1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
ryan 2011-02-01 03:11:34 +00:00
parent f4234c9b8f
commit ec84bfc9e3
17 changed files with 201 additions and 46 deletions

View file

@ -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