Class: Gem::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/rubygems_ext.rb

Constant Summary collapse

JAVA =
Gem::Platform.new("java")
MSWIN =
Gem::Platform.new("mswin32")
MSWIN64 =
Gem::Platform.new("mswin64")
MINGW =
Gem::Platform.new("x86-mingw32")
X64_MINGW =
[Gem::Platform.new("x64-mingw32"),
Gem::Platform.new("x64-mingw-ucrt")].freeze
WINDOWS =
[MSWIN, MSWIN64, MINGW, X64_MINGW].flatten.freeze
X64_LINUX =
Gem::Platform.new("x86_64-linux")
X64_LINUX_MUSL =
Gem::Platform.new("x86_64-linux-musl")

Instance Method Summary collapse

Instance Method Details

#===(other) ⇒ Object



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/bundler/rubygems_ext.rb', line 247

def ===(other)
  return nil unless Gem::Platform === other

  # universal-mingw32 matches x64-mingw-ucrt
  return true if (@cpu == "universal" || other.cpu == "universal") &&
                 @os.start_with?("mingw") && other.os.start_with?("mingw")

  # cpu
  ([nil,"universal"].include?(@cpu) || [nil, "universal"].include?(other.cpu) || @cpu == other.cpu ||
  (@cpu == "arm" && other.cpu.start_with?("arm"))) &&

    # os
    @os == other.os &&

    # version
    (
      (@os != "linux" && (@version.nil? || other.version.nil?)) ||
      (@os == "linux" && (other.version == "gnu#{@version}" || other.version == "musl#{@version}" || @version == "gnu#{other.version}")) ||
      @version == other.version
    )
end