mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Import RubyGems 1.1.0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dc8359969e
commit
8cc45aae94
82 changed files with 5776 additions and 2928 deletions
|
@ -38,6 +38,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|||
def execute
|
||||
gemname = get_one_gem_name
|
||||
path = get_path(gemname, options[:version])
|
||||
|
||||
if path then
|
||||
basename = File.basename(path).sub(/\.gem$/, '')
|
||||
target_dir = File.expand_path File.join(options[:target], basename)
|
||||
|
@ -66,16 +67,27 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|||
# source directories?
|
||||
def get_path(gemname, version_req)
|
||||
return gemname if gemname =~ /\.gem$/i
|
||||
specs = Gem::SourceIndex.from_installed_gems.search(/\A#{gemname}\z/, version_req)
|
||||
|
||||
specs = Gem::source_index.search(/\A#{gemname}\z/, version_req)
|
||||
|
||||
selected = specs.sort_by { |s| s.version }.last
|
||||
|
||||
return nil if selected.nil?
|
||||
|
||||
# We expect to find (basename).gem in the 'cache' directory.
|
||||
# Furthermore, the name match must be exact (ignoring case).
|
||||
if gemname =~ /^#{selected.name}$/i
|
||||
filename = selected.full_name + '.gem'
|
||||
return File.join(Gem.dir, 'cache', filename)
|
||||
path = nil
|
||||
|
||||
Gem.path.find do |gem_dir|
|
||||
path = File.join gem_dir, 'cache', filename
|
||||
File.exist? path
|
||||
end
|
||||
|
||||
path
|
||||
else
|
||||
return nil
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue