aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/commands/fetch_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/commands/fetch_command.rb')
-rw-r--r--lib/rubygems/commands/fetch_command.rb16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb
index 7db365eba0..ccedc45401 100644
--- a/lib/rubygems/commands/fetch_command.rb
+++ b/lib/rubygems/commands/fetch_command.rb
@@ -44,17 +44,15 @@ class Gem::Commands::FetchCommand < Gem::Command
spec, source_uri = specs_and_sources.last
- gem_file = "#{spec.full_name}.gem"
-
- gem_path = File.join source_uri, 'gems', gem_file
-
- gem = Gem::RemoteFetcher.fetcher.fetch_path gem_path
-
- File.open gem_file, 'wb' do |fp|
- fp.write gem
+ if spec.nil? then
+ alert_error "Could not find #{gem_name} in any repository"
+ next
end
- say "Downloaded #{gem_file}"
+ path = Gem::RemoteFetcher.fetcher.download spec, source_uri
+ FileUtils.mv path, "#{spec.full_name}.gem"
+
+ say "Downloaded #{spec.full_name}"
end
end