Browse files

Wrapping up the update task

  • Loading branch information...
1 parent 42b7d93 commit 21877dd45b68736b963c54af91feab3f1015f9a6 @qrush qrush committed Aug 4, 2009
Showing with 17 additions and 4 deletions.
  1. +2 −0 Rakefile
  2. +15 −4 lib/tasks/gemcutter.rake
View
2 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']
View
19 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

0 comments on commit 21877dd

Please sign in to comment.