Class: Bundler::Resolver::Candidate
- Inherits:
-
Object
- Object
- Bundler::Resolver::Candidate
- Includes:
- Comparable
- Defined in:
- lib/bundler/resolver/candidate.rb
Overview
This class is a PubGrub compatible “Version” class that takes Bundler resolution complexities into account.
Each Resolver::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.
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #dependencies ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(version, group: nil, priority: -1)) ⇒ Candidate
constructor
A new instance of Candidate.
- #prerelease? ⇒ Boolean
- #segments ⇒ Object
- #to_s ⇒ Object
- #to_specs(package, most_specific_locked_platform) ⇒ Object
Constructor Details
#initialize(version, group: nil, priority: -1)) ⇒ Candidate
Returns a new instance of Candidate.
27 28 29 30 31 |
# 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
#version ⇒ Object (readonly)
Returns the value of attribute version.
25 26 27 |
# File 'lib/bundler/resolver/candidate.rb', line 25 def version @version end |
Instance Method Details
#<=>(other) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/bundler/resolver/candidate.rb', line 51 def <=>(other) return unless other.is_a?(self.class) version_comparison = version <=> other.version return version_comparison unless version_comparison.zero? priority <=> other.priority end |
#==(other) ⇒ Object
60 61 62 63 64 |
# File 'lib/bundler/resolver/candidate.rb', line 60 def ==(other) return unless other.is_a?(self.class) version == other.version && priority == other.priority end |
#dependencies ⇒ Object
33 34 35 |
# File 'lib/bundler/resolver/candidate.rb', line 33 def dependencies @spec_group.dependencies end |
#eql?(other) ⇒ Boolean
66 67 68 69 70 |
# File 'lib/bundler/resolver/candidate.rb', line 66 def eql?(other) return unless other.is_a?(self.class) version.eql?(other.version) && priority.eql?(other.priority) end |
#hash ⇒ Object
72 73 74 |
# File 'lib/bundler/resolver/candidate.rb', line 72 def hash [@version, @priority].hash end |
#prerelease? ⇒ Boolean
43 44 45 |
# File 'lib/bundler/resolver/candidate.rb', line 43 def prerelease? @version.prerelease? end |
#segments ⇒ Object
47 48 49 |
# File 'lib/bundler/resolver/candidate.rb', line 47 def segments @version.segments end |
#to_s ⇒ Object
76 77 78 |
# File 'lib/bundler/resolver/candidate.rb', line 76 def to_s @version.to_s end |
#to_specs(package, most_specific_locked_platform) ⇒ Object
37 38 39 40 41 |
# File 'lib/bundler/resolver/candidate.rb', line 37 def to_specs(package, most_specific_locked_platform) return [] if package. @spec_group.to_specs(package.force_ruby_platform?, most_specific_locked_platform) end |