Permalink
Browse files

Get SourceIndex seperated from Gem::SourceIndex

  • Loading branch information...
1 parent de69b18 commit a960244a0893b5ab7acf0930fbe58ce26915410c @evanphx evanphx committed Jun 2, 2011
Showing with 28 additions and 35 deletions.
  1. +3 −7 lib/source_index_fp.rb
  2. +8 −11 test/gemutilities.rb
  3. +13 −13 test/test_gem_source_index.rb
  4. +2 −2 test/test_gemfile.rb
  5. +2 −2 test/test_rubygems_fp.rb
View
10 lib/source_index_fp.rb
@@ -4,15 +4,11 @@
# See LICENSE.txt for permissions.
#++
+require 'rubygems_fp'
+
require 'rubygems/user_interaction'
require 'rubygems/specification'
-# :stopdoc:
-module Gem
- autoload :SpecFetcher, 'rubygems/spec_fetcher'
-end
-# :startdoc:
-
##
# The SourceIndex object indexes all the gems available from a
# particular source (e.g. a list of gem directories, or a remote
@@ -24,7 +20,7 @@ module Gem
# constant Gem::Cache is an alias for this class to allow old
# YAMLized source index objects to load properly.
-class Gem::SourceIndex
+class RubyGemsFP::SourceIndex
include Enumerable
View
19 test/gemutilities.rb
@@ -183,17 +183,17 @@ def mu_pp(obj)
end
def prep_cache_files(lc)
- @usr_si ||= Gem::SourceIndex.new
+ @usr_si ||= RubyGemsFP::SourceIndex.new
@usr_sice ||= Gem::SourceInfoCacheEntry.new @usr_si, 0
- @sys_si ||= Gem::SourceIndex.new
+ @sys_si ||= RubyGemsFP::SourceIndex.new
@sys_sice ||= Gem::SourceInfoCacheEntry.new @sys_si, 0
- latest_si = Gem::SourceIndex.new
+ latest_si = RubyGemsFP::SourceIndex.new
latest_si.add_specs(*@sys_si.latest_specs)
latest_sys_sice = Gem::SourceInfoCacheEntry.new latest_si, 0
- latest_si = Gem::SourceIndex.new
+ latest_si = RubyGemsFP::SourceIndex.new
latest_si.add_specs(*@usr_si.latest_specs)
latest_usr_sice = Gem::SourceInfoCacheEntry.new latest_si, 0
@@ -242,7 +242,6 @@ def quick_gem(gemname, version='2')
s.author = 'A User'
s.email = 'example@example.com'
s.homepage = 'http://example.com'
- s.has_rdoc = true
s.summary = "this is a summary"
s.description = "This is a test description"
@@ -256,7 +255,7 @@ def quick_gem(gemname, version='2')
spec.loaded_from = written_path
- Gem.source_index.add_spec spec
+ # @source_index.add_spec spec
return spec
end
@@ -284,7 +283,7 @@ def util_build_gem(spec)
def util_clear_gems
FileUtils.rm_r File.join(@gemhome, 'gems')
FileUtils.rm_r File.join(@gemhome, 'specifications')
- Gem.source_index.refresh!
+ @source_index.refresh!
end
def util_gem(name, version, &block)
@@ -366,8 +365,6 @@ def util_make_gems(prerelease = false)
end
FileUtils.rm_r File.join(@gemhome, 'gems', @pl1.original_name)
-
- Gem.source_index = nil
end
##
@@ -388,6 +385,7 @@ def util_setup_fake_fetcher(prerelease = false)
require 'socket'
require 'rubygems/remote_fetcher'
+ @source_index = RubyGemsFP::SourceIndex.new
@fetcher = Gem::FakeFetcher.new
util_make_gems(prerelease)
@@ -398,7 +396,6 @@ def util_setup_fake_fetcher(prerelease = false)
gem_names = [@a1.full_name, @a2.full_name, @a3a.full_name, @b2.full_name]
@gem_names = gem_names.sort.join("\n")
- @source_index = Gem::SourceIndex.new
@source_index.add_spec @a1
@source_index.add_spec @a2
@source_index.add_spec @a3a
@@ -411,7 +408,7 @@ def util_setup_fake_fetcher(prerelease = false)
def util_setup_spec_fetcher(*specs)
specs = Hash[*specs.map { |spec| [spec.full_name, spec] }.flatten]
- si = Gem::SourceIndex.new specs
+ si = RubyGemsFP::SourceIndex.new specs
spec_fetcher = Gem::SpecFetcher.fetcher
View
26 test/test_gem_source_index.rb
@@ -2,7 +2,7 @@
require File.expand_path('../../lib/source_index_fp', __FILE__)
require 'rubygems/config_file'
-class Gem::SourceIndex
+class RubyGemsFP::SourceIndex
public :fetcher, :fetch_bulk_index, :fetch_quick_index,
:find_missing, :gems, :remove_extra,
:update_with_missing, :unzip
@@ -31,7 +31,7 @@ def test_self_from_gems_in
fp.write a1.to_ruby
end
- si = Gem::SourceIndex.from_gems_in spec_dir
+ si = RubyGemsFP::SourceIndex.from_gems_in spec_dir
assert_equal [spec_dir], si.spec_dirs
assert_equal [a1.full_name], si.gems.keys
@@ -52,7 +52,7 @@ def test_self_load_specification
fp.write a1.to_ruby
end
- spec = Gem::SourceIndex.load_specification spec_file
+ spec = RubyGemsFP::SourceIndex.load_specification spec_file
assert_equal a1.author, spec.author
end
@@ -97,7 +97,7 @@ def test_self_load_specification_utf_8
File.open spec_file, 'w' do |io| io.write spec_data end
- spec = Gem::SourceIndex.load_specification spec_file
+ spec = RubyGemsFP::SourceIndex.load_specification spec_file
pi = "\317\200"
pi.force_encoding 'UTF-8' if pi.respond_to? :force_encoding
@@ -117,7 +117,7 @@ def test_self_load_specification_exception
end
use_ui @ui do
- assert_equal nil, Gem::SourceIndex.load_specification(spec_file)
+ assert_equal nil, RubyGemsFP::SourceIndex.load_specification(spec_file)
end
assert_equal '', @ui.output
@@ -144,7 +144,7 @@ def test_self_load_specification_interrupt
use_ui @ui do
assert_raises Interrupt do
- Gem::SourceIndex.load_specification(spec_file)
+ RubyGemsFP::SourceIndex.load_specification(spec_file)
end
end
@@ -164,7 +164,7 @@ def test_self_load_specification_syntax_error
end
use_ui @ui do
- assert_equal nil, Gem::SourceIndex.load_specification(spec_file)
+ assert_equal nil, RubyGemsFP::SourceIndex.load_specification(spec_file)
end
assert_equal '', @ui.output
@@ -186,7 +186,7 @@ def test_self_load_specification_system_exit
use_ui @ui do
assert_raises SystemExit do
- Gem::SourceIndex.load_specification(spec_file)
+ RubyGemsFP::SourceIndex.load_specification(spec_file)
end
end
@@ -221,7 +221,7 @@ def test_find_name
assert_equal [], @source_index.find_name('bogusstring')
assert_equal [], @source_index.find_name('a', '= 3')
- source_index = Gem::SourceIndex.new
+ source_index = RubyGemsFP::SourceIndex.new
source_index.add_spec @a1
source_index.add_spec @a2
@@ -232,7 +232,7 @@ def test_find_name
end
def test_find_name_empty_cache
- empty_source_index = Gem::SourceIndex.new({})
+ empty_source_index = RubyGemsFP::SourceIndex.new({})
assert_equal [], empty_source_index.find_name("foo")
end
@@ -338,7 +338,7 @@ def test_refresh_bang
FileUtils.mv a1_spec, @tempdir
- source_index = Gem::SourceIndex.from_installed_gems
+ source_index = RubyGemsFP::SourceIndex.from_installed_gems
refute source_index.gems.include?(@a1.full_name)
@@ -350,7 +350,7 @@ def test_refresh_bang
end
def test_refresh_bang_not_from_dir
- source_index = Gem::SourceIndex.new
+ source_index = RubyGemsFP::SourceIndex.new
e = assert_raises RuntimeError do
source_index.refresh!
@@ -415,7 +415,7 @@ def test_search_platform
s.platform = Gem::Platform.new 'x86-other_platform1'
end
- si = Gem::SourceIndex.new(a1.full_name => a1, a1_mine.full_name => a1_mine,
+ si = RubyGemsFP::SourceIndex.new(a1.full_name => a1, a1_mine.full_name => a1_mine,
a1_other.full_name => a1_other)
dep = Gem::Dependency.new 'a', Gem::Requirement.new('1')
View
4 test/test_gemfile.rb
@@ -1,8 +1,8 @@
require "rubygems"
require "rubygems_fp"
-require "test/unit"
+require 'minitest/autorun'
-class TestRubyGemsFPGemFile < Test::Unit::TestCase
+class TestRubyGemsFPGemFile < MiniTest::Unit::TestCase
def setup
@path = File.expand_path("../test-1.0.gem", __FILE__)
end
View
4 test/test_rubygems_fp.rb
@@ -1,4 +1,4 @@
-require "test/unit"
+require "minitest/autorun"
require "rubygems_fp"
require "yaml"
require "pathname"
@@ -7,7 +7,7 @@
STDERR.puts "===== Testing against RubyGems: #{Gem::VERSION}"
-class TestRubyGemsFPSpecification < Test::Unit::TestCase
+class TestRubyGemsFPSpecification < MiniTest::Unit::TestCase
def setup
tmpdir = File.expand_path("tmp/test")

0 comments on commit a960244

Please sign in to comment.