Module: Homebrew::API::CaskDownload Private

Defined in:
api/cask_download.rb

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

Class Method Summary collapse

Class Method Details

.download(token:, cask_struct:, languages: nil, quarantine: nil, require_sha: false) ⇒ ::Cask::Download?

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:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'api/cask_download.rb', line 20

def self.download(token:, cask_struct:, languages: nil, quarantine: nil, require_sha: false)
  languages ||= cask_struct.languages.empty? ? [] : ::Cask::Config.new.languages
  cask_struct = cask_struct.localise(languages)
  return if cask_struct.languages.any? && cask_struct.language_variations.empty?
  return if cask_struct.url_args.empty?

  cask = ::Cask::Cask.new(
    token,
    tap:                      CoreCaskTap.instance,
    loaded_from_api:          true,
    loaded_from_internal_api: true,
  ) do
    version cask_struct.version
    sha256 cask_struct.sha256
    url(*cask_struct.url_args, **cask_struct.url_kwargs)
    homepage cask_struct.homepage if cask_struct.homepage?
    if cask_struct.container?
      container(nested: cask_struct.container_args[:nested], type: cask_struct.container_args[:type])
    end
    # Staging (and the download queue's pre-staging) performs rename
    # operations through this cask, so they must be preserved here.
    cask_struct.renames.each do |from, to|
      rename from, to
    end
  end

  ::Cask::Download.new(cask, quarantine:, require_sha:)
end