Class: OS::Mac::Version Private

Inherits:
Version show all
Extended by:
T::Sig
Defined in:
os/mac/version.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

A macOS version.

Constant Summary collapse

SYMBOLS =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

{
  monterey:    "12",
  big_sur:     "11",
  catalina:    "10.15",
  mojave:      "10.14",
  high_sierra: "10.13",
  sierra:      "10.12",
  el_capitan:  "10.11",
  yosemite:    "10.10",
}.freeze

Constants inherited from Version

Version::NULL, Version::NULL_TOKEN

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Version

create, detect, #detected_from_url?, #empty?, formula_optionally_versioned_regex, #hash, #head?, #major, #major_minor, #major_minor_patch, #minor, #null?, parse, #patch, #to_f, #to_i, #to_s

Constructor Details

#initialize(value) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Raises:



46
47
48
49
50
51
52
53
54
# File 'os/mac/version.rb', line 46

def initialize(value)
  version ||= value

  raise MacOSVersionError, version unless /\A1\d+(?:\.\d+){0,2}\Z/.match?(version)

  super(version)

  @comparison_cache = {}
end

Class Method Details

.from_symbol(version) ⇒ T.attached_class

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:

  • (T.attached_class)


40
41
42
43
# File 'os/mac/version.rb', line 40

def self.from_symbol(version)
  str = SYMBOLS.fetch(version) { raise MacOSVersionError, version }
  new(str)
end

Instance Method Details

#<=>(other) ⇒ Integer?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • other (T.untyped)

Returns:

  • (Integer, nil)


57
58
59
60
61
62
63
64
65
66
# File 'os/mac/version.rb', line 57

def <=>(other)
  @comparison_cache.fetch(other) do
    if SYMBOLS.key?(other) && to_sym == other
      0
    else
      v = SYMBOLS.fetch(other) { other.to_s }
      @comparison_cache[other] = super(::Version.new(v))
    end
  end
end

#outdated_release?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


89
90
91
# File 'os/mac/version.rb', line 89

def outdated_release?
  self < MACOS_OLDEST_SUPPORTED
end

#prerelease?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


94
95
96
# File 'os/mac/version.rb', line 94

def prerelease?
  self >= MACOS_NEWEST_UNSUPPORTED
end

#pretty_nameString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



84
85
86
# File 'os/mac/version.rb', line 84

def pretty_name
  @pretty_name ||= to_sym.to_s.split("_").map(&:capitalize).join(" ").freeze
end

#requires_nehalem_cpu?Boolean Also known as: requires_sse4?, requires_sse41?, requires_sse42?, requires_popcnt?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

For OS::Mac::Version compatibility.

Returns:

  • (Boolean)


100
101
102
103
104
105
106
# File 'os/mac/version.rb', line 100

def requires_nehalem_cpu?
  unless Hardware::CPU.intel?
    raise "Unexpected architecture: #{Hardware::CPU.arch}. This only works with Intel architecture."
  end

  Hardware.oldest_cpu(self) == :nehalem
end

#strip_patchT.self_type

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (T.self_type)


69
70
71
72
73
74
75
76
# File 'os/mac/version.rb', line 69

def strip_patch
  # Big Sur is 11.x but Catalina is 10.15.x.
  if major >= 11
    self.class.new(major.to_s)
  else
    major_minor
  end
end

#to_symSymbol

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



79
80
81
# File 'os/mac/version.rb', line 79

def to_sym
  @to_sym ||= SYMBOLS.invert.fetch(strip_patch.to_s, :dunno)
end