Class: Cask::DSL Private
- 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::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::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.
(ORDINARY_ARTIFACT_CLASSES - [Artifact::StageOnly]).freeze
- 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
- 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.
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, :disable!, :disabled?, :disable_date, :disable_reason, :disable_replacement_cask, :disable_replacement_formula, :livecheck, :livecheck_defined?, :livecheckable?, # TODO: remove once `#livecheckable?` was odisabled and is now removed :no_autobump!, :autobump?, :no_autobump_message, :on_system_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] }, ]).freeze
Instance Attribute Summary collapse
- #artifacts ⇒ Object readonly private
- #cask ⇒ Object readonly private
- #deprecation_date ⇒ Object readonly private
- #deprecation_reason ⇒ Object readonly private
- #deprecation_replacement_cask ⇒ Object readonly private
- #deprecation_replacement_formula ⇒ Object readonly private
- #disable_date ⇒ Object readonly private
- #disable_reason ⇒ Object readonly private
- #disable_replacement_cask ⇒ Object readonly private
- #disable_replacement_formula ⇒ Object readonly private
- #no_autobump_message ⇒ Object readonly private
- #on_system_block_min_os ⇒ Object readonly private
- #token ⇒ Object readonly private
Instance Method Summary collapse
- #add_implicit_macos_dependency ⇒ Object private
-
#appdir ⇒ Pathname, String
The directory
app
s are installed into. -
#arch(arm: nil, intel: nil) ⇒ Object
Sets the cask's architecture strings.
-
#auto_updates(auto_updates = nil) ⇒ Object
Asserts that the cask artifacts auto-update.
-
#autobump? ⇒ Boolean
private
Is the cask in autobump list?.
- #caskroom_path ⇒ Pathname private
-
#caveats(*strings, &block) ⇒ Object
Provide the user with cask-specific information at install time.
-
#conflicts_with(**kwargs) ⇒ Object
Declare conflicts that keep a cask from installing or working correctly.
-
#container(**kwargs) ⇒ Object
Sets the cask's container type or nested container path.
-
#depends_on(**kwargs) ⇒ Object
Declare dependencies and requirements for a cask.
- #depends_on_set_in_block? ⇒ Boolean private
-
#deprecate!(date:, because:, replacement: nil, replacement_formula: nil, replacement_cask: nil) ⇒ Object
Declare that a cask is no longer functional or supported.
- #deprecated? ⇒ Boolean private
-
#desc(description = nil) ⇒ Object
Describes the cask.
-
#disable!(date:, because:, replacement: nil, replacement_formula: nil, replacement_cask: nil) ⇒ Object
Declare that a cask is no longer functional or supported.
- #disabled? ⇒ Boolean private
-
#homepage(homepage = nil) ⇒ Object
Sets the cask's homepage.
- #initialize(cask) ⇒ void constructor private
- #language(*args, default: false, &block) ⇒ Object private
- #language_eval ⇒ Object private
- #languages ⇒ Object private
-
#livecheck(&block) ⇒ Object
Automatically fetch the latest version of a cask from changelogs.
- #livecheck_defined? ⇒ Boolean private
-
#livecheckable? ⇒ Boolean
deprecated
private
Deprecated.
Calling #livecheckable? is disabled, use #livecheck_defined? instead.
- #method_missing(method) ⇒ Object private
-
#name(*args) ⇒ Object
Specifies the cask's name.
-
#no_autobump!(because:) ⇒ void
Excludes the cask from autobump list.
-
#no_autobump_defined? ⇒ Boolean
private
Is no_autobump! method defined?.
- #on_system_blocks_exist? ⇒ Boolean private
-
#os(macos: nil, linux: nil) ⇒ String?
Sets the cask's os strings.
- #os_version ⇒ MacOSVersion? private
-
#rename(from = T.unsafe(nil), to = T.unsafe(nil)) ⇒ Array<DSL::Rename>
Renames files after extraction.
- #respond_to_missing? ⇒ Boolean private
- #set_unique_stanza(stanza, should_return) ⇒ Object private
-
#sha256(arg = nil, arm: nil, intel: nil, x86_64: nil, x86_64_linux: nil, arm64_linux: nil) ⇒ Symbol, ...
Sets the cask's download checksum.
-
#staged_path ⇒ Pathname
The staged location for this cask, including version number.
-
#url(*args, **options) ⇒ Object
Sets the cask's download URL.
-
#version(arg = nil) ⇒ DSL::Version?
Sets the cask's version.
Methods included from OnSystem::MacOSAndLinux
included, #on_arch_conditional, #on_macos, #on_system_conditional
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
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.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'cask/dsl.rb', line 128 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 = T.let(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)) @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)) @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) @on_system_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_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) ⇒ Object
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.
707 708 709 710 711 712 713 714 |
# File 'cask/dsl.rb', line 707 def method_missing(method, *) if method Utils.(method, token) nil else super end end |
Instance Attribute Details
#artifacts ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def artifacts @artifacts end |
#cask ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def cask @cask end |
#deprecation_date ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def deprecation_date @deprecation_date end |
#deprecation_reason ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def deprecation_reason @deprecation_reason end |
#deprecation_replacement_cask ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def deprecation_replacement_cask @deprecation_replacement_cask end |
#deprecation_replacement_formula ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def deprecation_replacement_formula @deprecation_replacement_formula end |
#disable_date ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def disable_date @disable_date end |
#disable_reason ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def disable_reason @disable_reason end |
#disable_replacement_cask ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def disable_replacement_cask @disable_replacement_cask end |
#disable_replacement_formula ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def disable_replacement_formula @disable_replacement_formula end |
#no_autobump_message ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def @no_autobump_message end |
#on_system_block_min_os ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def on_system_block_min_os @on_system_block_min_os end |
#token ⇒ Object (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.
122 123 124 |
# File 'cask/dsl.rb', line 122 def token @token end |
Instance Method Details
#add_implicit_macos_dependency ⇒ Object
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.
509 510 511 512 513 |
# File 'cask/dsl.rb', line 509 def add_implicit_macos_dependency return if (cask_depends_on = @depends_on).present? && cask_depends_on.macos.present? depends_on macos: ">= #{MacOSVersion.new(HOMEBREW_MACOS_OLDEST_ALLOWED).to_sym.inspect}" end |
#appdir ⇒ Pathname, String
The directory app
s are installed into.
729 730 731 732 733 |
# File 'cask/dsl.rb', line 729 def appdir return HOMEBREW_CASK_APPDIR_PLACEHOLDER if Cask. cask.config.appdir end |
#arch(arm: nil, intel: nil) ⇒ Object
Sets the cask's architecture strings.
Example
arch arm: "darwin-arm64", intel: "darwin"
456 457 458 459 460 461 462 463 464 |
# File 'cask/dsl.rb', line 456 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) ⇒ Object
Asserts that the cask artifacts auto-update.
558 559 560 |
# File 'cask/dsl.rb', line 558 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?
608 609 610 |
# File 'cask/dsl.rb', line 608 def autobump? @autobump == true end |
#caskroom_path ⇒ Pathname
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.
524 525 526 |
# File 'cask/dsl.rb', line 524 def caskroom_path cask.caskroom_path end |
#caveats(*strings, &block) ⇒ Object
Provide the user with cask-specific information at install time.
542 543 544 545 546 547 548 549 550 551 552 553 |
# File 'cask/dsl.rb', line 542 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 |
#conflicts_with(**kwargs) ⇒ Object
Declare conflicts that keep a cask from installing or working correctly.
518 519 520 521 |
# File 'cask/dsl.rb', line 518 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(**kwargs) ⇒ Object
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
342 343 344 345 346 |
# File 'cask/dsl.rb', line 342 def container(**kwargs) set_unique_stanza(:container, kwargs.empty?) do DSL::Container.new(**kwargs) end end |
#depends_on(**kwargs) ⇒ Object
Multiple dependencies can be specified.
Declare dependencies and requirements for a cask.
496 497 498 499 500 501 502 503 504 505 506 |
# File 'cask/dsl.rb', line 496 def depends_on(**kwargs) @depends_on_set_in_block = true if @called_in_on_system_block return @depends_on if kwargs.empty? begin @depends_on.load(**kwargs) 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.
182 |
# File 'cask/dsl.rb', line 182 def depends_on_set_in_block? = @depends_on_set_in_block |
#deprecate!(date:, because:, replacement: nil, replacement_formula: nil, replacement_cask: nil) ⇒ Object
A warning will be shown when trying to install this cask.
Declare that a cask is no longer functional or supported.
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
# File 'cask/dsl.rb', line 622 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 # odeprecate: remove this remapping when the :unsigned reason is removed because = :fails_gatekeeper_check if because == :unsigned if replacement odeprecated( "deprecate!(:replacement)", "deprecate!(:replacement_formula) or deprecate!(:replacement_cask)", ) end @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.
185 |
# File 'cask/dsl.rb', line 185 def deprecated? = @deprecated |
#desc(description = nil) ⇒ Object
Describes the cask.
Example
desc "Open-source code editor"
222 223 224 |
# File 'cask/dsl.rb', line 222 def desc(description = nil) set_unique_stanza(:desc, description.nil?) { description } end |
#disable!(date:, because:, replacement: nil, replacement_formula: nil, replacement_cask: nil) ⇒ Object
An error will be thrown when trying to install this cask.
Declare that a cask is no longer functional or supported.
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
# File 'cask/dsl.rb', line 651 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_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.
188 |
# File 'cask/dsl.rb', line 188 def disabled? = @disabled |
#homepage(homepage = nil) ⇒ Object
Sets the cask's homepage.
Example
homepage "https://code.visualstudio.com/"
256 257 258 |
# File 'cask/dsl.rb', line 256 def homepage(homepage = nil) set_unique_stanza(:homepage, homepage.nil?) { homepage } end |
#language(*args, default: false, &block) ⇒ Object
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.
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'cask/dsl.rb', line 260 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 else raise CaskInvalidError.new(cask, "No block given to language stanza.") end end |
#language_eval ⇒ Object
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.
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'cask/dsl.rb', line 278 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 = locale.detect(@language_blocks.keys) next if key.nil? || (language_block = @language_blocks[key]).nil? return @language_eval = language_block.call end @language_eval = language_blocks_default.call end |
#languages ⇒ Object
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.
304 305 306 |
# File 'cask/dsl.rb', line 304 def languages @language_blocks.keys.flatten end |
#livecheck(&block) ⇒ Object
Automatically fetch the latest version of a cask from changelogs.
565 566 567 568 569 570 571 572 573 574 575 576 |
# File 'cask/dsl.rb', line 565 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) no_autobump! because: :extract_plist if @livecheck.strategy == :extract_plist @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.
191 |
# File 'cask/dsl.rb', line 191 def livecheck_defined? = @livecheck_defined |
#livecheckable? ⇒ 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.
Calling #livecheckable? is disabled, use #livecheck_defined? instead.
Whether the cask contains a livecheck
block. This is a legacy alias
for #livecheck_defined?
.
581 582 583 584 |
# File 'cask/dsl.rb', line 581 def livecheckable? odisabled "`livecheckable?`", "`livecheck_defined?`" @livecheck_defined == true end |
#name(*args) ⇒ Object
Multiple names can be specified.
Specifies the cask's name.
Example
name "Visual Studio Code"
207 208 209 210 211 |
# File 'cask/dsl.rb', line 207 def name(*args) return @name if args.empty? @name.concat(args.flatten) end |
#no_autobump!(because:) ⇒ void
limit this method to the official taps only
(e.g. raise an error if !tap.official?
)
This method returns an undefined value.
Excludes the cask from autobump list.
593 594 595 596 597 598 599 600 601 602 603 604 605 |
# File 'cask/dsl.rb', line 593 def no_autobump!(because:) if because.is_a?(Symbol) && !NO_AUTOBUMP_REASONS_LIST.key?(because) raise ArgumentError, "'because' argument should use valid symbol or a string!" end if !@cask.allow_reassignment && @no_autobump_defined raise CaskInvalidError.new(cask, "'no_autobump_defined' stanza may only appear once.") end @no_autobump_defined = true @no_autobump_message = because @autobump = false end |
#no_autobump_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.
Is no_autobump! method defined?
613 614 615 |
# File 'cask/dsl.rb', line 613 def no_autobump_defined? @no_autobump_defined == true end |
#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.
194 |
# File 'cask/dsl.rb', line 194 def on_system_blocks_exist? = @on_system_blocks_exist |
#os(macos: nil, linux: nil) ⇒ String?
481 482 483 484 485 486 487 488 489 |
# File 'cask/dsl.rb', line 481 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_system_conditional(macos:, linux:) end end |
#os_version ⇒ MacOSVersion?
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.
721 722 723 |
# File 'cask/dsl.rb', line 721 def os_version nil 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"
364 365 366 367 368 |
# File 'cask/dsl.rb', line 364 def rename(from = T.unsafe(nil), to = T.unsafe(nil)) return @rename if from.nil? @rename << DSL::Rename.new(T.must(from), T.must(to)) end |
#respond_to_missing? ⇒ 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.
716 717 718 |
# File 'cask/dsl.rb', line 716 def respond_to_missing?(*) true end |
#set_unique_stanza(stanza, should_return) ⇒ Object
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.
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'cask/dsl.rb', line 226 def set_unique_stanza(stanza, should_return) 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"
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'cask/dsl.rb', line 423 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 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 val when String Checksum.new(val) else raise CaskInvalidError.new(cask, "invalid 'sha256' value: #{val.inspect}") end end end |
#staged_path ⇒ Pathname
The staged location for this cask, including version number.
532 533 534 535 536 537 |
# File 'cask/dsl.rb', line 532 def staged_path return @staged_path if @staged_path cask_version = version || :unknown @staged_path = caskroom_path.join(cask_version.to_s) end |
#url(*args, **options) ⇒ Object
Sets the cask's download URL.
Example
url "https://update.code.visualstudio.com/#{version}/#{arch}/stable"
317 318 319 320 321 322 323 |
# File 'cask/dsl.rb', line 317 def url(*args, **) caller_location = T.must(caller_locations).fetch(0) set_unique_stanza(:url, args.empty? && .empty?) do URL.new(*args, **, caller_location:) end end |
#version(arg = nil) ⇒ DSL::Version?
Sets the cask's version.
Example
version "1.88.1"
381 382 383 384 385 386 387 388 389 390 391 |
# File 'cask/dsl.rb', line 381 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 no_autobump! because: :latest_version if arg == :latest DSL::Version.new(arg) end end |