summaryrefslogtreecommitdiff
path: root/lib/bundler/spec_set.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2023-12-22 18:27:39 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2024-01-11 13:51:52 +0900
commit51d2a8e983ddc25e2333706f0fc6f1c01e12fa06 (patch)
treee0fd8a4f425cbbb4f30d611a952bbd9856ff040e /lib/bundler/spec_set.rb
parentab1936faf9197e0466a581de19f4023fdfe10204 (diff)
[rubygems/rubygems] Extract a couple of helper methods
https://github.com/rubygems/rubygems/commit/880a4eae7f
Diffstat (limited to 'lib/bundler/spec_set.rb')
-rw-r--r--lib/bundler/spec_set.rb49
1 files changed, 29 insertions, 20 deletions
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index 09bbea27c5..d241842c37 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -55,29 +55,11 @@ module Bundler
def add_extra_platforms!(platforms)
return platforms.concat([Gem::Platform::RUBY]).uniq if @specs.empty?
- new_platforms = @specs.flat_map {|spec| spec.source.specs.search([spec.name, spec.version]).map(&:platform) }.uniq.select do |platform|
+ new_platforms = all_platforms.select do |platform|
next if platforms.include?(platform)
next unless GemHelpers.generic(platform) == Gem::Platform::RUBY
- new_specs = []
-
- valid_platform = lookup.all? do |_, specs|
- spec = specs.first
- matching_specs = spec.source.specs.search([spec.name, spec.version])
- platform_spec = GemHelpers.select_best_platform_match(matching_specs, platform).find do |s|
- s.matches_current_metadata? && valid_dependencies?(s)
- end
-
- if platform_spec
- new_specs << LazySpecification.from_spec(platform_spec)
- true
- else
- false
- end
- end
- next unless valid_platform
-
- @specs.concat(new_specs.uniq)
+ complete_platform(platform)
end
return platforms if new_platforms.empty?
@@ -216,6 +198,33 @@ module Bundler
@lookup = nil
end
+ def complete_platform(platform)
+ new_specs = []
+
+ valid_platform = lookup.all? do |_, specs|
+ spec = specs.first
+ matching_specs = spec.source.specs.search([spec.name, spec.version])
+ platform_spec = GemHelpers.select_best_platform_match(matching_specs, platform).find do |s|
+ s.matches_current_metadata? && valid_dependencies?(s)
+ end
+
+ if platform_spec
+ new_specs << LazySpecification.from_spec(platform_spec)
+ true
+ else
+ false
+ end
+ end
+
+ @specs.concat(new_specs.uniq) if valid_platform
+
+ valid_platform
+ end
+
+ def all_platforms
+ @specs.flat_map {|spec| spec.source.specs.search([spec.name, spec.version]).map(&:platform) }.uniq
+ end
+
def valid_dependencies?(s)
validate_deps(s) == :valid
end