Class: AbstractDownloadStrategy 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.
Abstract superclass for all download strategies.
Direct Known Subclasses
Defined Under Namespace
Modules: Pourable
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
private
-
#cached_location ⇒ Pathname
readonly
Location of the cached download.
-
#source_modified_time ⇒ Time
readonly
Returns the most recent modified time for all files in the current working directory after stage.
-
#url ⇒ String
readonly
The download URL.
Instance Method Summary collapse
-
#basename ⇒ Object
private
-
#clear_cache ⇒ Object
Remove #cached_location and any other files associated with the resource from the cache.
-
#fetch(timeout: nil) ⇒ Object
Download and cache the resource at #cached_location.
-
#initialize(url, name, version, **meta) ⇒ AbstractDownloadStrategy
constructor
private
A new instance of AbstractDownloadStrategy.
-
#quiet! ⇒ void
Disable any output during downloading.
-
#quiet? ⇒ Boolean
private
-
#shutup! ⇒ void
deprecated
private
Deprecated.
-
#stage(&block) ⇒ Object
Unpack #cached_location into the current working directory.
Methods included from Context
current, current=, #debug?, #verbose?, #with_context
Constructor Details
#initialize(url, name, version, **meta) ⇒ 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.
Returns a new instance of AbstractDownloadStrategy.
60 61 62 63 64 65 66 67 68 |
# File 'download_strategy.rb', line 60 def initialize(url, name, version, **) @url = url @name = name @version = version @cache = .fetch(:cache, HOMEBREW_CACHE) @meta = @quiet = false extend Pourable if [:bottle] end |
Instance Attribute Details
#cache ⇒ 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.
56 57 58 |
# File 'download_strategy.rb', line 56 def cache @cache end |
#cached_location ⇒ Pathname (readonly)
Location of the cached download.
54 55 56 |
# File 'download_strategy.rb', line 54 def cached_location @cached_location end |
#source_modified_time ⇒ Time (readonly)
Returns the most recent modified time for all files in the current working directory after stage.
138 139 140 |
# File 'download_strategy.rb', line 138 def source_modified_time Pathname.pwd.to_enum(:find).select(&:file?).map(&:mtime).max end |
#url ⇒ String (readonly)
The download URL.
48 49 50 |
# File 'download_strategy.rb', line 48 def url @url 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.
150 151 152 |
# File 'download_strategy.rb', line 150 def basename cached_location.basename end |
#clear_cache ⇒ Object
Remove #cached_location and any other files associated with the resource from the cache.
146 147 148 |
# File 'download_strategy.rb', line 146 def clear_cache rm_rf(cached_location) end |
#fetch(timeout: nil) ⇒ Object
Download and cache the resource at #cached_location.
73 |
# File 'download_strategy.rb', line 73 def fetch(timeout: nil); end |
#quiet! ⇒ void
This method returns an undefined value.
Disable any output during downloading.
79 80 81 |
# File 'download_strategy.rb', line 79 def quiet! @quiet = true end |
#quiet? ⇒ 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.
93 94 95 |
# File 'download_strategy.rb', line 93 def quiet? Context.current.quiet? || @quiet end |
#shutup! ⇒ 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.
Disable any output during downloading.
88 89 90 91 |
# File 'download_strategy.rb', line 88 def shutup! # odeprecated "AbstractDownloadStrategy#shutup!", "AbstractDownloadStrategy#quiet!" quiet! end |
#stage(&block) ⇒ Object
Unpack #cached_location into the current working directory.
Additionally, if a block is given, the working directory was previously empty and a single directory is extracted from the archive, the block will be called with the working directory changed to that directory. Otherwise this method will return, or the block will be called, without changing the current working directory.
106 107 108 109 110 111 112 113 114 |
# File 'download_strategy.rb', line 106 def stage(&block) UnpackStrategy.detect(cached_location, prioritize_extension: true, ref_type: @ref_type, ref: @ref) .extract_nestedly(basename: basename, prioritize_extension: true, verbose: verbose? && !quiet?) chdir(&block) if block end |