Created
March 30, 2013 17:50
-
-
Save havenwood/5277651 to your computer and use it in GitHub Desktop.
Create a Gemfile (irc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A gem: https://github.com/shockone/gemper