Class: Bundler::PubGrub::VersionSolver
- Inherits:
-
Object
- Object
- Bundler::PubGrub::VersionSolver
- Defined in:
- lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#solution ⇒ Object
readonly
Returns the value of attribute solution.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source:, root: Package.root, logger: Bundler::PubGrub.logger) ⇒ VersionSolver
constructor
A new instance of VersionSolver.
- #solve ⇒ Object (also: #result)
- #solved? ⇒ Boolean
-
#work ⇒ Object
Returns true if there is more work to be done, false otherwise.
Constructor Details
#initialize(source:, root: Package.root, logger: Bundler::PubGrub.logger) ⇒ VersionSolver
Returns a new instance of VersionSolver.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb', line 12 def initialize(source:, root: Package.root, logger: Bundler::PubGrub.logger) @logger = logger @source = source # { package => [incompatibility, ...]} @incompatibilities = Hash.new do |h, k| h[k] = [] end @seen_incompatibilities = {} @solution = PartialSolution.new add_incompatibility Incompatibility.new([ Term.new(VersionConstraint.any(root), false) ], cause: :root) propagate(root) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb', line 8 def logger @logger end |
#solution ⇒ Object (readonly)
Returns the value of attribute solution.
10 11 12 |
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb', line 10 def solution @solution end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
9 10 11 |
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb', line 9 def source @source end |
Instance Method Details
#solve ⇒ Object Also known as: result
57 58 59 60 61 |
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb', line 57 def solve work until solved? solution.decisions end |
#solved? ⇒ Boolean
33 34 35 |
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb', line 33 def solved? solution.unsatisfied.empty? end |
#work ⇒ Object
Returns true if there is more work to be done, false otherwise
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb', line 38 def work return false if solved? next_package = choose_package_version propagate(next_package) if solved? logger.info { "Solution found after #{solution.attempted_solutions} attempts:" } solution.decisions.each do |package, version| next if Package.root?(package) logger.info { "* #{package} #{version}" } end false else true end end |