Skip to content
Browse files

Added rake task to generate heroku .gems manifest

  • Loading branch information...
1 parent 8d93d58 commit f2dd9a01b6d258f8b11168adf0376c6de7e7bb5d Jeremy Weiskotten committed Nov 9, 2009
Showing with 27 additions and 0 deletions.
  1. +27 −0 lib/tasks/heroku.rake
View
27 lib/tasks/heroku.rake
@@ -0,0 +1,27 @@
+namespace :gems do
+ desc "Generate .gems file for Heroku"
+ task :heroku_spec => :environment do
+ require 'open-uri'
+ installed_gems = []
+ url = "http://installed-gems.heroku.com/"
+ open(url).read.scan(/<li>(\w+) [^<]*<\/li>/) do |w|
+ installed_gems << w.first
+ end
+
+ gems = Rails.configuration.gems
+
+ # output .gems
+ dot_gems = File.join(RAILS_ROOT, ".gems")
+ File.open(dot_gems, "w") do |f|
+ output = []
+ gems.each do |gem|
+ next if installed_gems.include?(gem.name)
+ 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

0 comments on commit f2dd9a0

Please sign in to comment.
Something went wrong with that request. Please try again.