From ec84bfc9e3d11a3b1dbebcaf4d1ddf1357307513 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 1 Feb 2011 03:11:34 +0000 Subject: Import rubygems 1.5.0 (released version @ 1fb59d0) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/commands/unpack_command.rb | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 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 5e0bc830f2..ac1d376106 100644 --- a/lib/rubygems/commands/unpack_command.rb +++ b/lib/rubygems/commands/unpack_command.rb @@ -71,6 +71,22 @@ class Gem::Commands::UnpackCommand < Gem::Command end end + ## + # + # Find cached filename in Gem.path. Returns nil if the file cannot be found. + # + #-- + # 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 + return this_path if File.exist? this_path + end + + return nil + end + ## # Return the full path to the cached gem file matching the given # name and version requirement. Returns 'nil' if no match. @@ -101,13 +117,9 @@ class Gem::Commands::UnpackCommand < Gem::Command # We expect to find (basename).gem in the 'cache' directory. Furthermore, # the name match must be exact (ignoring case). - filename = selected.file_name - path = nil - - Gem.path.find do |gem_dir| - path = File.join gem_dir, 'cache', filename - File.exist? path - end + + path = find_in_cache(selected.file_name) + return download(dependency) unless path path end -- cgit v1.2.3