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. - #eql?(other) ⇒ Boolean
-
#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.
- #hash ⇒ Object
-
#initialize(spec, request) ⇒ 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.
-
#parent ⇒ Object
Return the ActivationRequest that contained the dependency that we were activated for.
-
#platform ⇒ Object
The platform of this activation request’s specification.
-
#pretty_print(q) ⇒ Object
:nodoc:.
-
#version ⇒ Object
The version of this activation request’s specification.
Constructor Details
#initialize(spec, request) ⇒ ActivationRequest
Creates a new ActivationRequest that will activate spec
. The parent request
is used to provide diagnostics in case of conflicts.
22 23 24 25 |
# File 'lib/rubygems/resolver/activation_request.rb', line 22 def initialize(spec, request) @spec = spec @request = request 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:
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rubygems/resolver/activation_request.rb', line 27 def ==(other) # :nodoc: case other when Gem::Specification @spec == other when Gem::Resolver::ActivationRequest @spec == other.spec else false end end |
#development? ⇒ Boolean
Is this activation request for a development dependency?
49 50 51 |
# File 'lib/rubygems/resolver/activation_request.rb', line 49 def development? @request.development? end |
#download(path) ⇒ Object
Downloads a gem at path
and returns the file path.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rubygems/resolver/activation_request.rb', line 56 def download(path) Gem.ensure_gem_subdirectories path if @spec.respond_to? :sources exception = nil path = @spec.sources.find do |source| 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 |
#eql?(other) ⇒ Boolean
38 39 40 |
# File 'lib/rubygems/resolver/activation_request.rb', line 38 def eql?(other) self == other end |
#full_name ⇒ Object Also known as: to_s
The full name of the specification to be activated.
81 82 83 |
# File 'lib/rubygems/resolver/activation_request.rb', line 81 def full_name name_tuple.full_name end |
#full_spec ⇒ Object
The Gem::Specification for this activation request.
90 91 92 |
# File 'lib/rubygems/resolver/activation_request.rb', line 90 def full_spec Gem::Specification === @spec ? @spec : @spec.spec end |
#hash ⇒ Object
42 43 44 |
# File 'lib/rubygems/resolver/activation_request.rb', line 42 def hash @spec.hash end |
#inspect ⇒ Object
:nodoc:
94 95 96 |
# File 'lib/rubygems/resolver/activation_request.rb', line 94 def inspect # :nodoc: format("#<%s for %p from %s>", self.class, @spec, @request) end |
#installed? ⇒ Boolean
True if the requested gem has already been installed.
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/rubygems/resolver/activation_request.rb', line 101 def installed? case @spec when Gem::Resolver::VendorSpecification then true else this_spec = full_spec Gem::Specification.any? do |s| s == this_spec && s.base_dir == this_spec.base_dir end end end |
#name ⇒ Object
The name of this activation request’s specification
117 118 119 |
# File 'lib/rubygems/resolver/activation_request.rb', line 117 def name @spec.name end |
#parent ⇒ Object
Return the ActivationRequest that contained the dependency that we were activated for.
125 126 127 |
# File 'lib/rubygems/resolver/activation_request.rb', line 125 def parent @request.requester end |
#platform ⇒ Object
The platform of this activation request’s specification
150 151 152 |
# File 'lib/rubygems/resolver/activation_request.rb', line 150 def platform @spec.platform end |
#pretty_print(q) ⇒ Object
:nodoc:
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/rubygems/resolver/activation_request.rb', line 129 def pretty_print(q) # :nodoc: q.group 2, "[Activation request", "]" do q.breakable q.pp @spec q.breakable q.text " for " q.pp @request end end |
#version ⇒ Object
The version of this activation request’s specification
143 144 145 |
# File 'lib/rubygems/resolver/activation_request.rb', line 143 def version @spec.version end |