Skip to content

Instantly share code, notes, and snippets.

@rylwin
Created June 10, 2010 19:45
Show Gist options
  • Save rylwin/433530 to your computer and use it in GitHub Desktop.
Save rylwin/433530 to your computer and use it in GitHub Desktop.
Rake task to generate heroku .gems file from gems listed in environment.rb
namespace :heroku do
desc "Update .gems with a list of the required gems"
task :gems => 'gems:base' do
gem_lines = []
gem_array = Rails.configuration.gems.reject{|g| g.frozen? && !g.framework_gem?}.map do |gem|
line = gem.name
line += " --source #{gem.source}" if gem.source
line += " --version '#{gem.requirement.to_s}'" if gem.requirement
gem_lines << line
end
if (RAILS_GEM_VERSION rescue false)
gem_lines << "rails --version #{RAILS_GEM_VERSION}"
else
gem_lines << 'rails'
end
config_path = File.join(Dir.pwd, '.gems')
file = File.open( config_path, 'w' )
file.write(gem_lines.join("\n"))
file.close
puts ".gems has been updated with your application's gem dependencies."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment