123456789_123456789_123456789_123456789_123456789_

Class: Gem::Resolver::DependencyRequest

Relationships & Source Files
Inherits: Object
Defined in: lib/rubygems/resolver/dependency_request.rb

Overview

Used Internally. Wraps a ::Gem::Dependency object to also track which spec contained the ::Gem::Dependency.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(dependency, requester) ⇒ DependencyRequest

Creates a new DependencyRequest for #dependency from #requester. +requester may be nil if the request came from a user.

[ GitHub ]

  
# File 'lib/rubygems/resolver/dependency_request.rb', line 21

def initialize(dependency, requester)
  @dependency = dependency
  @requester  = requester
end

Instance Attribute Details

#dependency (readonly)

The wrapped ::Gem::Dependency

[ GitHub ]

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

attr_reader :dependency

#development?Boolean (readonly)

Is this dependency a development dependency?

[ GitHub ]

  
# File 'lib/rubygems/resolver/dependency_request.rb', line 40

def development?
  @dependency.type == :development
end

#explicit?Boolean (readonly)

Indicate that the request is for a gem explicitly requested by the user

[ GitHub ]

  
# File 'lib/rubygems/resolver/dependency_request.rb', line 77

def explicit?
  @requester.nil?
end

#implicit?Boolean (readonly)

Indicate that the request is for a gem requested as a dependency of another gem

[ GitHub ]

  
# File 'lib/rubygems/resolver/dependency_request.rb', line 85

def implicit?
  !explicit?
end

#requester (readonly)

The request for this dependency.

[ GitHub ]

  
# File 'lib/rubygems/resolver/dependency_request.rb', line 15

attr_reader :requester

Instance Method Details

#==(other)

This method is for internal use only.
[ GitHub ]

  
# 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

#match?(spec, allow_prerelease = false) ⇒ Boolean

Does this dependency request match spec?

NOTE: #match? only matches prerelease versions when #dependency is a prerelease dependency.

[ GitHub ]

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

[ GitHub ]

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

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

#name

The name of the gem this dependency request is requesting.

[ GitHub ]

  
# File 'lib/rubygems/resolver/dependency_request.rb', line 66

def name
  @dependency.name
end

#pretty_print(q)

This method is for internal use only.
[ GitHub ]

  
# 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

Return a String indicating who caused this request to be added (only valid for implicit requests)

[ GitHub ]

  
# File 'lib/rubygems/resolver/dependency_request.rb', line 93

def request_context
  @requester ? @requester.request : "(unknown)"
end

#requirement

The version requirement for this dependency request

[ GitHub ]

  
# File 'lib/rubygems/resolver/dependency_request.rb', line 111

def requirement
  @dependency.requirement
end

#to_s

This method is for internal use only.
[ GitHub ]

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

def to_s # :nodoc:
  @dependency.to_s
end

#type

[ GitHub ]

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

def type
  @dependency.type
end