aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/test_utilities.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 06:52:18 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 06:52:18 +0000
commit9694bb8cac12969300692dac5a1cf7aa4e3a46cd (patch)
treec3cb423d701f7049ba9382de052e2a937cd1302d /lib/rubygems/test_utilities.rb
parent3f606b7063fc7a8b191556365ad343a314719a8d (diff)
downloadruby-9694bb8cac12969300692dac5a1cf7aa4e3a46cd.tar.gz
* lib/rubygems*: Updated to RubyGems 2.0
* test/rubygems*: ditto. * common.mk (prelude): Updated for RubyGems 2.0 source rearrangement. * tool/change_maker.rb: Allow invalid UTF-8 characters in source files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/test_utilities.rb')
-rw-r--r--lib/rubygems/test_utilities.rb30
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index 1a8fb5a0ad..bd5f2134be 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -24,11 +24,17 @@ class Gem::FakeFetcher
attr_reader :data
attr_reader :last_request
+ attr_reader :api_endpoints
attr_accessor :paths
def initialize
@data = {}
@paths = []
+ @api_endpoints = {}
+ end
+
+ def api_endpoint(uri)
+ @api_endpoints[uri] || uri
end
def find_data(path)
@@ -57,6 +63,15 @@ class Gem::FakeFetcher
end
end
+ def cache_update_path uri, path = nil
+ if data = fetch_path(uri)
+ open(path, 'wb') { |io| io.write data } if path
+ data
+ else
+ Gem.read_binary(path) if path
+ end
+ end
+
# Thanks, FakeWeb!
def open_uri_or_path(path)
data = find_data(path)
@@ -98,7 +113,13 @@ class Gem::FakeFetcher
def download spec, source_uri, install_dir = Gem.dir
name = File.basename spec.cache_file
- path = File.join install_dir, "cache", name
+ path = if Dir.pwd == install_dir then # see fetch_command
+ install_dir
+ else
+ File.join install_dir, "cache"
+ end
+
+ path = File.join path, name
Gem.ensure_gem_subdirectories install_dir
@@ -114,14 +135,13 @@ class Gem::FakeFetcher
end
def download_to_cache dependency
- found = Gem::SpecFetcher.fetcher.fetch dependency, true, true,
- dependency.prerelease?
+ found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dependency
return if found.empty?
- spec, source_uri = found.first
+ spec, source = found.first
- download spec, source_uri
+ download spec, source.uri.to_s
end
end