123456789_123456789_123456789_123456789_123456789_

Class: Bundler::Resolver::Candidate

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Comparable
Inherits: Object
Defined in: lib/bundler/resolver/candidate.rb

Overview

This class is a ::Bundler::PubGrub compatible “Version” class that takes ::Bundler resolution complexities into account.

Each Candidate has a underlying Gem::Version plus a set of platforms. For example, 1.1.0-x86_64-linux is a different resolution candidate from 1.1.0 (generic). This is because different platform variants of the same gem version can bring different dependencies, so they need to be considered separately.

Some candidates may also keep some information explicitly about the package they refer to. These candidates are referred to as “canonical” and are used when materializing resolution results back into RubyGems specifications that can be installed, written to lock files, and so on.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(version, group: nil, priority: -1)) ⇒ Candidate

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 27

def initialize(version, group: nil, priority: -1)
  @spec_group = group || SpecGroup.new([])
  @version = Gem::Version.new(version)
  @priority = priority
end

Instance Attribute Details

#prerelease?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 43

def prerelease?
  @version.prerelease?
end

#version (readonly)

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 25

attr_reader :version

Instance Method Details

#<=>(other)

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 55

def <=>(other)
  return unless other.is_a?(self.class)

  sort_obj <=> other.sort_obj
end

#==(other)

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 61

def ==(other)
  return unless other.is_a?(self.class)

  sort_obj == other.sort_obj
end

#dependencies

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 33

def dependencies
  @spec_group.dependencies
end

#eql?(other) ⇒ Boolean

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 67

def eql?(other)
  return unless other.is_a?(self.class)

  sort_obj.eql?(other.sort_obj)
end

#hash

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 73

def hash
  sort_obj.hash
end

#segments

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 47

def segments
  @version.segments
end

#sort_obj

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 51

def sort_obj
  [@version, @priority]
end

#to_s

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 77

def to_s
  @version.to_s
end

#to_specs(package)

[ GitHub ]

  
# File 'lib/bundler/resolver/candidate.rb', line 37

def to_specs(package)
  return [] if package.meta?

  @spec_group.to_specs(package.force_ruby_platform?)
end