summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/unpack_command.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-03-01 09:41:32 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-03-01 09:41:32 +0000
commit25a9b62d45ddd60a231272567c7dda9337da9b62 (patch)
treee72ba4c9c01cba5fb510eb1eafaba76d998baf4c /lib/rubygems/commands/unpack_command.rb
parent86bb0af7ea3b50f72e6845a6f5f64cb1b23fd279 (diff)
Import rubygems 1.6.0 (released version @ 58d8a0b9)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/unpack_command.rb')
-rw-r--r--lib/rubygems/commands/unpack_command.rb26
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb
index ac1d376106..ef0d65e073 100644
--- a/lib/rubygems/commands/unpack_command.rb
+++ b/lib/rubygems/commands/unpack_command.rb
@@ -7,6 +7,7 @@
require 'rubygems/command'
require 'rubygems/installer'
require 'rubygems/version_option'
+require 'rubygems/remote_fetcher'
class Gem::Commands::UnpackCommand < Gem::Command
@@ -39,16 +40,6 @@ class Gem::Commands::UnpackCommand < Gem::Command
"#{program_name} GEMNAME"
end
- def download dependency
- found = Gem::SpecFetcher.fetcher.fetch dependency
-
- return if found.empty?
-
- spec, source_uri = found.first
-
- Gem::RemoteFetcher.fetcher.download spec, source_uri
- end
-
#--
# TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for
# this, so that it works for uninstall as well. (And check other commands
@@ -79,8 +70,9 @@ class Gem::Commands::UnpackCommand < Gem::Command
# 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
+
+ Gem.path.each do |path|
+ this_path = Gem.cache_gem(filename, path)
return this_path if File.exist? this_path
end
@@ -111,15 +103,17 @@ class Gem::Commands::UnpackCommand < Gem::Command
selected = specs.sort_by { |s| s.version }.last
- return download(dependency) if selected.nil?
+ return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless
+ selected
return unless dependency.name =~ /^#{selected.name}$/i
# We expect to find (basename).gem in the 'cache' directory. Furthermore,
# the name match must be exact (ignoring case).
-
- path = find_in_cache(selected.file_name)
- return download(dependency) unless path
+
+ path = find_in_cache selected.file_name
+
+ return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless path
path
end