Class: Cask::DSL::DependsOn Private

Inherits:
SimpleDelegator
  • Object
show all
Includes:
Kernel, Utils::Output::Mixin
Defined in:
cask/dsl/depends_on.rb,
cask/dsl/depends_on.rbi

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.

Constant Summary collapse

VALID_KEYS =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

T.let(Set.new([
  :formula,
  :cask,
  :macos,
  :maximum_macos,
  :linux,
  :arch,
]).freeze, T::Set[Symbol])
VALID_ARCHES =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

T.let({
  intel:  { type: :intel, bits: 64 },
  # specific
  x86_64: { type: :intel, bits: 64 },
  arm64:  { type: :arm, bits: 64 },
}.freeze, T::Hash[Symbol, T::Hash[Symbol, T.any(Symbol, Integer)]])

Constants included from Kernel

Kernel::IGNORE_INTERRUPTS_MUTEX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Kernel

#ensure_executable!, #exec_browser, #exec_editor, #ignore_interrupts, #interactive_shell, #quiet_system, #redirect_stdout, #safe_system, #which, #which_editor, #with_env, #with_homebrew_path

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Constructor Details

#initializevoid

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.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'cask/dsl/depends_on.rb', line 45

def initialize
  super({})
  @arch = T.let(nil, T.nilable(T::Array[T::Hash[Symbol, T.any(Symbol, Integer)]]))
  @cask = T.let(nil, T.nilable(T::Array[String]))
  @formula = T.let(nil, T.nilable(T::Array[String]))
  @macos = T.let(nil, T.nilable(MacOSRequirement))
  @maximum_macos = T.let(nil, T.nilable(MacOSRequirement))
  @linux = T.let(nil, T.nilable(LinuxRequirement))
  @macos_required = T.let(false, T::Boolean)
  @macos_bare_set_top_level = T.let(false, T::Boolean)
  @macos_version_set_top_level = T.let(false, T::Boolean)
  @maximum_macos_set_top_level = T.let(false, T::Boolean)
  @linux_set_top_level = T.let(false, T::Boolean)
end

Instance Attribute Details

#archArray<Hash{Symbol => Symbol, Integer}>?

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:



33
34
35
# File 'cask/dsl/depends_on.rb', line 33

def arch
  @arch
end

#linuxLinuxRequirement?

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:



42
43
44
# File 'cask/dsl/depends_on.rb', line 42

def linux
  @linux
end

#macosMacOSRequirement?

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:



36
37
38
# File 'cask/dsl/depends_on.rb', line 36

def macos
  @macos
end

#maximum_macosMacOSRequirement?

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:



39
40
41
# File 'cask/dsl/depends_on.rb', line 39

def maximum_macos
  @maximum_macos
end

Instance Method Details

#caskArray<String>

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:



61
62
63
# File 'cask/dsl/depends_on.rb', line 61

def cask
  @cask ||= []
end

#cask=(*args) ⇒ 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.

Parameters:



105
106
107
# File 'cask/dsl/depends_on.rb', line 105

def cask=(*args)
  cask.concat(args)
end

#empty?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)


153
# File 'cask/dsl/depends_on.rb', line 153

def empty? = T.let(__getobj__, T::Hash[Symbol, T.untyped]).empty?

#formulaArray<String>

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:



66
67
68
# File 'cask/dsl/depends_on.rb', line 66

def formula
  @formula ||= []
end

#formula=(*args) ⇒ 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.

Parameters:



100
101
102
# File 'cask/dsl/depends_on.rb', line 100

def formula=(*args)
  formula.concat(args)
end

#load(pairs, set_in_block: false, os_scoped: false) ⇒ 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.

Parameters:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'cask/dsl/depends_on.rb', line 77

def load(pairs, set_in_block: false, os_scoped: false)
  pairs.each do |key, value|
    raise "invalid depends_on key: '#{key.inspect}'" unless VALID_KEYS.include?(key)

    previous_macos = @macos if key == :macos
    case key
    when :macos, :maximum_macos
      send(:"#{key}=", *value, set_in_block:)
    else
      send(:"#{key}=", *value)
    end
    __getobj__[key] = public_send(key)
    record_os_requirement(key, set_in_block:, os_scoped:)
    next if key != :macos
    next if value != :any
    next unless previous_macos&.version_specified?

    @macos = previous_macos
    __getobj__[key] = previous_macos
  end
end

#present?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)


156
# File 'cask/dsl/depends_on.rb', line 156

def present? = !empty?

#record_macos_requirement(requirement, set_in_block:, os_scoped:) ⇒ 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.

Parameters:



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'cask/dsl/depends_on.rb', line 186

def record_macos_requirement(requirement, set_in_block:, os_scoped:)
  # `on_arm`/`on_intel` blocks are evaluated on every OS, so a macOS
  # dependency inside one applies everywhere; only an OS block scopes a
  # dependency to macOS alone.
  @macos_required = true unless os_scoped

  return if set_in_block

  raise "`depends_on :linux` cannot be combined with `depends_on macos:`" if requires_linux?

  if !requirement.version_specified?
    raise "`depends_on :macos` cannot be combined with another macOS `depends_on`" if @macos_bare_set_top_level

    if @macos_version_set_top_level || @maximum_macos_set_top_level
      odeprecated "`depends_on :macos` with `depends_on macos:`"
    end

    @macos_bare_set_top_level = true
  elsif requirement.comparator == "<="
    odeprecated "`depends_on :macos` with `depends_on maximum_macos:`" if @macos_bare_set_top_level

    if @maximum_macos_set_top_level
      raise "`depends_on maximum_macos:` cannot be combined with another macOS `depends_on`"
    end

    @maximum_macos_set_top_level = true
  else
    odeprecated "`depends_on :macos` with `depends_on macos:`" if @macos_bare_set_top_level

    if @macos_version_set_top_level
      raise "`depends_on macos:` cannot be combined with another macOS `depends_on`"
    end

    @macos_version_set_top_level = true
  end
end

#record_os_requirement(key, set_in_block:, os_scoped:) ⇒ 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.

Parameters:

  • key (Symbol)
  • set_in_block (Boolean)
  • os_scoped (Boolean)


165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'cask/dsl/depends_on.rb', line 165

def record_os_requirement(key, set_in_block:, os_scoped:)
  case key
  when :macos
    macos = @macos
    raise "invalid 'depends_on macos' value" unless macos

    record_macos_requirement(macos, set_in_block:, os_scoped:)
  when :maximum_macos
    maximum_macos = @maximum_macos
    raise "invalid 'depends_on maximum_macos' value" unless maximum_macos

    record_macos_requirement(maximum_macos, set_in_block:, os_scoped:)
  when :linux
    return if set_in_block
    raise "`depends_on :linux` cannot be combined with `depends_on macos:`" if requires_macos?

    @linux_set_top_level = true
  end
end

#requires_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)


162
# File 'cask/dsl/depends_on.rb', line 162

def requires_linux? = @linux_set_top_level

#requires_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)


159
# File 'cask/dsl/depends_on.rb', line 159

def requires_macos? = @macos_required