Class: Cask::Download Private

Inherits:
Object show all
Includes:
Context, Downloadable
Defined in:
cask/download.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.

A download corresponding to a Cask.

Instance Attribute Summary collapse

Attributes included from Downloadable

#mirrors

Instance Method Summary collapse

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

Methods included from Downloadable

#cached_download, #clear_cache, #download_strategy, #downloaded?, #downloader, #freeze, #initialize_dup

Constructor Details

#initialize(cask, quarantine: nil) ⇒ 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.

Returns a new instance of Download.



18
19
20
21
22
23
# File 'cask/download.rb', line 18

def initialize(cask, quarantine: nil)
  super()

  @cask = cask
  @quarantine = quarantine
end

Instance Attribute Details

#caskObject (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.



16
17
18
# File 'cask/download.rb', line 16

def cask
  @cask
end

Instance Method Details

#basenameObject

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.



79
80
81
# File 'cask/download.rb', line 79

def basename
  downloader.basename
end

#checksum::Checksum?

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:



38
39
40
# File 'cask/download.rb', line 38

def checksum
  @checksum ||= cask.sha256 if cask.sha256 != :no_check
end

#download_nameString

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:



94
95
96
# File 'cask/download.rb', line 94

def download_name
  cask.token
end

#download_typeString

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:



99
100
101
# File 'cask/download.rb', line 99

def download_type
  "cask"
end

#fetch(quiet: nil, verify_download_integrity: true, timeout: nil) ⇒ 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.

Parameters:

  • quiet (Boolean, nil) (defaults to: nil)
  • verify_download_integrity (Boolean) (defaults to: true)
  • timeout (Integer, Float, nil) (defaults to: nil)

Returns:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'cask/download.rb', line 56

def fetch(quiet: nil, verify_download_integrity: true, timeout: nil)
  downloader.quiet! if quiet

  begin
    super(verify_download_integrity: false, timeout:)
  rescue DownloadError => e
    error = CaskError.new("Download failed on Cask '#{cask}' with message: #{e.cause}")
    error.set_backtrace e.backtrace
    raise error
  end

  downloaded_path = cached_download
  quarantine(downloaded_path)
  self.verify_download_integrity(downloaded_path) if verify_download_integrity
  downloaded_path
end

#nameString

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:



26
27
28
# File 'cask/download.rb', line 26

def name
  cask.token
end

#time_file_size(timeout: nil) ⇒ 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.

Raises:

  • (ArgumentError)


73
74
75
76
77
# File 'cask/download.rb', line 73

def time_file_size(timeout: nil)
  raise ArgumentError, "not supported for this download strategy" unless downloader.is_a?(CurlDownloadStrategy)

  T.cast(downloader, CurlDownloadStrategy).resolved_time_file_size(timeout:)
end

#url::URL?

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:



31
32
33
34
35
# File 'cask/download.rb', line 31

def url
  return if cask.url.nil?

  @url ||= ::URL.new(cask.url.to_s, cask.url.specs)
end

#verify_download_integrity(filename) ⇒ 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:



84
85
86
87
88
89
90
91
# File 'cask/download.rb', line 84

def verify_download_integrity(filename)
  if @cask.sha256 == :no_check
    opoo "No checksum defined for cask '#{@cask}', skipping verification."
    return
  end

  super
end

#versionVersion?

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:



43
44
45
46
47
# File 'cask/download.rb', line 43

def version
  return if cask.version.nil?

  @version ||= Version.new(cask.version)
end