Class: Gem::Platform
- Inherits:
-
Object
- Object
- Gem::Platform
- Defined in:
- lib/bundler/rubygems_ext.rb
Constant Summary collapse
- JAVA =
:nodoc:
Gem::Platform.new("java")
- MSWIN =
:nodoc:
Gem::Platform.new("mswin32")
- MSWIN64 =
:nodoc:
Gem::Platform.new("mswin64")
- MINGW =
:nodoc:
Gem::Platform.new("x86-mingw32")
- X64_MINGW_LEGACY =
:nodoc:
Gem::Platform.new("x64-mingw32")
- X64_MINGW =
:nodoc:
Gem::Platform.new("x64-mingw-ucrt")
- UNIVERSAL_MINGW =
:nodoc:
Gem::Platform.new("universal-mingw")
- WINDOWS =
:nodoc:
[MSWIN, MSWIN64, UNIVERSAL_MINGW].freeze
- X64_LINUX =
:nodoc:
Gem::Platform.new("x86_64-linux")
- X64_LINUX_MUSL =
:nodoc:
Gem::Platform.new("x86_64-linux-musl")
Class Method Summary collapse
-
.generic(platform) ⇒ Object
Returns the generic platform for the given platform.
-
.platform_specificity_match(spec_platform, user_platform) ⇒ Object
Returns the platform specificity match for the given spec platform and user platform.
-
.sort_and_filter_best_platform_match(matching, platform) ⇒ Object
Sorts and filters the best platform match for the given matching specs and platform.
-
.sort_best_platform_match(matching, platform) ⇒ Object
Sorts the best platform match for the given matching specs and platform.
Class Method Details
.generic(platform) ⇒ Object
Returns the generic platform for the given platform.
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/bundler/rubygems_ext.rb', line 78 def generic(platform) return Gem::Platform::RUBY if platform.nil? || platform == Gem::Platform::RUBY GENERIC_CACHE[platform] ||= begin found = GENERICS.find do |match| platform === match end found || Gem::Platform::RUBY end end |
.platform_specificity_match(spec_platform, user_platform) ⇒ Object
Returns the platform specificity match for the given spec platform and user platform.
92 93 94 95 96 97 98 99 |
# File 'lib/bundler/rubygems_ext.rb', line 92 def platform_specificity_match(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 + version_match(spec_platform, user_platform) * 100 end |
.sort_and_filter_best_platform_match(matching, platform) ⇒ Object
Sorts and filters the best platform match for the given matching specs and platform.
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/bundler/rubygems_ext.rb', line 104 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 |
.sort_best_platform_match(matching, platform) ⇒ Object
Sorts the best platform match for the given matching specs and platform.
119 120 121 122 123 124 125 126 |
# File 'lib/bundler/rubygems_ext.rb', line 119 def sort_best_platform_match(matching, platform) matching.sort_by.with_index do |spec, i| [ platform_specificity_match(spec.platform, platform), i, # for stable sort ] end end |