Permalink
Browse files

Upgrade RubyGems API usage

* Gem::SourceInfoCache is deprecated and functionality was broken.

Signed-off-by: Alex Coles <alex@alexcolesportfolio.com>
  • Loading branch information...
1 parent e6be9e0 commit 996cc69c7111ef85860224cae001a15d702c2992 @myabc myabc committed Dec 17, 2009
Showing with 13 additions and 10 deletions.
  1. +4 −2 app/models/code.rb
  2. +9 −8 app/models/gem_importer.rb
View
@@ -49,9 +49,11 @@ def to_xml(options = {})
end
end
- def self.new_from_gem_spec(spec)
- f = find_or_initialize_by_name(spec.name.to_s)
+ def self.new_from_gem_tuple(gem_tuple)
+ f = find_or_initialize_by_name(gem_tuple[0])
if f.new_record?
+ require 'rubygems'
+ spec = Gem::SpecFetcher.fetcher.fetch_spec(gem_tuple, URI.parse(GemImporter::GEMCUTTER_URI))
f.attributes = {:description => spec.description, :homepage => spec.homepage, :rubyforge => spec.rubyforge_project, :summary => spec.summary}
f.code_type = "gem"
f.save!
View
@@ -1,15 +1,16 @@
require 'rubygems'
-require "rubygems/source_info_cache"
+
class GemImporter
-
+
+ GEMCUTTER_URI = 'http://gemcutter.org/'
+
def self.import
- a = Gem::SourceInfoCache.new
- a.refresh(true) #seems to want an argument but never uses it...
- a.cache_data["http://gems.rubyforge.org/"].source_index.each do |gem_name, gem|
- Code.new_from_gem_spec(gem)
+ # Gem::SpecFetcher.fetcher.list.each { |source, gems| }
+ Gem::SpecFetcher.fetcher.list[URI.parse(GEMCUTTER_URI)].each do |g|
+ Code.new_from_gem_tuple(g)
end
rescue Exception => ex
puts ex.message
end
-
-end
+
+end

0 comments on commit 996cc69

Please sign in to comment.