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: 
37:     gem_names = get_all_gem_names
38: 
39:     gem_names.each do |gem_name|
40:       dep = Gem::Dependency.new gem_name, version
41:       specs_and_sources = Gem::SourceInfoCache.search_with_source dep, true
42: 
43:       specs_and_sources.sort_by { |spec,| spec.version }
44: 
45:       spec, source_uri = specs_and_sources.last
46: 
47:       if spec.nil? then
48:         alert_error "Could not find #{gem_name} in any repository"
49:         next
50:       end
51: 
52:       path = Gem::RemoteFetcher.fetcher.download spec, source_uri
53:       FileUtils.mv path, "#{spec.full_name}.gem"
54: 
55:       say "Downloaded #{spec.full_name}"
56:     end
57:   end

[Validate]