Class: Gem::Commands::DeepFetchCommand

Inherits:
Gem::Command
  • Object
show all
Includes:
LocalRemoteOptions, VersionOption
Defined in:
lib/rubygems/commands/deep_fetch_command.rb

Instance Method Summary collapse

Constructor Details

#initializeDeepFetchCommand

Returns a new instance of DeepFetchCommand.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubygems/commands/deep_fetch_command.rb', line 11

def initialize
  super 'deep_fetch', 'Download a gem and its dependencies, place them in the current directory'

  add_bulk_threshold_option
  add_proxy_option
  add_source_option
  add_clear_sources_option

  add_version_option
  # TODO add_platform_option
  # TODO add_prerelease_option
end

Instance Method Details

#argumentsObject

:nodoc:



24
25
26
# File 'lib/rubygems/commands/deep_fetch_command.rb', line 24

def arguments # :nodoc:
  'GEMNAME       name of gem to download'
end

#defaults_strObject

:nodoc:



28
29
30
# File 'lib/rubygems/commands/deep_fetch_command.rb', line 28

def defaults_str # :nodoc:
  "--version '#{Gem::Requirement.default}'"
end

#descriptionObject

:nodoc:



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rubygems/commands/deep_fetch_command.rb', line 32

def description # :nodoc:
  "The deep_fetch command fetches gem files that can be stored for later use\nor unpacked to examine their contents.\n\nUnlike the built-in fetch command, deep_fetch command fetches the\ndependencies but ignores the gems that are already installed.\n\ndeep_fetch is usefull to examine new packages before installing them.\n"
end

#executeObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rubygems/commands/deep_fetch_command.rb', line 48

def execute
  version = options[:version] || Gem::Requirement.default
  gem_names = get_all_gem_names

  deps = gem_names.map do |gem_name|
    Gem::Dependency.new gem_name, version
  end

  resolver = Gem::DependencyResolver.new deps;
  action_requests = resolver.resolve;

  action_requests.reject do |ar|
    ar.installed?
  end.each do |ar|
    spec = ar.spec
    full_spec = spec.spec
    source = spec.source
    source.download full_spec
    say "Downloaded #{spec.full_name}"
    spec.full_name
  end
end

#usageObject

:nodoc:



44
45
46
# File 'lib/rubygems/commands/deep_fetch_command.rb', line 44

def usage # :nodoc:
  "#{program_name} GEMNAME [GEMNAME ...]"
end