Module: OnSystem
- Defined in:
- on_system.rb,
on_system/dsl.rb
Defined Under Namespace
Modules: DSL, MacOSAndLinux, MacOSOnly
Constant Summary collapse
- ARCH_OPTIONS =
[:intel, :arm].freeze
- BASE_OS_OPTIONS =
[:macos, :linux].freeze
- ALL_OS_OPTIONS =
T.let([*MacOSVersion::SYMBOLS.keys, :linux].freeze, T::Array[Symbol])
- ALL_OS_ARCH_COMBINATIONS =
T.let(ALL_OS_OPTIONS.product(ARCH_OPTIONS).freeze, T::Array[[Symbol, Symbol]])
- VALID_OS_ARCH_TAGS =
T.let(.freeze, T::Array[Utils::Bottles::Tag])
Class Method Summary collapse
- .arch_condition_met?(arch) ⇒ Boolean private
- .included(_base) ⇒ void private
- .os_condition_met?(os_name, or_condition = nil) ⇒ Boolean private
Class Method Details
.arch_condition_met?(arch) ⇒ 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.
18 19 20 21 22 |
# File 'on_system.rb', line 18 def self.arch_condition_met?(arch) raise ArgumentError, "Invalid arch condition: #{arch.inspect}" if ARCH_OPTIONS.exclude?(arch) arch == Homebrew::SimulateSystem.current_arch end |
.included(_base) ⇒ 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.
This method returns an undefined value.
58 59 60 |
# File 'on_system.rb', line 58 def self.included(_base) raise "Do not include `OnSystem` directly. Instead, include `OnSystem::MacOSAndLinux` or `OnSystem::MacOSOnly`" end |
.os_condition_met?(os_name, or_condition = nil) ⇒ 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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'on_system.rb', line 25 def self.os_condition_met?(os_name, or_condition = nil) if BASE_OS_OPTIONS.include?(os_name) return Homebrew::SimulateSystem.public_send(:"simulating_or_running_on_#{os_name}?") end raise ArgumentError, "Invalid OS condition: #{os_name.inspect}" unless MacOSVersion::SYMBOLS.key?(os_name) if or_condition.present? && [:or_newer, :or_older].exclude?(or_condition) raise ArgumentError, "Invalid OS `or_*` condition: #{or_condition.inspect}" end return false unless Homebrew::SimulateSystem.simulating_or_running_on_macos? base_os = MacOSVersion.from_symbol(os_name) current_os = if Homebrew::SimulateSystem.current_os == :macos # Assume the oldest macOS version when simulating a generic macOS version. # Version::NULL is always treated as less than any other version. Version::NULL else MacOSVersion.from_symbol(Homebrew::SimulateSystem.current_os) end return current_os >= base_os if or_condition == :or_newer return current_os <= base_os if or_condition == :or_older current_os == base_os end |