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.
21 22 23 24 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 21 def initialize(dependency, requester) @dependency = dependency @requester = requester end |
Instance Attribute Details
#dependency ⇒ Object (readonly)
The wrapped Gem::Dependency
10 11 12 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 10 def dependency @dependency end |
#requester ⇒ Object (readonly)
The request for this dependency.
15 16 17 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 15 def requester @requester end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 26 def ==(other) # :nodoc: case other when Gem::Dependency @dependency == other when Gem::Resolver::DependencyRequest @dependency == other.dependency else false end end |
#development? ⇒ Boolean
Is this dependency a development dependency?
40 41 42 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 40 def development? @dependency.type == :development end |
#explicit? ⇒ Boolean
Indicate that the request is for a gem explicitly requested by the user
77 78 79 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 77 def explicit? @requester.nil? end |
#implicit? ⇒ Boolean
Indicate that the request is for a gem requested as a dependency of another gem
85 86 87 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 85 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.
50 51 52 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 50 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?
59 60 61 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 59 def matches_spec?(spec) @dependency.matches_spec? spec end |
#name ⇒ Object
The name of the gem this dependency request is requesting.
66 67 68 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 66 def name @dependency.name end |
#pretty_print(q) ⇒ Object
:nodoc:
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 97 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)
93 94 95 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 93 def request_context @requester ? @requester.request : "(unknown)" end |
#requirement ⇒ Object
The version requirement for this dependency request
111 112 113 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 111 def requirement @dependency.requirement end |
#to_s ⇒ Object
:nodoc:
115 116 117 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 115 def to_s # :nodoc: @dependency.to_s end |
#type ⇒ Object
70 71 72 |
# File 'lib/rubygems/resolver/dependency_request.rb', line 70 def type @dependency.type end |