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_upgradable

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
# 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_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:



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

def cask
  @cask ||= []
end

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

Parameters:

Returns:



102
103
104
# File 'cask/dsl/depends_on.rb', line 102

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)


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

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:



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

def formula
  @formula ||= []
end

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

Parameters:

Returns:



97
98
99
# File 'cask/dsl/depends_on.rb', line 97

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

#load(pairs, set_in_block: 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:



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

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

    previous_macos = @macos if key == :macos
    __getobj__[key] = case key
    when :macos, :maximum_macos
      send(:"#{key}=", *value, set_in_block:)
    else
      send(:"#{key}=", *value)
    end
    record_os_requirement(key, set_in_block:)
    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)


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

def present? = !empty?

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



185
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
# File 'cask/dsl/depends_on.rb', line 185

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


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

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

    record_macos_requirement(macos, set_in_block:)
  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:)
  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)


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

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)


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

def requires_macos?
  @macos_bare_set_top_level || @macos_version_set_top_level || @maximum_macos_set_top_level
end