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
- RELEASES =
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.
Retain named releases after support ends so historical data can still be labelled.
T.let({ golden_gate: "27", tahoe: "26", sequoia: "15", sonoma: "14", ventura: "13", monterey: "12", # odisabled: remove support for Big Sur and macOS x86_64 September (or later) 2027 big_sur: "11", catalina: "10.15", mojave: "10.14", high_sierra: "10.13", sierra: "10.12", el_capitan: "10.11", }.freeze, T::Hash[Symbol, String])
- RELEASE_ALIASES =
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.
Big Sur reports 10.16 under SYSTEM_VERSION_COMPAT.
T.let({ "10.16" => "11", }.freeze, T::Hash[String, String])
- 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 support, exclude the symbol here and add it to
DISABLED_MACOS_VERSIONSinMacOSRequirement.Note:Active symbols must match
macos_version_nameincmd/update.sh. T.let(RELEASES.except( :catalina, :mojave, :high_sierra, :sierra, :el_capitan, ).freeze, T::Hash[Symbol, String])
- 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.
Note:Constructor needs to called with an arbitrary macOS-like version which is then set to
nil.Represents the absence of a version.
T.let(MacOSVersion.new("11").tap do |v| T.let(v, MacOSVersion).instance_variable_set(:@version, nil) end.freeze, MacOSVersion)
Constants inherited from Version
Instance Attribute Summary collapse
- #comparison_cache ⇒ Hash{T.untyped => Integer, nil} readonly private
- #sym ⇒ Symbol? readonly private
Class Method Summary collapse
- .from_symbol(version) ⇒ T.attached_class private
- .kernel_major_version(macos_version) ⇒ Version private
Instance Method Summary collapse
- #initialize(version) ⇒ void constructor private
- #outdated_release? ⇒ Boolean private
- #prerelease? ⇒ Boolean private
- #pretty_name ⇒ String private
- #release_name ⇒ String? private
- #release_version ⇒ 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, detect, #detected_from_url?, formula_optionally_versioned_regex, #freeze, #head?, #major, #major_minor, #major_minor_patch, #minor, #null?, parse, #patch, #respond_to?, #to_f, #to_i, #to_json, #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.
78 79 80 81 82 83 84 85 86 |
# File 'macos_version.rb', line 78 def initialize(version) raise MacOSVersion::Error, version if version.nil? || !/\A\d{2,}(?:\.\d+){0,2}\z/.match?(version) super @comparison_cache = T.let({}, T::Hash[T.untyped, T.nilable(Integer)]) @pretty_name = T.let(nil, T.nilable(String)) @sym = T.let(nil, T.nilable(Symbol)) end |
Instance Attribute Details
#comparison_cache ⇒ Hash{T.untyped => Integer, nil} (readonly)
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 |
# File 'macos_version.rb', line 72 def comparison_cache @comparison_cache end |
#sym ⇒ Symbol? (readonly)
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.
75 76 77 |
# File 'macos_version.rb', line 75 def sym @sym 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.
66 67 68 69 |
# File 'macos_version.rb', line 66 def self.from_symbol(version) str = SYMBOLS.fetch(version) { raise MacOSVersion::Error, version } new(str) end |
.kernel_major_version(macos_version) ⇒ Version
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.
54 55 56 57 58 59 60 61 62 63 |
# File 'macos_version.rb', line 54 def self.kernel_major_version(macos_version) version_major = macos_version.major.to_i if version_major >= 27 Version.new(version_major.to_s) elsif version_major == 26 Version.new((version_major - 1).to_s) else Version.new((version_major + 9).to_s) end end |
Instance Method Details
#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.
164 165 166 |
# File 'macos_version.rb', line 164 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.
169 170 171 |
# File 'macos_version.rb', line 169 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.
148 149 150 151 152 153 154 155 156 |
# File 'macos_version.rb', line 148 def pretty_name return @pretty_name if @pretty_name pretty_name = (release_name || "Dunno").freeze @pretty_name = pretty_name unless frozen? pretty_name end |
#release_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.
128 129 130 131 132 133 |
# File 'macos_version.rb', line 128 def release_name symbol = RELEASES.key(release_version) return if symbol.nil? symbol.to_s.split("_").map(&:capitalize).join(" ") end |
#release_version ⇒ 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.
122 123 124 125 |
# File 'macos_version.rb', line 122 def release_version version = strip_patch.to_s RELEASE_ALIASES.fetch(version, version) 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.
179 180 181 182 183 184 185 186 187 |
# File 'macos_version.rb', line 179 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.
110 111 112 113 114 115 116 117 118 119 |
# File 'macos_version.rb', line 110 def strip_patch return self if null? # Releases before Big Sur are all 10.x. if major.to_i >= 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.
136 137 138 139 140 141 142 143 144 145 |
# File 'macos_version.rb', line 136 def to_sym return @sym if @sym # Compatibility aliases are display-only and must not become supported bottle tags. 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.
174 175 176 |
# File 'macos_version.rb', line 174 def unsupported_release? outdated_release? || prerelease? end |