Class: Cask::DSL Private

Inherits:
Object show all
Includes:
OS::Mac::Cask::DSL, OnSystem::MacOSAndLinux, Utils::Output::Mixin, Utils::Path
Defined in:
cask/dsl.rb,
cask/dsl/base.rb,
cask/dsl/rename.rb,
cask/dsl/caveats.rb,
cask/dsl/version.rb,
cask/dsl/container.rb,
cask/dsl/preflight.rb,
cask/dsl/depends_on.rb,
cask/dsl/postflight.rb,
cask/dsl/conflicts_with.rb,
cask/dsl/uninstall_preflight.rb,
cask/dsl/uninstall_postflight.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.

Class representing the domain-specific language used for casks.

Defined Under Namespace

Classes: Base, Caveats, ConflictsWith, Container, DependsOn, Postflight, Preflight, Rename, UninstallPostflight, UninstallPreflight, Version

Constant Summary collapse

ORDINARY_ARTIFACT_CLASSES =

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.

[
  Artifact::Installer,
  Artifact::App,
  Artifact::AppImage,
  Artifact::Artifact,
  Artifact::AudioUnitPlugin,
  Artifact::Binary,
  Artifact::Colorpicker,
  Artifact::Dictionary,
  Artifact::Font,
  Artifact::InputMethod,
  Artifact::InternetPlugin,
  Artifact::KeyboardLayout,
  Artifact::Manpage,
  Artifact::Pkg,
  Artifact::Prefpane,
  Artifact::Qlplugin,
  Artifact::Mdimporter,
  Artifact::ScreenSaver,
  Artifact::Service,
  Artifact::StageOnly,
  Artifact::Suite,
  Artifact::VstPlugin,
  Artifact::Vst3Plugin,
  Artifact::ZshCompletion,
  Artifact::FishCompletion,
  Artifact::BashCompletion,
  Artifact::GeneratedCompletion,
  Artifact::Uninstall,
  Artifact::Zap,
].freeze
ACTIVATABLE_ARTIFACT_CLASSES =

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(
  (ORDINARY_ARTIFACT_CLASSES - [Artifact::StageOnly]).freeze,
  T::Array[T.class_of(Artifact::AbstractArtifact)],
)
ARTIFACT_BLOCK_CLASSES =

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.

[
  Artifact::PreflightBlock,
  Artifact::PostflightBlock,
].freeze
INSTALL_STEP_ARTIFACT_CLASSES =

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.

[
  Artifact::PreflightSteps,
  Artifact::PostflightSteps,
  Artifact::UninstallPreflightSteps,
  Artifact::UninstallPostflightSteps,
].freeze
InstallStepFlightBlockClasses =

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.type_alias do
  T::Hash[
    T.class_of(Artifact::AbstractInstallSteps),
    [T.class_of(Artifact::AbstractFlightBlock), Symbol],
  ]
end
INSTALL_STEP_FLIGHT_BLOCK_CLASSES =

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({
  Artifact::PreflightSteps           => [Artifact::PreflightBlock, :preflight],
  Artifact::PostflightSteps          => [Artifact::PostflightBlock, :postflight],
  Artifact::UninstallPreflightSteps  => [Artifact::PreflightBlock, :uninstall_preflight],
  Artifact::UninstallPostflightSteps => [Artifact::PostflightBlock, :uninstall_postflight],
}.freeze, InstallStepFlightBlockClasses)
DSL_METHODS =

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([
  :arch,
  :artifacts,
  :auto_updates,
  :caveats,
  :conflicts_with,
  :container,
  :desc,
  :depends_on,
  :homepage,
  :language,
  :name,
  :os,
  :rename,
  :sha256,
  :staged_path,
  :url,
  :version,
  :appdir,
  :deprecate!,
  :deprecated?,
  :deprecation_date,
  :deprecation_reason,
  :deprecation_replacement_cask,
  :deprecation_replacement_formula,
  :deprecate_args,
  :disable!,
  :disabled?,
  :disable_date,
  :disable_reason,
  :disable_replacement_cask,
  :disable_replacement_formula,
  :disable_args,
  :livecheck,
  :livecheck_defined?,
  :no_autobump!,
  :autobump?,
  :no_autobump_message,
  :on_system_blocks_exist?,
  :on_os_blocks_exist?,
  :on_system_block_min_os,
  :depends_on_set_in_block?,
  *ORDINARY_ARTIFACT_CLASSES.map(&:dsl_key),
  *ACTIVATABLE_ARTIFACT_CLASSES.map(&:dsl_key),
  *ARTIFACT_BLOCK_CLASSES.flat_map { |klass| [klass.dsl_key, klass.uninstall_dsl_key] },
  *INSTALL_STEP_ARTIFACT_CLASSES.map(&:dsl_key),
]).freeze, T::Set[Symbol])

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OnSystem::MacOSAndLinux

included, #on_arch_conditional, #on_macos, #on_system_conditional

Methods included from Utils::Path

child_of?, formula_any_version_installed?, #formula_any_version_installed?, formula_installed_prefixes, formula_opt_bin, #formula_opt_bin, formula_opt_bin_env, formula_opt_bin_path, formula_opt_lib, #formula_opt_lib, formula_opt_libexec, #formula_opt_libexec, formula_opt_prefix, #formula_opt_prefix, loadable_package_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

#initialize(cask) ⇒ 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.

Parameters:



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'cask/dsl.rb', line 198

def initialize(cask)
  # NOTE: `:"@#{stanza}"` variables set by `set_unique_stanza` must be
  # initialized to `nil`.
  @arch = T.let(nil, T.nilable(String))
  @arch_set_in_block = T.let(false, T::Boolean)
  @artifacts = T.let(ArtifactSet.new, ArtifactSet)
  @auto_updates = T.let(nil, T.nilable(T::Boolean))
  @auto_updates_set_in_block = T.let(false, T::Boolean)
  @autobump = T.let(true, T::Boolean)
  @called_in_on_system_block = T.let(false, T::Boolean)
  @cask = cask
  @caveats = T.let(DSL::Caveats.new(cask), DSL::Caveats)
  @conflicts_with = T.let(nil, T.nilable(DSL::ConflictsWith))
  @conflicts_with_set_in_block = T.let(false, T::Boolean)
  @container = T.let(nil, T.nilable(DSL::Container))
  @container_set_in_block = T.let(false, T::Boolean)
  @depends_on = T.let(DSL::DependsOn.new, DSL::DependsOn)
  @depends_on_set_in_block = T.let(false, T::Boolean)
  @deprecated = T.let(false, T::Boolean)
  @deprecation_date = T.let(nil, T.nilable(Date))
  @deprecation_reason = T.let(nil, T.nilable(T.any(String, Symbol)))
  @deprecation_replacement_cask = T.let(nil, T.nilable(String))
  @deprecation_replacement_formula = T.let(nil, T.nilable(String))
  @deprecate_args = T.let(nil, T.nilable(T::Hash[Symbol, T.nilable(T.any(String, Symbol))]))
  @desc = T.let(nil, T.nilable(String))
  @desc_set_in_block = T.let(false, T::Boolean)
  @disable_date = T.let(nil, T.nilable(Date))
  @disable_reason = T.let(nil, T.nilable(T.any(String, Symbol)))
  @disable_replacement_cask = T.let(nil, T.nilable(String))
  @disable_replacement_formula = T.let(nil, T.nilable(String))
  @disable_args = T.let(nil, T.nilable(T::Hash[Symbol, T.nilable(T.any(String, Symbol))]))
  @disabled = T.let(false, T::Boolean)
  @homepage = T.let(nil, T.nilable(String))
  @homepage_set_in_block = T.let(false, T::Boolean)
  @language_blocks = T.let({}, T::Hash[T::Array[String], Proc])
  @language_eval = T.let(nil, T.nilable(String))
  @livecheck = T.let(Livecheck.new(cask), Livecheck)
  @livecheck_defined = T.let(false, T::Boolean)
  @name = T.let([], T::Array[String])
  @no_autobump_defined = T.let(false, T::Boolean)
  @no_autobump_message = T.let(nil, T.nilable(T.any(String, Symbol)))
  @on_system_blocks_exist = T.let(false, T::Boolean)
  @on_os_blocks_exist = T.let(false, T::Boolean)
  @on_system_block_min_os = T.let(nil, T.nilable(MacOSVersion))
  @os = T.let(nil, T.nilable(String))
  @os_set_in_block = T.let(false, T::Boolean)
  @rename = T.let([], T::Array[DSL::Rename])
  @sha256 = T.let(nil, T.nilable(T.any(Checksum, Symbol)))
  @sha256_set_for_linux = T.let(false, T::Boolean)
  @sha256_set_in_block = T.let(false, T::Boolean)
  @staged_path = T.let(nil, T.nilable(Pathname))
  @token = T.let(cask.token, String)
  @url = T.let(nil, T.nilable(URL))
  @url_set_in_block = T.let(false, T::Boolean)
  @version = T.let(nil, T.nilable(DSL::Version))
  @version_set_in_block = T.let(false, T::Boolean)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *_args) ⇒ T.noreturn

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:

  • method (Symbol)
  • _args (T.anything)

Returns:

  • (T.noreturn)

Raises:

  • (NoMethodError)


888
889
890
# File 'cask/dsl.rb', line 888

def method_missing(method, *_args)
  raise NoMethodError, "undefined method '#{method}' for Cask '#{token}'"
end

Instance Attribute Details

#artifactsArtifactSet (readonly)

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:



162
163
164
# File 'cask/dsl.rb', line 162

def artifacts
  @artifacts
end

#caskCask (readonly)

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:



153
154
155
# File 'cask/dsl.rb', line 153

def cask
  @cask
end

#deprecate_argsHash{Symbol => String, Symbol, nil}? (readonly)

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:



177
178
179
# File 'cask/dsl.rb', line 177

def deprecate_args
  @deprecate_args
end

#deprecation_dateDate? (readonly)

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:

  • (Date, nil)


165
166
167
# File 'cask/dsl.rb', line 165

def deprecation_date
  @deprecation_date
end

#deprecation_reasonString, ... (readonly)

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:



168
169
170
# File 'cask/dsl.rb', line 168

def deprecation_reason
  @deprecation_reason
end

#deprecation_replacement_caskString? (readonly)

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:



171
172
173
# File 'cask/dsl.rb', line 171

def deprecation_replacement_cask
  @deprecation_replacement_cask
end

#deprecation_replacement_formulaString? (readonly)

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:



174
175
176
# File 'cask/dsl.rb', line 174

def deprecation_replacement_formula
  @deprecation_replacement_formula
end

#disable_argsHash{Symbol => String, Symbol, nil}? (readonly)

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:



192
193
194
# File 'cask/dsl.rb', line 192

def disable_args
  @disable_args
end

#disable_dateDate? (readonly)

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:

  • (Date, nil)


180
181
182
# File 'cask/dsl.rb', line 180

def disable_date
  @disable_date
end

#disable_reasonString, ... (readonly)

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:



183
184
185
# File 'cask/dsl.rb', line 183

def disable_reason
  @disable_reason
end

#disable_replacement_caskString? (readonly)

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:



186
187
188
# File 'cask/dsl.rb', line 186

def disable_replacement_cask
  @disable_replacement_cask
end

#disable_replacement_formulaString? (readonly)

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:



189
190
191
# File 'cask/dsl.rb', line 189

def disable_replacement_formula
  @disable_replacement_formula
end

#no_autobump_messageString, ... (readonly)

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:



159
160
161
# File 'cask/dsl.rb', line 159

def no_autobump_message
  @no_autobump_message
end

#on_system_block_min_osMacOSVersion? (readonly)

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:



195
196
197
# File 'cask/dsl.rb', line 195

def on_system_block_min_os
  @on_system_block_min_os
end

#tokenString (readonly)

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:



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

def token
  @token
end

Instance Method Details

#appdirPathname, String

The directory apps are installed into.

Returns:



906
907
908
909
910
# File 'cask/dsl.rb', line 906

def appdir
  return HOMEBREW_CASK_APPDIR_PLACEHOLDER if Cask.generating_hash?

  cask.config.appdir
end

#arch(arm: nil, intel: nil) ⇒ String?

Sets the cask's architecture strings.

Example

arch arm: "darwin-arm64", intel: "darwin"

Parameters:

  • arm (String, nil) (defaults to: nil)
  • intel (String, nil) (defaults to: nil)

Returns:



567
568
569
570
571
572
573
574
575
# File 'cask/dsl.rb', line 567

def arch(arm: nil, intel: nil)
  should_return = arm.nil? && intel.nil?

  set_unique_stanza(:arch, should_return) do
    @on_system_blocks_exist = true

    on_arch_conditional(arm:, intel:)
  end
end

#auto_updates(auto_updates = nil) ⇒ Boolean?

Asserts that the cask artifacts auto-update.

Parameters:

  • auto_updates (Boolean, nil) (defaults to: nil)

Returns:

  • (Boolean, nil)


686
687
688
# File 'cask/dsl.rb', line 686

def auto_updates(auto_updates = nil)
  set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates }
end

#autobump?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.

Is the cask in autobump list?

Returns:

  • (Boolean)


722
723
724
# File 'cask/dsl.rb', line 722

def autobump?
  @autobump == true
end

#caskroom_pathPathname

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:



642
643
644
# File 'cask/dsl.rb', line 642

def caskroom_path
  cask.caskroom_path
end

#caveats(*strings, &block) ⇒ String, DSL::Caveats

Provide the user with cask-specific information at install time.

Parameters:

Returns:



666
667
668
669
670
671
672
673
674
675
676
677
# File 'cask/dsl.rb', line 666

def caveats(*strings, &block)
  if block
    @caveats.eval_caveats(&block)
  elsif strings.any?
    strings.each do |string|
      @caveats.eval_caveats { string }
    end
  else
    return @caveats.to_s
  end
  @caveats
end

#caveats_objectDSL::Caveats

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:



680
# File 'cask/dsl.rb', line 680

def caveats_object = @caveats

#conflicts_with(**kwargs) ⇒ DSL::ConflictsWith?

Declare conflicts that keep a cask from installing or working correctly.

Parameters:

  • kwargs (T.anything)

Returns:



636
637
638
639
# File 'cask/dsl.rb', line 636

def conflicts_with(**kwargs)
  # TODO: Remove this constraint and instead merge multiple `conflicts_with` stanzas
  set_unique_stanza(:conflicts_with, kwargs.empty?) { DSL::ConflictsWith.new(**kwargs) }
end

#container(nested: nil, type: nil) ⇒ DSL::Container?

Sets the cask's container type or nested container path.

Examples

The container is a nested disk image:

container nested: "orca-#{version}.dmg"

The container should not be unarchived:

container type: :naked

Parameters:

  • nested (String, nil) (defaults to: nil)
  • type (Symbol, nil) (defaults to: nil)

Returns:



451
452
453
454
455
# File 'cask/dsl.rb', line 451

def container(nested: nil, type: nil)
  set_unique_stanza(:container, nested.nil? && type.nil?) do
    DSL::Container.new(nested:, type:)
  end
end

#depends_on(arg = nil, **kwargs) ⇒ DSL::DependsOn

Note:

Multiple dependencies can be specified.

Declare dependencies and requirements for a cask.

Parameters:

  • arg (Symbol, nil) (defaults to: nil)
  • kwargs (T.untyped)

Returns:



609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
# File 'cask/dsl.rb', line 609

def depends_on(arg = nil, **kwargs)
  @depends_on_set_in_block = true if @called_in_on_system_block
  if arg == :macos
    if kwargs.key?(:macos) || kwargs.key?(:maximum_macos)
      raise CaskInvalidError.new(cask, "`depends_on :macos` cannot be combined with another macOS `depends_on`")
    end

    kwargs[:macos] = :any
  elsif arg == :linux
    kwargs[:linux] = :any
  elsif arg
    raise CaskInvalidError.new(cask, "invalid 'depends_on' value: #{arg.inspect}")
  end
  return @depends_on if kwargs.empty?

  begin
    @depends_on.load(kwargs, set_in_block: @called_in_on_system_block)
  rescue RuntimeError => e
    raise CaskInvalidError.new(cask, e)
  end
  @depends_on
end

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


257
# File 'cask/dsl.rb', line 257

def depends_on_set_in_block? = @depends_on_set_in_block

#deprecate!(date:, because:, replacement: nil, replacement_formula: nil, replacement_cask: nil) ⇒ void

Note:

A warning will be shown when trying to install this cask.

This method returns an undefined value.

Declare that a cask is no longer functional or supported.

Parameters:

  • date (String)
  • because (String, Symbol)
  • replacement (String, nil) (defaults to: nil)
  • replacement_formula (String, nil) (defaults to: nil)
  • replacement_cask (String, nil) (defaults to: nil)


740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
# File 'cask/dsl.rb', line 740

def deprecate!(date:, because:, replacement: nil, replacement_formula: nil, replacement_cask: nil)
  if [replacement, replacement_formula, replacement_cask].filter_map(&:presence).length > 1
    raise ArgumentError, "more than one of replacement, replacement_formula and/or replacement_cask specified!"
  end

  if replacement
    odeprecated(
      "deprecate!(:replacement)",
      "deprecate!(:replacement_formula) or deprecate!(:replacement_cask)",
    )
  end

  @deprecate_args = { date:, because:, replacement_formula:, replacement_cask: }

  @deprecation_date = Date.parse(date)
  return if @deprecation_date > Date.today

  @deprecation_reason = because
  @deprecation_replacement_formula = replacement_formula.presence || replacement
  @deprecation_replacement_cask = replacement_cask.presence || replacement
  @deprecated = true
end

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


260
# File 'cask/dsl.rb', line 260

def deprecated? = @deprecated

#desc(description = nil) ⇒ String?

Describes the cask.

Example

desc "Open-source code editor"

Parameters:

  • description (String, nil) (defaults to: nil)

Returns:



305
306
307
# File 'cask/dsl.rb', line 305

def desc(description = nil)
  set_unique_stanza(:desc, description.nil?) { description }
end

#disable!(date:, because:, replacement: nil, replacement_formula: nil, replacement_cask: nil) ⇒ void

Note:

An error will be thrown when trying to install this cask.

This method returns an undefined value.

Declare that a cask is no longer functional or supported.

Parameters:

  • date (String)
  • because (String, Symbol)
  • replacement (String, nil) (defaults to: nil)
  • replacement_formula (String, nil) (defaults to: nil)
  • replacement_cask (String, nil) (defaults to: nil)


777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
# File 'cask/dsl.rb', line 777

def disable!(date:, because:, replacement: nil, replacement_formula: nil, replacement_cask: nil)
  if [replacement, replacement_formula, replacement_cask].filter_map(&:presence).length > 1
    raise ArgumentError, "more than one of replacement, replacement_formula and/or replacement_cask specified!"
  end

  # odeprecate: remove this remapping when the :unsigned reason is removed
  because = :fails_gatekeeper_check if because == :unsigned

  if replacement
    odeprecated(
      "disable!(:replacement)",
      "disable!(:replacement_formula) or disable!(:replacement_cask)",
    )
  end

  @disable_args = { date:, because:, replacement_formula:, replacement_cask: }

  @disable_date = Date.parse(date)

  if @disable_date > Date.today
    @deprecation_reason = because
    @deprecation_replacement_formula = replacement_formula.presence || replacement
    @deprecation_replacement_cask = replacement_cask.presence || replacement
    @deprecated = true
    return
  end

  @disable_reason = because
  @disable_replacement_formula = replacement_formula.presence || replacement
  @disable_replacement_cask = replacement_cask.presence || replacement
  @disabled = true
end

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


263
# File 'cask/dsl.rb', line 263

def disabled? = @disabled

#homepage(homepage = nil) ⇒ String?

Sets the cask's homepage.

Example

homepage "https://code.visualstudio.com/"

Parameters:

  • homepage (String, nil) (defaults to: nil)

Returns:



349
350
351
# File 'cask/dsl.rb', line 349

def homepage(homepage = nil)
  set_unique_stanza(:homepage, homepage.nil?) { homepage }
end

#install_step_artifact_class(dsl_key) ⇒ T.class_of(Artifact::AbstractInstallSteps)?

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:



861
862
863
864
865
# File 'cask/dsl.rb', line 861

def install_step_artifact_class(dsl_key)
  INSTALL_STEP_FLIGHT_BLOCK_CLASSES.find do |_step_class, (_block_class, block_dsl_key)|
    block_dsl_key == dsl_key
  end&.first
end

#install_step_artifact_defined?(dsl_key) ⇒ 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.

Parameters:

Returns:

  • (Boolean)


854
855
856
857
858
# File 'cask/dsl.rb', line 854

def install_step_artifact_defined?(dsl_key)
  return false unless (klass = install_step_artifact_class(dsl_key))

  artifacts.any?(klass)
end

#language(*args, default: false, &block) ⇒ String?

Specifies language-specific values for the cask.

Parameters:

  • args (String)
  • default (Boolean) (defaults to: false)
  • block (T.proc.returns(String), nil)

Returns:



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'cask/dsl.rb', line 363

def language(*args, default: false, &block)
  if args.empty?
    language_eval
  elsif block
    @language_blocks[args] = block

    return unless default

    if !@cask.allow_reassignment && @language_blocks.default.present?
      raise CaskInvalidError.new(cask, "Only one default language may be defined.")
    end

    @language_blocks.default = block
    nil
  else
    raise CaskInvalidError.new(cask, "No block given to language stanza.")
  end
end

#language_evalString?

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:



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'cask/dsl.rb', line 383

def language_eval
  return @language_eval unless @language_eval.nil?

  return @language_eval = nil if @language_blocks.empty?

  if (language_blocks_default = @language_blocks.default).nil?
    raise CaskInvalidError.new(cask, "No default language specified.")
  end

  locales = cask.config.languages
                .filter_map do |language|
                  Locale.parse(language)
                rescue Locale::ParserError
                  nil
                end

  locales.each do |locale|
    key = T.cast(locale.detect(@language_blocks.keys), T.nilable(T::Array[String]))
    next if key.nil? || (language_block = @language_blocks[key]).nil?

    return @language_eval = language_block.call
  end

  @language_eval = language_blocks_default.call
end

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



410
411
412
# File 'cask/dsl.rb', line 410

def languages
  @language_blocks.keys.flatten
end

#livecheck(&block) ⇒ Livecheck

Automatically fetch the latest version of a cask from changelogs.

Parameters:

  • block (T.proc.void, nil)

Returns:



694
695
696
697
698
699
700
701
702
703
704
705
# File 'cask/dsl.rb', line 694

def livecheck(&block)
  return @livecheck unless block

  if !@cask.allow_reassignment && @livecheck_defined
    raise CaskInvalidError.new(cask, "'livecheck' stanza may only appear once.")
  end

  @livecheck_defined = true
  @livecheck.instance_eval(&block)
  set_no_autobump(because: :extract_plist) if @livecheck.strategy == :extract_plist && !no_autobump_defined?
  @livecheck
end

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


266
# File 'cask/dsl.rb', line 266

def livecheck_defined? = @livecheck_defined

#name(*args) ⇒ Array<String>

Note:

Multiple names can be specified.

Specifies the cask's name.

Example

name "Visual Studio Code"

Parameters:

Returns:



289
290
291
292
293
# File 'cask/dsl.rb', line 289

def name(*args)
  return @name if args.empty?

  @name.concat(args.flatten)
end

#no_autobump!(because:) ⇒ void

This method returns an undefined value.

Excludes the cask from autobump list.

Parameters:



711
712
713
714
715
716
717
718
# File 'cask/dsl.rb', line 711

def no_autobump!(because:)
  tap = @cask.tap
  if tap && !tap.official?
    raise CaskInvalidError.new(cask, "'no_autobump!' can only be used in official Homebrew taps.")
  end

  set_no_autobump(because:)
end

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


272
# File 'cask/dsl.rb', line 272

def on_os_blocks_exist? = @on_os_blocks_exist

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


269
# File 'cask/dsl.rb', line 269

def on_system_blocks_exist? = @on_system_blocks_exist

#os(macos: nil, linux: nil) ⇒ String?

Sets the cask's os strings.

Example

os macos: "darwin", linux: "tux"

Parameters:

  • macos (String, nil) (defaults to: nil)
  • linux (String, nil) (defaults to: nil)

Returns:



592
593
594
595
596
597
598
599
600
601
# File 'cask/dsl.rb', line 592

def os(macos: nil, linux: nil)
  should_return = macos.nil? && linux.nil?

  set_unique_stanza(:os, should_return) do
    @on_system_blocks_exist = true
    @on_os_blocks_exist = true

    on_system_conditional(macos:, linux:)
  end
end

#os_versionMacOSVersion?

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:



898
899
900
# File 'cask/dsl.rb', line 898

def os_version
  nil
end

#remove_conflicting_flight_blocks(klass) ⇒ 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:



868
869
870
871
872
873
874
875
876
877
878
879
880
# File 'cask/dsl.rb', line 868

def remove_conflicting_flight_blocks(klass)
  flight_block_class, dsl_key = INSTALL_STEP_FLIGHT_BLOCK_CLASSES.fetch(klass)
  conflicting_flight_blocks = artifacts.select do |artifact|
    next false unless artifact.is_a?(flight_block_class)

    artifact.directives.key?(dsl_key)
  end

  conflicting_flight_blocks.each do |artifact|
    warn_on_install_step_conflict(dsl_key, klass.dsl_key)
    artifacts.delete(artifact)
  end
end

#rename(from = T.unsafe(nil), to = T.unsafe(nil)) ⇒ Array<DSL::Rename>

Renames files after extraction.

This is useful when the downloaded file has unpredictable names that need to be normalized for proper artifact installation.

Example

rename "RØDECaster App*.pkg", "RØDECaster App.pkg"

Parameters:

  • from (String) (defaults to: T.unsafe(nil))
  • to (String) (defaults to: T.unsafe(nil))

Returns:



473
474
475
476
477
# File 'cask/dsl.rb', line 473

def rename(from = T.unsafe(nil), to = T.unsafe(nil))
  return @rename if from.nil?

  @rename << DSL::Rename.new(from, to)
end

#respond_to_missing?(_method_name, _include_private = false) ⇒ 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.

Parameters:

  • _method_name (String, Symbol)
  • _include_private (Boolean) (defaults to: false)

Returns:

  • (Boolean)


893
894
895
# File 'cask/dsl.rb', line 893

def respond_to_missing?(_method_name, _include_private = false)
  false
end

#set_unique_stanza(stanza, should_return, &_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.

Note:

Using WithoutRuntime to avoid Sorbet wrapping this method,

which would interfere with caller_locations in methods like url.

Parameters:

  • stanza (Symbol)
  • should_return (Boolean)
  • _block (T.proc.returns(T.all(BasicObject, T.type_parameter(:U))))

Returns:

  • (T.type_parameter(:U))


318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'cask/dsl.rb', line 318

def set_unique_stanza(stanza, should_return, &_block)
  return instance_variable_get(:"@#{stanza}") if should_return

  unless @cask.allow_reassignment
    if !instance_variable_get(:"@#{stanza}").nil? && !@called_in_on_system_block
      raise CaskInvalidError.new(cask, "'#{stanza}' stanza may only appear once.")
    end

    if instance_variable_get(:"@#{stanza}_set_in_block") && @called_in_on_system_block
      raise CaskInvalidError.new(cask, "'#{stanza}' stanza may only be overridden once.")
    end
  end

  instance_variable_set(:"@#{stanza}_set_in_block", true) if @called_in_on_system_block
  instance_variable_set(:"@#{stanza}", yield)
rescue CaskInvalidError
  raise
rescue => e
  raise CaskInvalidError.new(cask, "'#{stanza}' stanza failed with: #{e}")
end

#sha256(arg = nil, arm: nil, intel: nil, x86_64: nil, x86_64_linux: nil, arm64_linux: nil) ⇒ Symbol, ...

Sets the cask's download checksum.

Example

For universal or single-architecture downloads:

sha256 "7bdb497080ffafdfd8cc94d8c62b004af1be9599e865e5555e456e2681e150ca"

For architecture-dependent downloads:

sha256 arm:          "7bdb497080ffafdfd8cc94d8c62b004af1be9599e865e5555e456e2681e150ca",
       x86_64:       "b3c1c2442480a0219b9e05cf91d03385858c20f04b764ec08a3fa83d1b27e7b2"
       x86_64_linux: "1a2aee7f1ddc999993d4d7d42a150c5e602bc17281678050b8ed79a0500cc90f"
       arm64_linux:  "bd766af7e692afceb727a6f88e24e6e68d9882aeb3e8348412f6c03d96537c75"

Parameters:

  • arg (String, Symbol, nil) (defaults to: nil)
  • arm (String, nil) (defaults to: nil)
  • intel (String, nil) (defaults to: nil)
  • x86_64 (String, nil) (defaults to: nil)
  • x86_64_linux (String, nil) (defaults to: nil)
  • arm64_linux (String, nil) (defaults to: nil)

Returns:



532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'cask/dsl.rb', line 532

def sha256(arg = nil, arm: nil, intel: nil, x86_64: nil, x86_64_linux: nil, arm64_linux: nil)
  should_return = arg.nil? && arm.nil? && (intel.nil? || x86_64.nil?) && x86_64_linux.nil? && arm64_linux.nil?

  x86_64 ||= intel if intel.present? && x86_64.nil?
  set_unique_stanza(:sha256, should_return) do
    if arm.present? || x86_64.present? || x86_64_linux.present? || arm64_linux.present?
      @on_system_blocks_exist = true
    end
    @sha256_set_for_linux = true if x86_64_linux.present? || arm64_linux.present?

    val = arg || on_system_conditional(
      macos: on_arch_conditional(arm:, intel: x86_64),
      linux: on_arch_conditional(arm: arm64_linux, intel: x86_64_linux),
    )
    case val
    when :no_check
      :no_check
    when String
      Checksum.new(val)
    else
      raise CaskInvalidError.new(cask, "invalid 'sha256' value: #{val.inspect}")
    end
  end
end

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


275
# File 'cask/dsl.rb', line 275

def sha256_set_for_linux? = @sha256_set_for_linux

#staged_pathPathname

The staged location for this cask, including version number.

Returns:



650
651
652
653
654
655
# File 'cask/dsl.rb', line 650

def staged_path
  return @staged_path if @staged_path

  cask_version = version || :unknown
  @staged_path = caskroom_path.join(cask_version.to_s)
end

#url(uri = nil, **options) ⇒ URL?

Sets the cask's download URL.

Example

url "https://update.code.visualstudio.com/#{version}/#{arch}/stable"

Parameters:

  • uri (URI::Generic, String, nil) (defaults to: nil)
  • options (T.untyped)

Returns:



424
425
426
427
428
429
430
431
# File 'cask/dsl.rb', line 424

def url(uri = nil, **options)
  caller_location = caller_locations.fetch(0)
  return @url unless uri

  set_unique_stanza(:url, false) do
    URL.new(uri, **options, caller_location:)
  end
end

#version(arg = nil) ⇒ DSL::Version?

Sets the cask's version.

Example

version "1.88.1"

Parameters:

Returns:

See Also:



490
491
492
493
494
495
496
497
498
499
500
# File 'cask/dsl.rb', line 490

def version(arg = nil)
  set_unique_stanza(:version, arg.nil?) do
    if !arg.is_a?(String) && arg != :latest
      raise CaskInvalidError.new(cask, "invalid 'version' value: #{arg.inspect}")
    end

    set_no_autobump(because: :latest_version) if arg == :latest && !no_autobump_defined?

    DSL::Version.new(arg)
  end
end

#warn_on_install_step_conflict(dsl_key, steps_key) ⇒ 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:



883
884
885
# File 'cask/dsl.rb', line 883

def warn_on_install_step_conflict(dsl_key, steps_key)
  opoo "#{token}: `#{dsl_key}` is ignored because `#{steps_key}` is defined!"
end