Class: Cask::Download Private
- Inherits:
-
Downloadable
- Object
- Downloadable
- Cask::Download
- Includes:
- Context
- 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
- #cask ⇒ Object readonly private
Attributes inherited from Downloadable
Instance Method Summary collapse
- #basename ⇒ Object private
- #checksum ⇒ ::Checksum? private
- #download_name ⇒ String private
- #fetch(quiet: nil, verify_download_integrity: true, timeout: nil) ⇒ Pathname private
-
#initialize(cask, quarantine: nil) ⇒ Download
constructor
private
A new instance of Download.
- #time_file_size(timeout: nil) ⇒ Object private
- #url ⇒ ::URL? private
- #verify_download_integrity(filename) ⇒ void private
- #version ⇒ Version? private
Methods included from Context
current, current=, #debug?, #quiet?, #verbose?, #with_context
Methods inherited 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.
16 17 18 19 20 21 |
# File 'cask/download.rb', line 16 def initialize(cask, quarantine: nil) super() @cask = cask @quarantine = quarantine end |
Instance Attribute Details
#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.
14 15 16 |
# File 'cask/download.rb', line 14 def cask @cask end |
Instance Method Details
#basename ⇒ 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.
72 73 74 |
# File 'cask/download.rb', line 72 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.
31 32 33 |
# File 'cask/download.rb', line 31 def checksum @checksum ||= cask.sha256 if cask.sha256 != :no_check end |
#download_name ⇒ 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.
87 88 89 |
# File 'cask/download.rb', line 87 def download_name cask.token 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.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'cask/download.rb', line 49 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 |
#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.
66 67 68 69 70 |
# File 'cask/download.rb', line 66 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.
24 25 26 27 28 |
# File 'cask/download.rb', line 24 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.
77 78 79 80 81 82 83 84 |
# File 'cask/download.rb', line 77 def verify_download_integrity(filename) if @cask.sha256 == :no_check opoo "No checksum defined for cask '#{@cask}', skipping verification." return end super end |
#version ⇒ Version?
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.
36 37 38 39 40 |
# File 'cask/download.rb', line 36 def version return if cask.version.nil? @version ||= Version.new(cask.version) end |