Class: Gem::Resolver::DependencyRequest
- Inherits:
-
Object
- Object
- Gem::Resolver::DependencyRequest
- Defined in:
- lib/rubygems/resolver/dependency_request.rb
Overview
Used Internally. Wraps a Dependency object to also track which spec contained the Dependency.
Instance Attribute Summary collapse
-
#dependency ⇒ Object
readonly
The wrapped Gem::Dependency.
-
#requester ⇒ Object
readonly
The request for this dependency.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
-
#development? ⇒ Boolean
Is this dependency a development dependency?.
-
#explicit? ⇒ Boolean
Indicate that the request is for a gem explicitly requested by the user.
-
#implicit? ⇒ Boolean
Indicate that the request is for a gem requested as a dependency of another gem.
-
#initialize(dependency, requester) ⇒ DependencyRequest
constructor
Creates a new DependencyRequest for
dependency
fromrequester
. -
#match?(spec, allow_prerelease = false) ⇒ Boolean
Does this dependency request match
spec
?. -
#matches_spec?(spec) ⇒ Boolean
Does this dependency request match
spec
?. -
#name ⇒ Object
The name of the gem this dependency request is requesting.
-
#pretty_print(q) ⇒ Object
:nodoc:.
-
#request_context ⇒ Object
Return a String indicating who caused this request to be added (only valid for implicit requests).
-
#requirement ⇒ Object
The version requirement for this dependency request.
-
#to_s ⇒ Object
:nodoc:.
- #type ⇒ Object
Constructor Details
#initialize(dependency, requester) ⇒ DependencyRequest
Creates a new DependencyRequest for dependency
from requester
. +requester may be nil if the request came from a user.
22 23 24 25 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 22 def initialize(dependency, requester) @dependency = dependency @requester = requester end |
Instance Attribute Details
#dependency ⇒ Object (readonly)
The wrapped Gem::Dependency
11 12 13 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 11 def dependency @dependency end |
#requester ⇒ Object (readonly)
The request for this dependency.
16 17 18 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 16 def requester @requester end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 27 def ==(other) # :nodoc: case other when Gem::Dependency @dependency == other when Gem::Resolver::DependencyRequest @dependency == other.dependency && @requester == other.requester else false end end |
#development? ⇒ Boolean
Is this dependency a development dependency?
41 42 43 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 41 def development? @dependency.type == :development end |
#explicit? ⇒ Boolean
Indicate that the request is for a gem explicitly requested by the user
78 79 80 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 78 def explicit? @requester.nil? end |
#implicit? ⇒ Boolean
Indicate that the request is for a gem requested as a dependency of another gem
86 87 88 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 86 def implicit? !explicit? end |
#match?(spec, allow_prerelease = false) ⇒ Boolean
Does this dependency request match spec
?
NOTE: #match? only matches prerelease versions when #dependency is a prerelease dependency.
51 52 53 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 51 def match?(spec, allow_prerelease = false) @dependency.match? spec, nil, allow_prerelease end |
#matches_spec?(spec) ⇒ Boolean
Does this dependency request match spec
?
NOTE: #matches_spec? matches prerelease versions. See also #match?
60 61 62 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 60 def matches_spec?(spec) @dependency.matches_spec? spec end |
#name ⇒ Object
The name of the gem this dependency request is requesting.
67 68 69 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 67 def name @dependency.name end |
#pretty_print(q) ⇒ Object
:nodoc:
98 99 100 101 102 103 104 105 106 107 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 98 def pretty_print(q) # :nodoc: q.group 2, '[Dependency request ', ']' do q.breakable q.text @dependency.to_s q.breakable q.text ' requested by ' q.pp @requester end end |
#request_context ⇒ Object
Return a String indicating who caused this request to be added (only valid for implicit requests)
94 95 96 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 94 def request_context @requester ? @requester.request : "(unknown)" end |
#requirement ⇒ Object
The version requirement for this dependency request
112 113 114 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 112 def requirement @dependency.requirement end |
#to_s ⇒ Object
:nodoc:
116 117 118 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 116 def to_s # :nodoc: @dependency.to_s end |
#type ⇒ Object
71 72 73 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 71 def type @dependency.type end |