Skip to content

Instantly share code, notes, and snippets.

@mkdynamic
Created September 23, 2009 10:54
Show Gist options
  • Save mkdynamic/191916 to your computer and use it in GitHub Desktop.
Save mkdynamic/191916 to your computer and use it in GitHub Desktop.
Spit out gems.yml and .gems in root of Rails app
namespace :gems do
desc "Spit out gems.yml and .gems in root of app (for Heroku + EY etc.)"
task :specify => :environment do
gems = Rails.configuration.gems
# output gems.yml
yaml = File.join(RAILS_ROOT, "gems.yml")
File.open(yaml, "w") do |f|
output = []
gems.each do |gem|
spec = { "name" => gem.name, "version" => gem.version_requirements.to_s }
spec["install_options"] = "--source #{gem.source}" if gem.source
output << spec
end
f.write output.to_yaml
puts output.to_yaml
end
# output .gems
dot_gems = File.join(RAILS_ROOT, ".gems")
File.open(dot_gems, "w") do |f|
output = []
gems.each do |gem|
spec = "#{gem.name} --version '#{gem.version_requirements.to_s}'"
spec << " --source #{gem.source}" if gem.source
output << spec
end
f.write output.join("\n")
puts output.join("\n")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment