Module: MacIosInfo
- Defined in:
- lib/mac_ios_info.rb,
lib/mac_ios_info/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- UNKNOWN =
"UnKnown".freeze
- DARWIN_MAJOR_TO_MACOS =
Darwin (kernel) major version => [macOS name, macOS major version].
A macOS build number starts with the Darwin major version ("24G830" => 24), so this resolves the release family of any build, including releases that came out after this gem was published.
{ 16 => ["macOS Sierra", "10.12"], 17 => ["macOS High Sierra", "10.13"], 18 => ["macOS Mojave", "10.14"], 19 => ["macOS Catalina", "10.15"], 20 => ["macOS Big Sur", "11"], 21 => ["macOS Monterey", "12"], 22 => ["macOS Ventura", "13"], 23 => ["macOS Sonoma", "14"], 24 => ["macOS Sequoia", "15"], 25 => ["macOS Tahoe", "26"] }.freeze
- MAJOR_TO_OS_NAME =
macOS version major => macOS name, for macOS 11 and later.
DARWIN_MAJOR_TO_MACOS.each_with_object({}) do |(_darwin, (name, version)), acc| next if version.start_with?("10.") acc[version.to_i] = name end.freeze
- LEGACY_MINOR_TO_OS_NAME =
macOS version minor => macOS name, for the "10.x" era.
DARWIN_MAJOR_TO_MACOS.each_with_object({}) do |(_darwin, (name, version)), acc| next unless version.start_with?("10.") acc[version.split(".")[1].to_i] = name end.freeze
- BUILD_NUMBER_TO_VERSION =
macOS build number => macOS version.
{ # macOS High Sierra "17A365" => "10.13", "17A405" => "10.13", "17B1002" => "10.13.1", "17B1003" => "10.13.1", "17B48" => "10.13.1", "17C205" => "10.13.2", "17C2205" => "10.13.2", "17C88" => "10.13.2", "17C89" => "10.13.2", "17D102" => "10.13.3", "17D2047" => "10.13.3", "17D2102" => "10.13.3", "17D47" => "10.13.3", "17E199" => "10.13.4", "17E201" => "10.13.4", "17E202" => "10.13.4", "17F77" => "10.13.5", "17G10021" => "10.13.6", "17G11023" => "10.13.6", "17G12034" => "10.13.6", "17G13033" => "10.13.6", "17G13035" => "10.13.6", "17G14019" => "10.13.6", "17G14033" => "10.13.6", "17G14042" => "10.13.6", "17G2208" => "10.13.6", "17G2307" => "10.13.6", "17G3025" => "10.13.6", "17G4015" => "10.13.6", "17G5019" => "10.13.6", "17G6029" => "10.13.6", "17G6030" => "10.13.6", "17G65" => "10.13.6", "17G7024" => "10.13.6", "17G8029" => "10.13.6", "17G8030" => "10.13.6", "17G8037" => "10.13.6", "17G9016" => "10.13.6", # macOS Mojave "18A391" => "10.14", "18B2107" => "10.14.1", "18B3094" => "10.14.1", "18B75" => "10.14.1", "18C54" => "10.14.2", "18D109" => "10.14.3", "18D42" => "10.14.3", "18D43" => "10.14.3", "18E226" => "10.14.4", "18E227" => "10.14.4", "18F132" => "10.14.5", "18F203" => "10.14.5", "18G1012" => "10.14.6", "18G103" => "10.14.6", "18G84" => "10.14.6", "18G95" => "10.14.6", # macOS Catalina "19A583" => "10.15", "19A602" => "10.15", "19A603" => "10.15", "19B88" => "10.15.1", "19C57" => "10.15.2", "19C58" => "10.15.2", "19D76" => "10.15.3", "19E266" => "10.15.4", "19E287" => "10.15.4", "19F101" => "10.15.5", "19F96" => "10.15.5", "19G2021" => "10.15.6", "19G73" => "10.15.6", "19H1030" => "10.15.7", "19H114" => "10.15.7", "19H1217" => "10.15.7", "19H1323" => "10.15.7", "19H1417" => "10.15.7", "19H1419" => "10.15.7", "19H15" => "10.15.7", "19H1519" => "10.15.7", "19H1615" => "10.15.7", "19H1713" => "10.15.7", "19H1715" => "10.15.7", "19H1824" => "10.15.7", "19H1922" => "10.15.7", "19H2" => "10.15.7", "19H2026" => "10.15.7", "19H4" => "10.15.7", "19H512" => "10.15.7", "19H524" => "10.15.7", "19H2036" => "10.15.8", # macOS Big Sur "20A2411" => "11.0", "20B29" => "11.0.1", "20B50" => "11.0.1", "20C69" => "11.1", "20D64" => "11.2", "20D74" => "11.2.1", "20D75" => "11.2.1", "20D80" => "11.2.2", "20D91" => "11.2.3", "20E232" => "11.3", "20E241" => "11.3.1", "20F71" => "11.4", "20G71" => "11.5", "20G80" => "11.5.1", "20G95" => "11.5.2", "20G165" => "11.6", "20G224" => "11.6.1", "20G314" => "11.6.2", "20G415" => "11.6.3", "20G417" => "11.6.4", "20G527" => "11.6.5", "20G624" => "11.6.6", "20G630" => "11.6.7", "20G730" => "11.6.8", "20G817" => "11.7", "20G918" => "11.7.1", "20G1020" => "11.7.2", "20G1116" => "11.7.3", "20G1120" => "11.7.4", "20G1225" => "11.7.5", "20G1231" => "11.7.6", "20G1345" => "11.7.7", "20G1351" => "11.7.8", "20G1426" => "11.7.9", "20G1427" => "11.7.10", "20G1443" => "11.7.11", # macOS Monterey "21A344" => "12.0", "21A559" => "12.0.1", "21C52" => "12.1", "21D49" => "12.2", "21D62" => "12.2.1", "21E230" => "12.3", "21E258" => "12.3.1", "21F2081" => "12.4", "21F2092" => "12.4", "21F79" => "12.4", "21G72" => "12.5", "21G83" => "12.5.1", "21G115" => "12.6", "21G217" => "12.6.1", "21G320" => "12.6.2", "21G419" => "12.6.3", "21G526" => "12.6.4", "21G531" => "12.6.5", "21G646" => "12.6.6", "21G651" => "12.6.7", "21G725" => "12.6.8", "21G726" => "12.6.9", "21G816" => "12.7", "21G920" => "12.7.1", "21G1974" => "12.7.2", "21H1015" => "12.7.3", "21H1123" => "12.7.4", "21H1222" => "12.7.5", "21H1320" => "12.7.6", # macOS Ventura "22A380" => "13.0", "22A400" => "13.0.1", "22C65" => "13.1", "22D49" => "13.2", "22D68" => "13.2.1", "22E252" => "13.3", "22E261" => "13.3.1", "22E772610a" => "13.3.1", "22F66" => "13.4", "22F770820b" => "13.4.1", "22F770820d" => "13.4.1", "22F82" => "13.4.1", "22G74" => "13.5", "22G90" => "13.5.1", "22G91" => "13.5.2", "22G120" => "13.6", "22G313" => "13.6.1", "22G320" => "13.6.2", "22G436" => "13.6.3", "22G513" => "13.6.4", "22G621" => "13.6.5", "22G630" => "13.6.6", "22G720" => "13.6.7", "22G820" => "13.6.8", "22G830" => "13.6.9", "22H123" => "13.7", "22H221" => "13.7.1", "22H313" => "13.7.2", "22H417" => "13.7.3", "22H420" => "13.7.4", "22H527" => "13.7.5", "22H625" => "13.7.6", "22H722" => "13.7.7", "22H730" => "13.7.8", # macOS Sonoma "23A344" => "14.0", "23B74" => "14.1", "23B2082" => "14.1.1", "23B81" => "14.1.1", "23B92" => "14.1.2", "23C64" => "14.2", "23C71" => "14.2.1", "23D56" => "14.3", "23D60" => "14.3.1", "23E214" => "14.4", "23E224" => "14.4.1", "23F79" => "14.5", "23G80" => "14.6", "23G93" => "14.6.1", "23H124" => "14.7", "23H222" => "14.7.1", "23H311" => "14.7.2", "23H417" => "14.7.3", "23H420" => "14.7.4", "23H527" => "14.7.5", "23H626" => "14.7.6", "23H723" => "14.7.7", "23H730" => "14.7.8", "23J21" => "14.8", "23J30" => "14.8.1", "23J126" => "14.8.2", "23J220" => "14.8.3", "23J319" => "14.8.4", "23J423" => "14.8.5", "23J520" => "14.8.7", "23J620" => "14.8.8", "23J631" => "14.8.9", # macOS Sequoia "24A335" => "15.0", "24A348" => "15.0.1", "24B2083" => "15.1", "24B83" => "15.1", "24B91" => "15.1.1", "24C101" => "15.2", "24D60" => "15.3", "24D70" => "15.3.1", "24D2082" => "15.3.2", "24D81" => "15.3.2", "24E248" => "15.4", "24E263" => "15.4.1", "24F74" => "15.5", "24G84" => "15.6", "24G90" => "15.6.1", "24G222" => "15.7", "24G231" => "15.7.1", "24G325" => "15.7.2", "24G419" => "15.7.3", "24G517" => "15.7.4", "24G624" => "15.7.5", "24G720" => "15.7.7", "24G824" => "15.7.8", "24G830" => "15.7.9", # macOS Tahoe "25A354" => "26.0", "25A8353" => "26.0", "25A362" => "26.0.1", "25A8364" => "26.0.1", "25B78" => "26.1", "25C56" => "26.2", "25D125" => "26.3", "25D2128" => "26.3.1", "25D771280a" => "26.3.1", "25D2140" => "26.3.2", "25D771400a" => "26.3.2", "25E246" => "26.4", "25E253" => "26.4.1", "25F71" => "26.5", "25F80" => "26.5.1", "25F84" => "26.5.2", "25G72" => "26.6", "25G76" => "26.6.1", "25G83" => "26.6.2" }.freeze
- VERSION =
"0.2.0"
Class Method Summary collapse
-
.macos_build_to_macos_version(build_number:) ⇒ Object
Change a macOS build number to a macOS version.
-
.macos_build_to_os_name(build_number:) ⇒ Object
Change a macOS build number to a macOS name.
-
.macos_version_to_os_name(version:) ⇒ Object
Change a macOS version to a macOS name.
Class Method Details
.macos_build_to_macos_version(build_number:) ⇒ Object
Change a macOS build number to a macOS version.
When the exact build is not listed, the major version is derived from the build number instead of giving up, so newer releases still resolve.
329 330 331 332 333 334 335 |
# File 'lib/mac_ios_info.rb', line 329 def self.macos_build_to_macos_version(build_number:) exact = BUILD_NUMBER_TO_VERSION[build_number.to_s] return exact unless exact.nil? _name, version = darwin_major_to_macos(build_number) version || UNKNOWN end |
.macos_build_to_os_name(build_number:) ⇒ Object
Change a macOS build number to a macOS name.
341 342 343 344 345 346 |
# File 'lib/mac_ios_info.rb', line 341 def self.macos_build_to_os_name(build_number:) name, = darwin_major_to_macos(build_number) return name unless name.nil? macos_version_to_os_name(version: macos_build_to_macos_version(build_number: build_number)) end |
.macos_version_to_os_name(version:) ⇒ Object
Change a macOS version to a macOS name.
352 353 354 355 356 357 358 359 360 |
# File 'lib/mac_ios_info.rb', line 352 def self.macos_version_to_os_name(version:) major, minor = version.to_s.split(".") return UNKNOWN if major.nil? || major.empty? return MAJOR_TO_OS_NAME.fetch(major.to_i, UNKNOWN) unless major == "10" return UNKNOWN if minor.nil? LEGACY_MINOR_TO_OS_NAME.fetch(minor.to_i, UNKNOWN) end |