[rubygems/rubygems] Refactor selecting specs from a SpecSet
https://github.com/rubygems/rubygems/commit/bcbbff5149
This commit is contained in:
parent
dd05191bc3
commit
e6c7a309d0
@ -46,19 +46,21 @@ module Bundler
|
|||||||
end
|
end
|
||||||
module_function :platform_specificity_match
|
module_function :platform_specificity_match
|
||||||
|
|
||||||
def select_best_platform_match(specs, platform)
|
def select_best_platform_match(specs, platform, force_ruby: false)
|
||||||
matching = specs.select {|spec| spec.match_platform(platform) }
|
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)
|
sort_best_platform_match(matching, platform)
|
||||||
end
|
end
|
||||||
module_function :select_best_platform_match
|
module_function :select_best_platform_match
|
||||||
|
|
||||||
def force_ruby_platform(specs)
|
def select_best_local_platform_match(specs, force_ruby: false)
|
||||||
matching = specs.select {|spec| spec.match_platform(Gem::Platform::RUBY) && spec.force_ruby_platform! }
|
select_best_platform_match(specs, local_platform, force_ruby: force_ruby).map(&:materialize_for_installation).compact
|
||||||
|
|
||||||
sort_best_platform_match(matching, Gem::Platform::RUBY)
|
|
||||||
end
|
end
|
||||||
module_function :force_ruby_platform
|
module_function :select_best_local_platform_match
|
||||||
|
|
||||||
def sort_best_platform_match(matching, platform)
|
def sort_best_platform_match(matching, platform)
|
||||||
exact = matching.select {|spec| spec.platform == platform }
|
exact = matching.select {|spec| spec.platform == platform }
|
||||||
|
@ -277,13 +277,11 @@ module Bundler
|
|||||||
specs_for_name = lookup[dep.name]
|
specs_for_name = lookup[dep.name]
|
||||||
return [] unless specs_for_name
|
return [] unless specs_for_name
|
||||||
|
|
||||||
matching_specs = if dep.force_ruby_platform
|
if platform
|
||||||
GemHelpers.force_ruby_platform(specs_for_name)
|
GemHelpers.select_best_platform_match(specs_for_name, platform, force_ruby: dep.force_ruby_platform)
|
||||||
else
|
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
|
end
|
||||||
matching_specs.map!(&:materialize_for_installation).compact! if platform.nil?
|
|
||||||
matching_specs
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def tsort_each_child(s)
|
def tsort_each_child(s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user