Skip to content
This repository
Browse code

Starting to import gems again and dealing with the inevitable problems

  • Loading branch information...
commit d3ebea03c19347b561c52435904ce3ac7f89cb05 1 parent dd2aec0
Nick Quaranto qrush authored
13 Rakefile
@@ -9,16 +9,11 @@ require 'tasks/rails'
9 9 desc "Run all tests and features"
10 10 task :default => [:test, :features]
11 11
12   -=begin
13 12 desc "Clean out files that aren't needed."
14 13 task :clean do
15 14 system("git clean -dfx server/; git checkout server/")
16 15 end
17 16
18   -Spec::Rake::SpecTask.new do |t|
19   - t.spec_opts = ['--format', 'progress', '--color', '--backtrace']
20   -end
21   -
22 17 desc "Get the gem server up and running"
23 18 task :bootstrap do
24 19 Rake::Task["clean"].execute
@@ -99,7 +94,12 @@ namespace :import do
99 94 puts "Processing #{gems.size} gems..."
100 95 gems.each do |g|
101 96 puts g
102   - Rubygem.create(:data => File.open(g))
  97 + file = File.open(g)
  98 + spec = Rubygem.pull_spec(file)
  99 + rubygem = Rubygem.find_or_initialize_by_name(spec.name)
  100 + rubygem.spec = spec
  101 + rubygem.path = file.path
  102 + rubygem.save
103 103 end
104 104 end
105 105 end
@@ -116,4 +116,3 @@ begin
116 116 rescue LoadError
117 117 puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
118 118 end
119   -=end
5 app/models/rubygem.rb
@@ -21,9 +21,10 @@ def build
21 21 self.name = self.spec.name if self.name.blank?
22 22
23 23 version = self.versions.build(
24   - :authors => self.spec.authors,
  24 + :authors => self.spec.authors.join(", "),
25 25 :description => self.spec.description || self.spec.summary,
26   - :number => self.spec.version)
  26 + :created_at => self.spec.date,
  27 + :number => self.spec.version.to_s)
27 28 end
28 29
29 30 def store
10 test/unit/rubygem_test.rb
@@ -58,9 +58,10 @@ class RubygemTest < ActiveSupport::TestCase
58 58 assert_equal 2, @rubygem.versions.size
59 59 version = @rubygem.versions.first
60 60 assert_not_nil version
61   - assert_equal @spec.authors, version.authors
  61 + assert_equal @spec.authors.join(", "), version.authors
62 62 assert_equal @spec.description, version.description
63   - assert_equal @spec.version, version.number
  63 + assert_equal @spec.version.to_s, version.number
  64 + assert_equal @spec.date, version.created_at
64 65 assert !version.new_record?
65 66 end
66 67
@@ -100,9 +101,10 @@ class RubygemTest < ActiveSupport::TestCase
100 101 should "create a new version" do
101 102 version = @rubygem.versions.first
102 103 assert_not_nil version
103   - assert_equal @spec.authors, version.authors
  104 + assert_equal @spec.authors.join(", "), version.authors
104 105 assert_equal @spec.description, version.description
105   - assert_equal @spec.version, version.number
  106 + assert_equal @spec.version.to_s, version.number
  107 + assert_equal @spec.date, version.created_at
106 108 assert !version.new_record?
107 109 end
108 110

0 comments on commit d3ebea0

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