Class: Gem::Resolver::ActivationRequest
Relationships & Source Files | |
Inherits: | Object |
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.
Class Method Summary
-
.new(spec, request, others_possible = true) ⇒ ActivationRequest
constructor
Creates a new
ActivationRequest
that will activate #spec.
Instance Attribute Summary
-
#development? ⇒ Boolean
readonly
Is this activation request for a development dependency?
-
#installed? ⇒ Boolean
readonly
True if the requested gem has already been installed.
-
#others_possible? ⇒ Boolean
readonly
Indicate if this activation is one of a set of possible requests for the same
::Gem::Dependency
request. -
#request
readonly
The parent request for this activation request.
-
#spec
readonly
The specification to be activated.
Instance Method Summary
-
#download(path)
Downloads a gem at Gem.path and returns the file path.
-
#full_name
(also: #to_s)
The full name of the specification to be activated.
-
#full_spec
The
::Gem::Specification
for this activation request. -
#name
The name of this activation request’s specification.
-
#parent
Return the
ActivationRequest
that contained the dependency that we were activated for. -
#to_s
Alias for #full_name.
-
#version
The version of this activation request’s specification.
- #==(other) Internal use only
- #inspect Internal use only
- #pretty_print(q) Internal use only
Constructor Details
.new(spec, request, others_possible = true) ⇒ ActivationRequest
Instance Attribute Details
#development? ⇒ Boolean
(readonly)
Is this activation request for a development dependency?
# File 'lib/rubygems/resolver/activation_request.rb', line 45
def development? @request.development? end
#installed? ⇒ Boolean
(readonly)
True if the requested gem has already been installed.
# 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
#others_possible? ⇒ Boolean
(readonly)
Indicate if this activation is one of a set of possible requests for the same ::Gem::Dependency
request.
# 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
#request (readonly)
The parent request for this activation request.
# File 'lib/rubygems/resolver/activation_request.rb', line 11
attr_reader :request
#spec (readonly)
The specification to be activated.
# File 'lib/rubygems/resolver/activation_request.rb', line 16
attr_reader :spec
Instance Method Details
#==(other)
#download(path)
Downloads a gem at Gem.path and returns the file path.
# 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 Also known as: #to_s
The full name of the specification to be activated.
# File 'lib/rubygems/resolver/activation_request.rb', line 79
def full_name @spec.full_name end
#full_spec
The ::Gem::Specification
for this activation request.
# File 'lib/rubygems/resolver/activation_request.rb', line 88
def full_spec Gem::Specification === @spec ? @spec : @spec.spec end
#inspect
# 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? 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
#name
The name of this activation request’s specification
# File 'lib/rubygems/resolver/activation_request.rb', line 130
def name @spec.name end
#parent
Return the ActivationRequest
that contained the dependency that we were activated for.
# File 'lib/rubygems/resolver/activation_request.rb', line 151
def parent @request.requester end
#pretty_print(q)
# 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? q.breakable q.text 'others ' q.pp @others_possible.map { |s| s.full_name } end end end end
#to_s
Alias for #full_name.
# File 'lib/rubygems/resolver/activation_request.rb', line 83
alias_method :to_s, :full_name
#version
The version of this activation request’s specification
# File 'lib/rubygems/resolver/activation_request.rb', line 182
def version @spec.version end