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_VERSIONSinMacOSRequirement.Note:Changes to this list must match
macos_version_nameincmd/update.sh. T.let({ tahoe: "26", sequoia: "15", sonoma: "14", ventura: "13", monterey: "12", big_sur: "11", catalina: "10.15", # odisabled remove support for Mojave and below 4.7.0 mojave: "10.14", high_sierra: "10.13", sierra: "10.12", el_capitan: "10.11", }.freeze, T::Hash[Symbol, String])
- VERSIONS_TO_ANALYTICS_PRETTY_NAMES =
          
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.
TODO:can be replaced with a call to
#pretty_nameonce we remove supportfor El Capitan (odisabled in 4.7.0)
 T.let({ "26" => "macOS Tahoe (26)", "15" => "macOS Sequoia (15)", "14" => "macOS Sonoma (14)", "13" => "macOS Ventura (13)", "12" => "macOS Monterey (12)", "11" => "macOS Big Sur (11)", "10.16" => "macOS Big Sur (11)", "10.15" => "macOS Catalina (10.15)", "10.14" => "macOS Mojave (10.14)", "10.13" => "macOS High Sierra (10.13)", "10.12" => "macOS Sierra (10.12)", "10.11" => "OS X El Capitan (10.11)", }.freeze, T::Hash[String, 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("10.0").tap do |v| T.let(v, MacOSVersion).instance_variable_set(:@version, nil) end.freeze, MacOSVersion)
Constants inherited from Version
Class Method Summary collapse
- .analytics_pretty_name(version) ⇒ String? private
 - .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
 - #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.
      84 85 86 87 88 89 90 91 92  | 
    
      # File 'macos_version.rb', line 84 def initialize(version) raise MacOSVersion::Error, version unless /\A\d{2,}(?:\.\d+){0,2}\z/.match?(version) super(T.must(version)) @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  | 
  
Class Method Details
.analytics_pretty_name(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.
      56 57 58 59 60 61 62  | 
    
      # File 'macos_version.rb', line 56 def self.analytics_pretty_name(version) VERSIONS_TO_ANALYTICS_PRETTY_NAMES.fetch(version) do VERSIONS_TO_ANALYTICS_PRETTY_NAMES.find do |v, _| version.start_with?(v) end&.last end end  | 
  
.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.
      78 79 80 81  | 
    
      # File 'macos_version.rb', line 78 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.
      65 66 67 68 69 70 71 72 73 74 75  | 
    
      # File 'macos_version.rb', line 65 def self.kernel_major_version(macos_version) version_major = macos_version.major.to_i if version_major >= 26 Version.new((version_major - 1).to_s) elsif version_major > 10 Version.new((version_major + 9).to_s) else version_minor = macos_version.minor.to_i Version.new((version_minor + 4).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.
      155 156 157  | 
    
      # File 'macos_version.rb', line 155 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.
      160 161 162  | 
    
      # File 'macos_version.rb', line 160 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.
      139 140 141 142 143 144 145 146 147  | 
    
      # File 'macos_version.rb', line 139 def pretty_name return @pretty_name if @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.
      170 171 172 173 174 175 176 177 178  | 
    
      # File 'macos_version.rb', line 170 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.
      116 117 118 119 120 121 122 123 124 125  | 
    
      # File 'macos_version.rb', line 116 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.
      128 129 130 131 132 133 134 135 136  | 
    
      # File 'macos_version.rb', line 128 def to_sym return @sym if @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.
      165 166 167  | 
    
      # File 'macos_version.rb', line 165 def unsupported_release? outdated_release? || prerelease? end  |