Permalink
Browse files

Starting to import gems again and dealing with the inevitable problems

  • Loading branch information...
qrush committed May 30, 2009
1 parent dd2aec0 commit d3ebea03c19347b561c52435904ce3ac7f89cb05
Showing with 15 additions and 13 deletions.
  1. +6 −7 Rakefile
  2. +3 −2 app/models/rubygem.rb
  3. +6 −4 test/unit/rubygem_test.rb
View
@@ -9,16 +9,11 @@ require 'tasks/rails'
desc "Run all tests and features"
task :default => [:test, :features]
-=begin
desc "Clean out files that aren't needed."
task :clean do
system("git clean -dfx server/; git checkout server/")
end
-Spec::Rake::SpecTask.new do |t|
- t.spec_opts = ['--format', 'progress', '--color', '--backtrace']
-end
-
desc "Get the gem server up and running"
task :bootstrap do
Rake::Task["clean"].execute
@@ -99,7 +94,12 @@ namespace :import do
puts "Processing #{gems.size} gems..."
gems.each do |g|
puts g
- Rubygem.create(:data => File.open(g))
+ file = File.open(g)
+ spec = Rubygem.pull_spec(file)
+ rubygem = Rubygem.find_or_initialize_by_name(spec.name)
+ rubygem.spec = spec
+ rubygem.path = file.path
+ rubygem.save
end
end
end
@@ -116,4 +116,3 @@ begin
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end
-=end
View
@@ -21,9 +21,10 @@ def build
self.name = self.spec.name if self.name.blank?
version = self.versions.build(
- :authors => self.spec.authors,
+ :authors => self.spec.authors.join(", "),
:description => self.spec.description || self.spec.summary,
- :number => self.spec.version)
+ :created_at => self.spec.date,
+ :number => self.spec.version.to_s)
end
def store
View
@@ -58,9 +58,10 @@ class RubygemTest < ActiveSupport::TestCase
assert_equal 2, @rubygem.versions.size
version = @rubygem.versions.first
assert_not_nil version
- assert_equal @spec.authors, version.authors
+ assert_equal @spec.authors.join(", "), version.authors
assert_equal @spec.description, version.description
- assert_equal @spec.version, version.number
+ assert_equal @spec.version.to_s, version.number
+ assert_equal @spec.date, version.created_at
assert !version.new_record?
end
@@ -100,9 +101,10 @@ class RubygemTest < ActiveSupport::TestCase
should "create a new version" do
version = @rubygem.versions.first
assert_not_nil version
- assert_equal @spec.authors, version.authors
+ assert_equal @spec.authors.join(", "), version.authors
assert_equal @spec.description, version.description
- assert_equal @spec.version, version.number
+ assert_equal @spec.version.to_s, version.number
+ assert_equal @spec.date, version.created_at
assert !version.new_record?
end

0 comments on commit d3ebea0

Please sign in to comment.