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:   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
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: 
43:       specs_and_sources = Gem::SpecFetcher.fetcher.fetch dep, all
44: 
45:       specs_and_sources.sort_by { |spec,| spec.version }
46: 
47:       spec, source_uri = specs_and_sources.last
48: 
49:       if spec.nil? then
50:         alert_error "Could not find #{gem_name} in any repository"
51:         next
52:       end
53: 
54:       path = Gem::RemoteFetcher.fetcher.download spec, source_uri
55:       FileUtils.mv path, "#{spec.full_name}.gem"
56: 
57:       say "Downloaded #{spec.full_name}"
58:     end
59:   end

[Validate]