summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/unpack_command.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-31 22:40:06 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-31 22:40:06 +0000
commit8cc45aae947d453acca029e13eb64f3f5f0bf942 (patch)
treef9485a20c99defe1aae3f32555a41d23c2298ad8 /lib/rubygems/commands/unpack_command.rb
parentdc8359969ec71ece10357ba9396430db7f029e45 (diff)
Import RubyGems 1.1.0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/unpack_command.rb')
-rw-r--r--lib/rubygems/commands/unpack_command.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb
index 23ebabc21a..d187f8a9ea 100644
--- a/lib/rubygems/commands/unpack_command.rb
+++ b/lib/rubygems/commands/unpack_command.rb
@@ -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