PATH:
opt
/
alt
/
ruby34
/
share
/
gems
/
gems
/
bundler-2.6.9
/
lib
/
bundler
# frozen_string_literal: true module Bundler module GemHelpers GENERIC_CACHE = { Gem::Platform::RUBY => Gem::Platform::RUBY } # rubocop:disable Style/MutableConstant GENERICS = [ Gem::Platform::JAVA, *Gem::Platform::WINDOWS, ].freeze def generic(p) GENERIC_CACHE[p] ||= begin found = GENERICS.find do |match| p === match end found || Gem::Platform::RUBY end end module_function :generic def generic_local_platform generic(local_platform) end module_function :generic_local_platform def local_platform Bundler.local_platform end module_function :local_platform def generic_local_platform_is_ruby? generic_local_platform == Gem::Platform::RUBY end module_function :generic_local_platform_is_ruby? def platform_specificity_match(spec_platform, user_platform) spec_platform = Gem::Platform.new(spec_platform) PlatformMatch.specificity_score(spec_platform, user_platform) end module_function :platform_specificity_match def select_all_platform_match(specs, platform, force_ruby: false, prefer_locked: 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 if prefer_locked locked_originally = matching.select {|spec| spec.is_a?(LazySpecification) } return locked_originally if locked_originally.any? end matching end module_function :select_all_platform_match def select_best_platform_match(specs, platform, force_ruby: false, prefer_locked: false) matching = select_all_platform_match(specs, platform, force_ruby: force_ruby, prefer_locked: prefer_locked) sort_and_filter_best_platform_match(matching, platform) end module_function :select_best_platform_match def select_best_local_platform_match(specs, force_ruby: false) matching = select_all_platform_match(specs, local_platform, force_ruby: force_ruby).filter_map(&:materialized_for_installation) sort_best_platform_match(matching, local_platform) end module_function :select_best_local_platform_match def sort_and_filter_best_platform_match(matching, platform) return matching if matching.one? exact = matching.select {|spec| spec.platform == platform } return exact if exact.any? sorted_matching = sort_best_platform_match(matching, platform) exemplary_spec = sorted_matching.first sorted_matching.take_while {|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) } end module_function :sort_and_filter_best_platform_match def sort_best_platform_match(matching, platform) matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) } end module_function :sort_best_platform_match class PlatformMatch def self.specificity_score(spec_platform, user_platform) return -1 if spec_platform == user_platform return 1_000_000 if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY os_match(spec_platform, user_platform) + cpu_match(spec_platform, user_platform) * 10 + platform_version_match(spec_platform, user_platform) * 100 end def self.os_match(spec_platform, user_platform) if spec_platform.os == user_platform.os 0 else 1 end end def self.cpu_match(spec_platform, user_platform) if spec_platform.cpu == user_platform.cpu 0 elsif spec_platform.cpu == "arm" && user_platform.cpu.to_s.start_with?("arm") 0 elsif spec_platform.cpu.nil? || spec_platform.cpu == "universal" 1 else 2 end end def self.platform_version_match(spec_platform, user_platform) if spec_platform.version == user_platform.version 0 elsif spec_platform.version.nil? 1 else 2 end end end def same_specificity(platform, spec, exemplary_spec) platform_specificity_match(spec.platform, platform) == platform_specificity_match(exemplary_spec.platform, platform) end module_function :same_specificity def same_deps(spec, exemplary_spec) same_runtime_deps = spec.dependencies.sort == exemplary_spec.dependencies.sort same_metadata_deps = spec.required_ruby_version == exemplary_spec.required_ruby_version && spec.required_rubygems_version == exemplary_spec.required_rubygems_version same_runtime_deps && same_metadata_deps end module_function :same_deps end end
[+]
..
[-] vendored_fileutils.rb
[edit]
[+]
settings
[-] similarity_detector.rb
[edit]
[-] mirror.rb
[edit]
[-] vendored_net_http.rb
[edit]
[-] match_metadata.rb
[edit]
[+]
resolver
[+]
plugin
[+]
fetcher
[-] lockfile_parser.rb
[edit]
[-] definition.rb
[edit]
[-] rubygems_integration.rb
[edit]
[-] source.rb
[edit]
[-] feature_flag.rb
[edit]
[-] index.rb
[edit]
[-] vlad.rb
[edit]
[-] compact_index_client.rb
[edit]
[+]
source
[-] checksum.rb
[edit]
[-] spec_set.rb
[edit]
[-] env.rb
[edit]
[-] process_lock.rb
[edit]
[-] version.rb
[edit]
[-] vendored_timeout.rb
[edit]
[-] fetcher.rb
[edit]
[-] digest.rb
[edit]
[+]
ui
[-] ruby_version.rb
[edit]
[-] ruby_dsl.rb
[edit]
[-] rubygems_ext.rb
[edit]
[+]
man
[+]
installer
[-] lockfile_generator.rb
[edit]
[-] force_platform.rb
[edit]
[-] remote_specification.rb
[edit]
[-] gem_tasks.rb
[edit]
[+]
templates
[+]
cli
[-] runtime.rb
[edit]
[-] installer.rb
[edit]
[+]
vendor
[-] shared_helpers.rb
[edit]
[+]
compact_index_client
[-] vendored_uri.rb
[edit]
[-] worker.rb
[edit]
[-] graph.rb
[edit]
[-] gem_helper.rb
[edit]
[-] vendored_persistent.rb
[edit]
[-] source_list.rb
[edit]
[-] settings.rb
[edit]
[-] materialization.rb
[edit]
[-] setup.rb
[edit]
[-] environment_preserver.rb
[edit]
[-] match_remote_metadata.rb
[edit]
[-] match_platform.rb
[edit]
[-] yaml_serializer.rb
[edit]
[-] constants.rb
[edit]
[-] vendored_securerandom.rb
[edit]
[-] plugin.rb
[edit]
[-] retry.rb
[edit]
[-] injector.rb
[edit]
[-] endpoint_specification.rb
[edit]
[-] self_manager.rb
[edit]
[-] vendored_thor.rb
[edit]
[-] errors.rb
[edit]
[-] stub_specification.rb
[edit]
[-] ui.rb
[edit]
[-] dependency.rb
[edit]
[-] capistrano.rb
[edit]
[-] uri_credentials_filter.rb
[edit]
[-] uri_normalizer.rb
[edit]
[-] ci_detector.rb
[edit]
[-] deprecate.rb
[edit]
[-] vendored_pub_grub.rb
[edit]
[-] gem_helpers.rb
[edit]
[-] dsl.rb
[edit]
[-] deployment.rb
[edit]
[-] vendored_tsort.rb
[edit]
[-] current_ruby.rb
[edit]
[-] gem_version_promoter.rb
[edit]
[-] safe_marshal.rb
[edit]
[-] cli.rb
[edit]
[-] resolver.rb
[edit]
[-] lazy_specification.rb
[edit]
[-] build_metadata.rb
[edit]
[-] inline.rb
[edit]
[-] rubygems_gem_installer.rb
[edit]
[-] friendly_errors.rb
[edit]
[-] source_map.rb
[edit]