diff options
author | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-01 03:11:34 +0000 |
---|---|---|
committer | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-01 03:11:34 +0000 |
commit | ec84bfc9e3d11a3b1dbebcaf4d1ddf1357307513 (patch) | |
tree | cc3b9df7f06f86c52f4d09c03f5c9a3876c87b67 /lib/rubygems/commands/unpack_command.rb | |
parent | f4234c9b8f4707c5979d9a3beddc19ceeb417bd8 (diff) |
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
Diffstat (limited to 'lib/rubygems/commands/unpack_command.rb')
-rw-r--r-- | lib/rubygems/commands/unpack_command.rb | 26 |
1 files changed, 19 insertions, 7 deletions
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 @@ -72,6 +72,22 @@ class Gem::Commands::UnpackCommand < Gem::Command 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 |