Class: Homebrew::SimulateSystem 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.
Helper module for simulating different system configurations.
Class Attribute Summary collapse
- .arch ⇒ Object private
- .os ⇒ Object private
Class Method Summary collapse
- .clear ⇒ void private
- .current_arch ⇒ Symbol private
- .current_os ⇒ Symbol private
- .simulating_or_running_on_linux? ⇒ Boolean private
- .simulating_or_running_on_macos? ⇒ Boolean private
- .with(os: T.unsafe(nil), arch: T.unsafe(nil), &_block) ⇒ T.type_parameter(:U) private
Class Attribute Details
.arch ⇒ Object
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.
10 11 12 |
# File 'simulate_system.rb', line 10 def arch @arch end |
.os ⇒ Object
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.
10 11 12 |
# File 'simulate_system.rb', line 10 def os @os end |
Class Method Details
.clear ⇒ 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.
52 53 54 |
# File 'simulate_system.rb', line 52 def clear @os = @arch = nil end |
.current_arch ⇒ 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.
67 68 69 |
# File 'simulate_system.rb', line 67 def current_arch @arch || Hardware::CPU.type end |
.current_os ⇒ 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.
72 73 74 |
# File 'simulate_system.rb', line 72 def current_os os || :generic end |
.simulating_or_running_on_linux? ⇒ 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.
62 63 64 |
# File 'simulate_system.rb', line 62 def simulating_or_running_on_linux? os == :linux end |
.simulating_or_running_on_macos? ⇒ 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.
57 58 59 |
# File 'simulate_system.rb', line 57 def simulating_or_running_on_macos? [:macos, *MacOSVersion::SYMBOLS.keys].include?(os) end |
.with(os: T.unsafe(nil), arch: T.unsafe(nil), &_block) ⇒ T.type_parameter(:U)
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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'simulate_system.rb', line 19 def with(os: T.unsafe(nil), arch: T.unsafe(nil), &_block) raise ArgumentError, "At least one of `os` or `arch` must be specified." if !os && !arch old_os = self.os old_arch = self.arch begin self.os = os if os && os != current_os self.arch = arch if arch && arch != current_arch yield ensure @os = old_os @arch = old_arch end end |