[rubygems/rubygems] Refactor selecting specs from a SpecSet

https://github.com/rubygems/rubygems/commit/bcbbff5149
This commit is contained in:
David Rodríguez 2024-07-04 15:48:08 +02:00 коммит произвёл git
Родитель dd05191bc3
Коммит e6c7a309d0
2 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -46,19 +46,21 @@ module Bundler
end
module_function :platform_specificity_match
def select_best_platform_match(specs, platform)
matching = specs.select {|spec| spec.match_platform(platform) }
def select_best_platform_match(specs, platform, force_ruby: false)
matching = if force_ruby
specs.select {|spec| spec.match_platform(Gem::Platform::RUBY) && spec.force_ruby_platform! }
else
specs.select {|spec| spec.match_platform(platform) }
end
sort_best_platform_match(matching, platform)
end
module_function :select_best_platform_match
def force_ruby_platform(specs)
matching = specs.select {|spec| spec.match_platform(Gem::Platform::RUBY) && spec.force_ruby_platform! }
sort_best_platform_match(matching, Gem::Platform::RUBY)
def select_best_local_platform_match(specs, force_ruby: false)
select_best_platform_match(specs, local_platform, force_ruby: force_ruby).map(&:materialize_for_installation).compact
end
module_function :force_ruby_platform
module_function :select_best_local_platform_match
def sort_best_platform_match(matching, platform)
exact = matching.select {|spec| spec.platform == platform }

Просмотреть файл

@ -277,13 +277,11 @@ module Bundler
specs_for_name = lookup[dep.name]
return [] unless specs_for_name
matching_specs = if dep.force_ruby_platform
GemHelpers.force_ruby_platform(specs_for_name)
if platform
GemHelpers.select_best_platform_match(specs_for_name, platform, force_ruby: dep.force_ruby_platform)
else
GemHelpers.select_best_platform_match(specs_for_name, platform || Bundler.local_platform)
GemHelpers.select_best_local_platform_match(specs_for_name, force_ruby: dep.force_ruby_platform)
end
matching_specs.map!(&:materialize_for_installation).compact! if platform.nil?
matching_specs
end
def tsort_each_child(s)