Class: Bundler::GemHelpers::PlatformMatch
- Inherits:
-
Struct
- Object
- Struct
- Bundler::GemHelpers::PlatformMatch
- Defined in:
- lib/bundler/gem_helpers.rb,
lib/bundler/gem_helpers.rb
Constant Summary collapse
- EXACT_MATCH =
new(-1, -1, -1).freeze
- WORST_MATCH =
new(1_000_000, 1_000_000, 1_000_000).freeze
Instance Attribute Summary collapse
-
#cpu_match ⇒ Object
Returns the value of attribute cpu_match.
-
#os_match ⇒ Object
Returns the value of attribute os_match.
-
#platform_version_match ⇒ Object
Returns the value of attribute platform_version_match.
Class Method Summary collapse
- .cpu_match(spec_platform, user_platform) ⇒ Object
- .os_match(spec_platform, user_platform) ⇒ Object
- .platform_version_match(spec_platform, user_platform) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#cpu_match ⇒ Object
Returns the value of attribute cpu_match
55 56 57 |
# File 'lib/bundler/gem_helpers.rb', line 55 def cpu_match @cpu_match end |
#os_match ⇒ Object
Returns the value of attribute os_match
55 56 57 |
# File 'lib/bundler/gem_helpers.rb', line 55 def os_match @os_match end |
#platform_version_match ⇒ Object
Returns the value of attribute platform_version_match
55 56 57 |
# File 'lib/bundler/gem_helpers.rb', line 55 def platform_version_match @platform_version_match end |
Class Method Details
.cpu_match(spec_platform, user_platform) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/bundler/gem_helpers.rb', line 81 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 |
.os_match(spec_platform, user_platform) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/bundler/gem_helpers.rb', line 73 def self.os_match(spec_platform, user_platform) if spec_platform.os == user_platform.os 0 else 1 end end |
.platform_version_match(spec_platform, user_platform) ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/bundler/gem_helpers.rb', line 93 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 |
Instance Method Details
#<=>(other) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bundler/gem_helpers.rb', line 57 def <=>(other) return nil unless other.is_a?(PlatformMatch) m = os_match <=> other.os_match return m unless m.zero? m = cpu_match <=> other.cpu_match return m unless m.zero? m = platform_version_match <=> other.platform_version_match m end |