Skip to content

Instantly share code, notes, and snippets.

@mattash
Forked from look/convert.rb
Created February 21, 2010 07:16
Show Gist options
  • Save mattash/310179 to your computer and use it in GitHub Desktop.
Save mattash/310179 to your computer and use it in GitHub Desktop.
# Convert a Gemfile to Heroku's .gems file plus config.gem statements for Rails 2.3
herokuconfig = ""
railsconfig = ""
gemfile = File.new("Gemfile")
gemfile.readlines.each do |line|
if line =~ /gem ['"](\w+)['"](?:, ['"](.+?)['"]){0,1}(?:, :require => ['"](.+?)['"]){0,1}/
herokuconfig << "#{$1}" + ($2 ? %Q( --version "#{$2}") : '') + "\n"
railsconfig << "config.gem '#{$1}'" + ($2 ? ", :version => '#{$2}'" : '') + ($3 ? ", :lib => '#{$3}'" : '') + "\n"
end
end
puts herokuconfig
puts railsconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment