Class Gem::Commands::FetchCommand
In: lib/rubygems/commands/fetch_command.rb
Parent: Gem::Command

Methods

execute   new  

Included Modules

Gem::LocalRemoteOptions Gem::VersionOption

Public Class methods

[Source]

    # File lib/rubygems/commands/fetch_command.rb, line 11
11:   def initialize
12:     super 'fetch', 'Download a gem and place it in the current directory'
13: 
14:     add_bulk_threshold_option
15:     add_proxy_option
16:     add_source_option
17: 
18:     add_version_option
19:     add_platform_option
20:     add_prerelease_option
21:   end

Public Instance methods

[Source]

    # File lib/rubygems/commands/fetch_command.rb, line 35
35:   def execute
36:     version = options[:version] || Gem::Requirement.default
37:     all = Gem::Requirement.default != version
38: 
39:     gem_names = get_all_gem_names
40: 
41:     gem_names.each do |gem_name|
42:       dep = Gem::Dependency.new gem_name, version
43:       dep.prerelease = options[:prerelease]
44: 
45:       specs_and_sources = Gem::SpecFetcher.fetcher.fetch(dep, all, true,
46:                                                          dep.prerelease?)
47: 
48:       specs_and_sources, errors =
49:         Gem::SpecFetcher.fetcher.fetch_with_errors(dep, all, true,
50:                                                    dep.prerelease?)
51: 
52:       spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
53: 
54:       if spec.nil? then
55:         show_lookup_failure gem_name, version, errors
56:         next
57:       end
58: 
59:       path = Gem::RemoteFetcher.fetcher.download spec, source_uri
60:       FileUtils.mv path, spec.file_name
61: 
62:       say "Downloaded #{spec.full_name}"
63:     end
64:   end

[Validate]