Skip to content

Instantly share code, notes, and snippets.

@look
Created February 18, 2010 21:39
Show Gist options
  • Save look/308097 to your computer and use it in GitHub Desktop.
Save look/308097 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