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.



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

#dependencyObject (readonly)

The wrapped Gem::Dependency



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

def dependency
  @dependency
end

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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


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

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

#nameObject

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_contextObject

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

#requirementObject

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_sObject

:nodoc:



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

def to_s # :nodoc:
  @dependency.to_s
end

#typeObject



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

def type
  @dependency.type
end