From 25a9b62d45ddd60a231272567c7dda9337da9b62 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 1 Mar 2011 09:41:32 +0000 Subject: Import rubygems 1.6.0 (released version @ 58d8a0b9) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/commands/unpack_command.rb | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'lib/rubygems/commands/unpack_command.rb') diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb index ac1d376106..ef0d65e073 100644 --- a/lib/rubygems/commands/unpack_command.rb +++ b/lib/rubygems/commands/unpack_command.rb @@ -7,6 +7,7 @@ require 'rubygems/command' require 'rubygems/installer' require 'rubygems/version_option' +require 'rubygems/remote_fetcher' class Gem::Commands::UnpackCommand < Gem::Command @@ -39,16 +40,6 @@ class Gem::Commands::UnpackCommand < Gem::Command "#{program_name} GEMNAME" end - def download dependency - found = Gem::SpecFetcher.fetcher.fetch dependency - - return if found.empty? - - spec, source_uri = found.first - - Gem::RemoteFetcher.fetcher.download spec, source_uri - end - #-- # TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for # this, so that it works for uninstall as well. (And check other commands @@ -79,8 +70,9 @@ class Gem::Commands::UnpackCommand < Gem::Command # TODO: see comments in get_path() about general service. def find_in_cache(filename) - Gem.path.each do |gem_dir| - this_path = File.join gem_dir, 'cache', filename + + Gem.path.each do |path| + this_path = Gem.cache_gem(filename, path) return this_path if File.exist? this_path end @@ -111,15 +103,17 @@ class Gem::Commands::UnpackCommand < Gem::Command selected = specs.sort_by { |s| s.version }.last - return download(dependency) if selected.nil? + return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless + selected return unless dependency.name =~ /^#{selected.name}$/i # We expect to find (basename).gem in the 'cache' directory. Furthermore, # the name match must be exact (ignoring case). - - path = find_in_cache(selected.file_name) - return download(dependency) unless path + + path = find_in_cache selected.file_name + + return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless path path end -- cgit v1.2.3