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 10
10:   def initialize
11:     super 'fetch', 'Download a gem and place it in the current directory'
12: 
13:     add_bulk_threshold_option
14:     add_proxy_option
15:     add_source_option
16: 
17:     add_version_option
18:     add_platform_option
19:     add_prerelease_option
20:   end

Public Instance methods

[Source]

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

[Validate]