Class: Homebrew::SimulateSystem Private

Inherits:
Object
  • Object
show all
Defined in:
simulate_system.rb

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

Class Method Summary collapse

Class Attribute Details

.archObject

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.



11
12
13
# File 'simulate_system.rb', line 11

def arch
  @arch
end

.osObject

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.



11
12
13
# File 'simulate_system.rb', line 11

def os
  @os
end

Class Method Details

.clearvoid

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.



65
66
67
# File 'simulate_system.rb', line 65

def clear
  @os = @arch = nil
end

.current_archSymbol

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.

Returns:



80
81
82
# File 'simulate_system.rb', line 80

def current_arch
  @arch || Hardware::CPU.type
end

.current_osSymbol

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.

Returns:



85
86
87
# File 'simulate_system.rb', line 85

def current_os
  os || :generic
end

.current_tagUtils::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.

Returns:



90
91
92
93
94
95
# File 'simulate_system.rb', line 90

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.

Returns:

  • (Boolean)


75
76
77
# File 'simulate_system.rb', line 75

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.

Returns:

  • (Boolean)


70
71
72
# File 'simulate_system.rb', line 70

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.

Parameters:

  • os (Symbol) (defaults to: T.unsafe(nil))
  • arch (Symbol) (defaults to: T.unsafe(nil))
  • _block (T.proc.returns(T.type_parameter(:U)))

Returns:

  • (T.type_parameter(:U))

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'simulate_system.rb', line 20

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.

Parameters:

Returns:

  • (T.type_parameter(:U))

Raises:

  • (ArgumentError)


43
44
45
46
47
# File 'simulate_system.rb', line 43

def with_tag(tag, &block)
  raise ArgumentError, "Invalid tag: #{tag}" unless tag.valid_combination?

  with(os: tag.system, arch: tag.arch, &block)
end