Class: Gem::Resolver::ActivationRequest
- Inherits:
-
Object
- Object
- Gem::Resolver::ActivationRequest
- Defined in:
- lib/rubygems/resolver/activation_request.rb
Overview
Specifies a Specification object that should be activated. Also contains a dependency that was used to introduce this activation.
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
The parent request for this activation request.
-
#spec ⇒ Object
readonly
The specification to be activated.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
-
#development? ⇒ Boolean
Is this activation request for a development dependency?.
-
#download(path) ⇒ Object
Downloads a gem at
path
and returns the file path. -
#full_name ⇒ Object
(also: #to_s)
The full name of the specification to be activated.
-
#full_spec ⇒ Object
The Gem::Specification for this activation request.
-
#initialize(spec, request, others_possible = true) ⇒ ActivationRequest
constructor
Creates a new ActivationRequest that will activate
spec
. -
#inspect ⇒ Object
:nodoc:.
-
#installed? ⇒ Boolean
True if the requested gem has already been installed.
-
#name ⇒ Object
The name of this activation request’s specification.
-
#others_possible? ⇒ Boolean
Indicate if this activation is one of a set of possible requests for the same Dependency request.
-
#parent ⇒ Object
Return the ActivationRequest that contained the dependency that we were activated for.
-
#pretty_print(q) ⇒ Object
:nodoc:.
-
#version ⇒ Object
The version of this activation request’s specification.
Constructor Details
#initialize(spec, request, others_possible = true) ⇒ ActivationRequest
Creates a new ActivationRequest that will activate spec
. The parent request
is used to provide diagnostics in case of conflicts.
others_possible
indicates that other specifications may also match this activation request.
25 26 27 28 29 |
# File 'lib/rubygems/resolver/activation_request.rb', line 25 def initialize spec, request, others_possible = true @spec = spec @request = request @others_possible = others_possible end |
Instance Attribute Details
#request ⇒ Object (readonly)
The parent request for this activation request.
11 12 13 |
# File 'lib/rubygems/resolver/activation_request.rb', line 11 def request @request end |
#spec ⇒ Object (readonly)
The specification to be activated.
16 17 18 |
# File 'lib/rubygems/resolver/activation_request.rb', line 16 def spec @spec end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubygems/resolver/activation_request.rb', line 31 def == other # :nodoc: case other when Gem::Specification @spec == other when Gem::Resolver::ActivationRequest @spec == other.spec && @request == other.request else false end end |
#development? ⇒ Boolean
Is this activation request for a development dependency?
45 46 47 |
# File 'lib/rubygems/resolver/activation_request.rb', line 45 def development? @request.development? end |
#download(path) ⇒ Object
Downloads a gem at path
and returns the file path.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rubygems/resolver/activation_request.rb', line 52 def download path Gem.ensure_gem_subdirectories path if @spec.respond_to? :sources exception = nil path = @spec.sources.find{ |source| begin source.download full_spec, path rescue exception end } return path if path raise exception if exception elsif @spec.respond_to? :source source = @spec.source source.download full_spec, path else source = Gem.sources.first source.download full_spec, path end end |
#full_name ⇒ Object Also known as: to_s
The full name of the specification to be activated.
79 80 81 |
# File 'lib/rubygems/resolver/activation_request.rb', line 79 def full_name @spec.full_name end |
#full_spec ⇒ Object
The Gem::Specification for this activation request.
88 89 90 |
# File 'lib/rubygems/resolver/activation_request.rb', line 88 def full_spec Gem::Specification === @spec ? @spec : @spec.spec end |
#inspect ⇒ Object
:nodoc:
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/rubygems/resolver/activation_request.rb', line 92 def inspect # :nodoc: others = case @others_possible when true then # TODO remove at RubyGems 3 ' (others possible)' when false then # TODO remove at RubyGems 3 nil else unless @others_possible.empty? then others = @others_possible.map { |s| s.full_name } " (others possible: #{others.join ', '})" end end '#<%s for %p from %s%s>' % [ self.class, @spec, @request, others ] end |
#installed? ⇒ Boolean
True if the requested gem has already been installed.
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/rubygems/resolver/activation_request.rb', line 114 def installed? case @spec when Gem::Resolver::VendorSpecification then true else this_spec = full_spec Gem::Specification.any? do |s| s == this_spec end end end |
#name ⇒ Object
The name of this activation request’s specification
130 131 132 |
# File 'lib/rubygems/resolver/activation_request.rb', line 130 def name @spec.name end |
#others_possible? ⇒ Boolean
Indicate if this activation is one of a set of possible requests for the same Dependency request.
138 139 140 141 142 143 144 145 |
# File 'lib/rubygems/resolver/activation_request.rb', line 138 def others_possible? case @others_possible when true, false then @others_possible else not @others_possible.empty? end end |
#parent ⇒ Object
Return the ActivationRequest that contained the dependency that we were activated for.
151 152 153 |
# File 'lib/rubygems/resolver/activation_request.rb', line 151 def parent @request.requester end |
#pretty_print(q) ⇒ Object
:nodoc:
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/rubygems/resolver/activation_request.rb', line 155 def pretty_print q # :nodoc: q.group 2, '[Activation request', ']' do q.breakable q.pp @spec q.breakable q.text ' for ' q.pp @request case @others_possible when false then when true then q.breakable q.text 'others possible' else unless @others_possible.empty? then q.breakable q.text 'others ' q.pp @others_possible.map { |s| s.full_name } end end end end |
#version ⇒ Object
The version of this activation request’s specification
182 183 184 |
# File 'lib/rubygems/resolver/activation_request.rb', line 182 def version @spec.version end |