Class: Cask::Download Private
- 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
- #cask ⇒ ::Cask::Cask readonly private
Attributes included from Downloadable
Instance Method Summary collapse
- #basename ⇒ Pathname private
- #checksum ⇒ ::Checksum? private
- #download_name ⇒ String private
- #download_type ⇒ String private
- #fetch(quiet: nil, verify_download_integrity: true, timeout: nil) ⇒ Pathname private
- #initialize(cask, quarantine: nil) ⇒ void constructor private
- #name ⇒ String private
- #time_file_size(timeout: nil) ⇒ Array<([Time, nil], Integer)> 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 included from Downloadable
#cached_download, #clear_cache, #download_strategy, #downloaded?, #downloader, #freeze, #initialize_dup
Constructor Details
#initialize(cask, quarantine: nil) ⇒ 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.
20 21 22 23 24 25 |
# File 'cask/download.rb', line 20 def initialize(cask, quarantine: nil) super() @cask = cask @quarantine = quarantine end |
Instance Attribute Details
#cask ⇒ ::Cask::Cask (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.
17 18 19 |
# File 'cask/download.rb', line 17 def cask @cask end |
Instance Method Details
#basename ⇒ 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.
83 84 85 |
# File 'cask/download.rb', line 83 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.
40 41 42 |
# File 'cask/download.rb', line 40 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.
98 99 100 |
# File 'cask/download.rb', line 98 def download_name cask.token end |
#download_type ⇒ 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.
103 104 105 |
# File 'cask/download.rb', line 103 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.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'cask/download.rb', line 58 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 |
#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.
28 29 30 |
# File 'cask/download.rb', line 28 def name cask.token end |
#time_file_size(timeout: nil) ⇒ Array<([Time, nil], Integer)>
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.
76 77 78 79 80 |
# File 'cask/download.rb', line 76 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.
33 34 35 36 37 |
# File 'cask/download.rb', line 33 def url return if (cask_url = 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.
88 89 90 91 92 93 94 95 |
# File 'cask/download.rb', line 88 def verify_download_integrity(filename) if no_checksum_defined? && !official_cask_tap? 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.
45 46 47 48 49 |
# File 'cask/download.rb', line 45 def version return if cask.version.nil? @version ||= Version.new(cask.version) end |