Class: MacOSVersion Private
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.
Defined Under Namespace
Classes: Error
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.
NOTE: When removing symbols here, ensure that they are added to
DEPRECATED_MACOS_VERSIONS
inMacOSRequirement
. { sonoma: "14", ventura: "13", monterey: "12", big_sur: "11", catalina: "10.15", mojave: "10.14", high_sierra: "10.13", sierra: "10.12", el_capitan: "10.11", }.freeze
- NULL =
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.
Represents the absence of a version. NOTE: Constructor needs to called with an arbitrary macOS-like version which is then set to
nil
. MacOSVersion.new("10.0").tap { |v| v.instance_variable_set(:@version, nil) }.freeze
Constants inherited from Version
Class Method Summary collapse
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer?
private
-
#initialize(version) ⇒ void
constructor
private
-
#outdated_release? ⇒ Boolean
private
-
#prerelease? ⇒ Boolean
private
-
#pretty_name ⇒ String
private
-
#requires_nehalem_cpu? ⇒ Boolean
(also: #requires_sse4?, #requires_sse41?, #requires_sse42?, #requires_popcnt?)
private
-
#strip_patch ⇒ T.self_type
private
-
#to_sym ⇒ Symbol
private
-
#unsupported_release? ⇒ Boolean
private
Methods inherited from Version
#==, #commit, #compare, create, detect, #detected_from_url?, formula_optionally_versioned_regex, #freeze, #hash, #head?, #inspect, #major, #major_minor, #major_minor_patch, #minor, #null?, parse, #patch, #respond_to?, #to_f, #to_i, #to_json, #to_s, #to_str, #update_commit
Constructor Details
#initialize(version) ⇒ 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.
42 43 44 45 46 47 48 |
# File 'macos_version.rb', line 42 def initialize(version) raise MacOSVersion::Error, version unless /\A1\d+(?:\.\d+){0,2}\Z/.match?(version) super(T.must(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.
36 37 38 39 |
# File 'macos_version.rb', line 36 def self.from_symbol(version) str = SYMBOLS.fetch(version) { raise MacOSVersion::Error, 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.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'macos_version.rb', line 51 def <=>(other) return @comparison_cache[other] if @comparison_cache.key?(other) result = case other when Symbol if SYMBOLS.key?(other) && to_sym == other 0 else v = SYMBOLS.fetch(other) { other.to_s } super(v) end else super end @comparison_cache[other] = result unless frozen? result 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.
106 107 108 |
# File 'macos_version.rb', line 106 def outdated_release? self < HOMEBREW_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.
111 112 113 |
# File 'macos_version.rb', line 111 def prerelease? self >= HOMEBREW_MACOS_NEWEST_UNSUPPORTED end |
#pretty_name ⇒ String
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.
95 96 97 98 99 100 101 102 103 |
# File 'macos_version.rb', line 95 def pretty_name return @pretty_name if defined?(@pretty_name) pretty_name = to_sym.to_s.split("_").map(&:capitalize).join(" ").freeze @pretty_name = pretty_name unless frozen? pretty_name 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.
121 122 123 124 125 126 127 128 129 |
# File 'macos_version.rb', line 121 def requires_nehalem_cpu? return false if null? require "hardware" return Hardware.oldest_cpu(self) == :nehalem if Hardware::CPU.intel? raise ArgumentError, "Unexpected architecture: #{Hardware::CPU.arch}. This only works with Intel architecture." end |
#strip_patch ⇒ T.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.
72 73 74 75 76 77 78 79 80 81 |
# File 'macos_version.rb', line 72 def strip_patch return self if null? # Big Sur is 11.x but Catalina is 10.15.x. if T.must(major) >= 11 self.class.new(major.to_s) else major_minor end end |
#to_sym ⇒ Symbol
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.
84 85 86 87 88 89 90 91 92 |
# File 'macos_version.rb', line 84 def to_sym return @sym if defined?(@sym) sym = SYMBOLS.invert.fetch(strip_patch.to_s, :dunno) @sym = sym unless frozen? sym end |
#unsupported_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.
116 117 118 |
# File 'macos_version.rb', line 116 def unsupported_release? outdated_release? || prerelease? end |