Class: Downloadable Abstract Private
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.
It cannot be directly instantiated. Subclasses must implement the abstract
methods below.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#checksum ⇒ Checksum?
readonly
private
-
#mirrors ⇒ Array<String>
readonly
private
-
#url ⇒ URL?
readonly
private
Instance Method Summary collapse
-
#cached_download ⇒ Pathname
private
-
#clear_cache ⇒ void
private
-
#download_name ⇒ String
private
-
#download_strategy ⇒ T.class_of(AbstractDownloadStrategy)
private
-
#downloaded? ⇒ Boolean
private
-
#downloader ⇒ AbstractDownloadStrategy
private
-
#fetch(verify_download_integrity: true, timeout: nil) ⇒ Pathname
private
-
#freeze ⇒ T.self_type
private
-
#initialize ⇒ void
constructor
private
-
#initialize_dup(other) ⇒ Object
private
-
#verify_download_integrity(filename) ⇒ void
private
-
#version ⇒ Version?
private
Methods included from Context
current, current=, #debug?, #quiet?, #verbose?, #with_context
Constructor Details
#initialize ⇒ 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.
24 25 26 |
# File 'downloadable.rb', line 24 def initialize @mirrors = T.let([], T::Array[String]) end |
Instance Attribute Details
#checksum ⇒ Checksum? (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.
18 19 20 |
# File 'downloadable.rb', line 18 def checksum @checksum end |
#mirrors ⇒ Array<String> (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.
21 22 23 |
# File 'downloadable.rb', line 21 def mirrors @mirrors end |
#url ⇒ URL? (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.
15 16 17 |
# File 'downloadable.rb', line 15 def url @url end |
Instance Method Details
#cached_download ⇒ 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 |
# File 'downloadable.rb', line 49 def cached_download downloader.cached_location end |
#clear_cache ⇒ 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.
54 55 56 |
# File 'downloadable.rb', line 54 def clear_cache downloader.clear_cache 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.
113 114 115 |
# File 'downloadable.rb', line 113 def download_name File.basename(determine_url.to_s) end |
#download_strategy ⇒ T.class_of(AbstractDownloadStrategy)
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.
67 68 69 |
# File 'downloadable.rb', line 67 def download_strategy @download_strategy ||= determine_url&.download_strategy end |
#downloaded? ⇒ 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.
44 45 46 |
# File 'downloadable.rb', line 44 def downloaded? cached_download.exist? end |
#downloader ⇒ AbstractDownloadStrategy
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 75 76 77 78 79 80 |
# File 'downloadable.rb', line 72 def downloader @downloader ||= begin primary_url, *mirrors = determine_url_mirrors raise ArgumentError, "attempted to use a Downloadable without a URL!" if primary_url.blank? download_strategy.new(primary_url, download_name, version, mirrors: mirrors, cache: cache, **T.must(@url).specs) end end |
#fetch(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.
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'downloadable.rb', line 83 def fetch(verify_download_integrity: true, timeout: nil) cache.mkpath begin downloader.fetch(timeout: timeout) rescue ErrorDuringExecution, CurlDownloadStrategyError => e raise DownloadError.new(self, e) end download = cached_download verify_download_integrity(download) if verify_download_integrity download end |
#freeze ⇒ T.self_type
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 41 |
# File 'downloadable.rb', line 36 def freeze @checksum.freeze @mirrors.freeze @version.freeze super end |
#initialize_dup(other) ⇒ 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.
28 29 30 31 32 33 |
# File 'downloadable.rb', line 28 def initialize_dup(other) super @checksum = @checksum.dup @mirrors = @mirrors.dup @version = @version.dup 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.
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'downloadable.rb', line 98 def verify_download_integrity(filename) if filename.file? ohai "Verifying checksum for '#{filename.basename}'" if verbose? filename.verify_checksum(checksum) end rescue ChecksumMissingError opoo <<~EOS Cannot verify integrity of '#{filename.basename}'. No checksum was provided. For your reference, the checksum is: sha256 "#{filename.sha256}" EOS 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.
59 60 61 62 63 64 |
# File 'downloadable.rb', line 59 def version return @version if @version && !@version.null? version = determine_url&.version version unless version&.null? end |