class Bundler::GemHelpers::PlatformMatch

Constants

EXACT_MATCH
WORST_MATCH

Public Class Methods

cpu_match(spec_platform, user_platform) click to toggle source
# File lib/bundler/gem_helpers.rb, line 78
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) click to toggle source
# File lib/bundler/gem_helpers.rb, line 70
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) click to toggle source
# File lib/bundler/gem_helpers.rb, line 90
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

Public Instance Methods

<=>(other) click to toggle source
# File lib/bundler/gem_helpers.rb, line 54
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