diff --git a/Rakefile b/Rakefile index f08acb199ba..c906f15fedd 100644 --- a/Rakefile +++ b/Rakefile @@ -8,3 +8,5 @@ require 'tasks/rails' desc "Run all tests and features" task :default => ['gemcutter:index:create', :test, :features] + +task :cron => ['gemcutter:update'] diff --git a/lib/tasks/gemcutter.rake b/lib/tasks/gemcutter.rake index 2ddd4a021c6..4f55c8cd555 100644 --- a/lib/tasks/gemcutter.rake +++ b/lib/tasks/gemcutter.rake @@ -195,7 +195,11 @@ namespace :gemcutter do desc 'Get the latest gems from rubyforge and index them here' task :update => :environment do + return unless Rails.env.production? + + require 'open-uri' require 'rubygems/commands/list_command' + ins = StringIO.new outs = StringIO.new Gem::DefaultUserInteraction.ui = Gem::StreamUI.new(ins, outs) @@ -224,10 +228,17 @@ namespace :gemcutter do downloads << "#{name}-#{version}.gem" end end - puts downloads.size - downloads.each { |d| puts d } - # cutter = Gemcutter.new(nil, StringIO.new(File.open(path).read)) - # cutter.pull_spec and cutter.find and cutter.save + + end + + downloads.each do |download| + puts "Downloading #{download}..." + begin + cutter = Gemcutter.new(nil, StringIO.new(open("http://gems.rubyforge.org/gems/#{download}").read)) + cutter.pull_spec and cutter.find and cutter.build and cutter.save + rescue Exception => e + puts e.message + end end end end