Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created March 30, 2013 17:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/5277651 to your computer and use it in GitHub Desktop.
Save havenwood/5277651 to your computer and use it in GitHub Desktop.
Create a Gemfile (irc)
abort 'Aborting. Gemfile already exists.' if File.exists? 'Gemfile'
@requires = []
files = Dir['*.rb']
files.each do |file|
open file do |file|
file.each do |line|
@requires << line.chomp if line.start_with? 'require '
end
end
end
@requires.map do |e|
e.gsub!('require ', '').gsub!(/'|"/, '').gsub!('/', '-')
end
# TODO: Remove stdlib matches.
open 'Gemfile', 'w' do |file|
file << "source 'https://rubygems.org'\n"
@requires.each do |gem|
file << "gem '#{gem}'\n"
end
end
puts 'Gemfile created.'
@vlad-shatskyi
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment