class Gem::Resolver::Strategy
Custom PubGrub strategy with caching for version selection. Modeled after Bundler’s strategy to avoid redundant versions_for calls during the solver’s package selection loop.
Public Class Methods
# File lib/rubygems/resolver/strategy.rb, line 8 def initialize(source) @source = source @package_priority_cache = Hash.new {|h, pkg| h[pkg] = {} } @version_indexes = Hash.new do |h, k| if Gem::PubGrub::Package.root?(k) h[k] = { Gem::PubGrub::Package.root_version => 0 } else h[k] = @source.all_versions_for(k).each.with_index.to_h end end end
Public Instance Methods
# File lib/rubygems/resolver/strategy.rb, line 21 def next_package_and_version(unsatisfied) package, range = next_term_to_try_from(unsatisfied) [package, most_preferred_version_of(package, range)] end