Class: HomebrewAutomation::MacOS
- Inherits:
-
Object
- Object
- HomebrewAutomation::MacOS
- Defined in:
- lib/homebrew_automation/mac_os.rb
Overview
Inspect version of the macOS we’re running on
Class Method Summary collapse
-
.identify_version! ⇒ String | NilClass
Identify the version of the macOS this is run on.
-
.mac_to_homebrew ⇒ Hash<Regexp, String>
Lookup table of numeric version patterns to Homebrew-recognised strings.
Class Method Details
.identify_version! ⇒ String | NilClass
Identify the version of the macOS this is run on
Return a macOS version name in a convention recognised by Homebrew, in particular by the Formula/Bottle DSL.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/homebrew_automation/mac_os.rb', line 13 def self.identify_version! version = begin `sw_vers -productVersion`.chomp rescue Errno::ENOENT # if we're not on a Mac nil end mac_to_homebrew. select { |pattern, _| pattern === version }. map { |_, description| description }. first end |
.mac_to_homebrew ⇒ Hash<Regexp, String>
Lookup table of numeric version patterns to Homebrew-recognised strings
29 30 31 32 33 34 35 36 |
# File 'lib/homebrew_automation/mac_os.rb', line 29 def self.mac_to_homebrew { /^10.10/ => 'yosemite', /^10.11/ => 'el_capitan', /^10.12/ => 'sierra', /^10.13/ => 'high_sierra' } end |