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 ⇒ Symbol? private
- .os ⇒ Symbol? private
Class Method Summary collapse
- .arch_symbols ⇒ Hash{Symbol => Symbol} private
- .clear ⇒ void private
- .current_arch ⇒ Symbol private
- .current_os ⇒ Symbol private
- .current_tag ⇒ Utils::Bottles::Tag 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
- .with_tag(tag, &block) ⇒ T.type_parameter(:U) private
Class Attribute Details
.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.
12 13 14 |
# File 'simulate_system.rb', line 12 def arch @arch end |
.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.
15 16 17 |
# File 'simulate_system.rb', line 15 def os @os end |
Class Method Details
.arch_symbols ⇒ Hash{Symbol => 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.
18 19 20 |
# File 'simulate_system.rb', line 18 def arch_symbols { arm64: :arm, x86_64: :intel }.freeze end |
.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.
74 75 76 |
# File 'simulate_system.rb', line 74 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.
89 90 91 |
# File 'simulate_system.rb', line 89 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.
94 95 96 |
# File 'simulate_system.rb', line 94 def current_os os || :generic end |
.current_tag ⇒ Utils::Bottles::Tag
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.
99 100 101 102 103 104 |
# File 'simulate_system.rb', line 99 def current_tag Utils::Bottles::Tag.new( system: current_os, arch: current_arch, ) 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.
84 85 86 |
# File 'simulate_system.rb', line 84 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.
79 80 81 |
# File 'simulate_system.rb', line 79 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.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'simulate_system.rb', line 29 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 |
.with_tag(tag, &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.
52 53 54 55 56 |
# File 'simulate_system.rb', line 52 def with_tag(tag, &block) raise ArgumentError, "Invalid tag: #{tag}" unless tag.valid_combination? with(os: tag.system, arch: tag.arch, &block) end |