Class: Gem::Resolver::DependencyRequest

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#dependencyObject (readonly)

The wrapped Gem::Dependency



10
11
12
# File 'lib/rubygems/resolver/dependency_request.rb', line 10

def dependency
  @dependency
end

#requesterObject (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?

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


59
60
61
# File 'lib/rubygems/resolver/dependency_request.rb', line 59

def matches_spec?(spec)
  @dependency.matches_spec? spec
end

#nameObject

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_contextObject

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

#requirementObject

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_sObject

:nodoc:



115
116
117
# File 'lib/rubygems/resolver/dependency_request.rb', line 115

def to_s # :nodoc:
  @dependency.to_s
end

#typeObject



70
71
72
# File 'lib/rubygems/resolver/dependency_request.rb', line 70

def type
  @dependency.type
end