Browse files

Moving fixing full names into rake task

  • Loading branch information...
1 parent 903175a commit e12523b0407e84b264880e108907623920975922 @qrush qrush committed Nov 9, 2009
Showing with 13 additions and 33 deletions.
  1. +0 −7 db/migrate/20091109203935_add_full_name_to_versions.rb
  2. +3 −1 db/schema.rb
  3. +10 −25 lib/tasks/gemcutter.rake
View
7 db/migrate/20091109203935_add_full_name_to_versions.rb
@@ -1,13 +1,6 @@
class AddFullNameToVersions < ActiveRecord::Migration
def self.up
add_column :versions, :full_name, :string
-
- Version.without_any_callbacks do
- Version.all(:include => :rubygem).each do |version|
- version.full_nameify!
- end
- end
-
add_index 'versions', 'full_name'
end
View
4 db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20091021203534) do
+ActiveRecord::Schema.define(:version => 20091109203935) do
create_table "delayed_jobs", :force => true do |t|
t.integer "priority", :default => 0
@@ -140,10 +140,12 @@
t.integer "position"
t.integer "downloads_count", :default => 0
t.boolean "latest"
+ t.string "full_name"
end
add_index "versions", ["built_at"], :name => "index_versions_on_built_at"
add_index "versions", ["created_at"], :name => "index_versions_on_created_at"
+ add_index "versions", ["full_name"], :name => "index_versions_on_full_name"
add_index "versions", ["indexed"], :name => "index_versions_on_indexed"
add_index "versions", ["number"], :name => "index_versions_on_number"
add_index "versions", ["position"], :name => "index_versions_on_position"
View
35 lib/tasks/gemcutter.rake
@@ -15,6 +15,16 @@ namespace :gemcutter do
puts "Ding, legacy index is done!"
end
+ desc "fix full names"
+ task :fix_full_names => :environment do
+ Version.without_any_callbacks do
+ def Version.run_callbacks; "no idea why this is necessary"; end
+ Version.all(:include => :rubygem).each do |version|
+ version.full_nameify!
+ end
+ end
+ end
+
namespace :index do
desc "Create the index"
task :create => :environment do
@@ -150,29 +160,4 @@ namespace :gemcutter do
Gemcutter.indexer.update_index(source_index)
end
end
-
- desc "Backup all .gem files"
- task :backup do
- require 'open-uri'
- gemcutter_gems = Marshal.load(Gem.gunzip(open("http://gemcutter.org/specs.4.8.gz").read))
- gemcutter_gems.each do |index|
- index.pop if index.last == "ruby"
- gem_name = "#{index.join('-')}.gem"
- FileUtils.mkdir("cache") unless File.exist?("cache")
- gem_path = File.join("cache", gem_name)
- gem_uri = "http://gemcutter.org/gems/#{gem_name}"
-
- unless File.exists?(gem_path)
- begin
- puts ">> Downloading #{gem_name}"
- File.open(gem_path, "wb") do |f|
- f.write open(gem_uri).read
- end
- rescue Exception => e
- puts ">> Problem fetching the gem: #{e.message}"
- puts e.backtrace
- end
- end
- end
- end
end

0 comments on commit e12523b

Please sign in to comment.