Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Resolver#build_spec_for_cache
build_spec_for_cache(name)
lib/rubygems/resolver.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/resolver.rb, line 469
def build_spec_for_cache(name)
# Rank sources by the order they were first supplied so that, when multiple
# sources offer the same version and platform, the earlier source wins.
source_rank = {}
@all_specs[name].each do |s|
source_rank[s.source] ||= source_rank.size
end
@all_specs[name].group_by(&:version).transform_values do |candidates|
next candidates.first if candidates.length == 1
# Prefer already-installed specs to avoid unnecessary downloads
installed = candidates.select {|s| s.is_a?(Gem::Resolver::InstalledSpecification) }
next installed.first if installed.length == 1
candidates = installed if installed.any?
# Among remaining candidates, prefer a content-addressed candidate
# built for the running Ruby, then the most specific platform, then the
# earlier-supplied source. The Ruby ABI ranks before platform
# specificity so that gem install and bundle install choose the same
# artifact: Bundler prefers compatible content-addressed candidates
# before sorting by platform.
candidates.min_by do |s|
[Gem::ContentAddress.ruby_abi_specificity_match(s),
Gem::Platform.platform_specificity_match(s.platform, Gem::Platform.local),
source_rank[s.source]]
end
end
end
No documentation available