Class: Cask::CaskLoader::FromURILoader Private
- Inherits:
-
FromPathLoader
- Object
- AbstractContentLoader
- FromPathLoader
- Cask::CaskLoader::FromURILoader
- Defined in:
- cask/cask_loader.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.
Loads a cask from a URI.
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
private
Attributes inherited from FromPathLoader
Attributes inherited from AbstractContentLoader
Class Method Summary collapse
-
.can_load?(ref) ⇒ Boolean
private
Instance Method Summary collapse
-
#initialize(url) ⇒ void
constructor
private
-
#load(config:) ⇒ Object
private
Constructor Details
#initialize(url) ⇒ 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.
154 155 156 157 |
# File 'cask/cask_loader.rb', line 154 def initialize(url) @url = URI(url) super Cache.path/File.basename(T.must(@url.path)) end |
Instance Attribute Details
#url ⇒ 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.
151 152 153 |
# File 'cask/cask_loader.rb', line 151 def url @url end |
Class Method Details
.can_load?(ref) ⇒ 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.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'cask/cask_loader.rb', line 136 def self.can_load?(ref) # Cache compiled regex @uri_regex ||= begin uri_regex = ::URI::DEFAULT_PARSER.make_regexp Regexp.new("\\A#{uri_regex.source}\\Z", uri_regex.) end return false unless ref.to_s.match?(@uri_regex) uri = URI(ref) return false unless uri.path true end |
Instance Method Details
#load(config:) ⇒ 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.
159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'cask/cask_loader.rb', line 159 def load(config:) path.dirname.mkpath begin ohai "Downloading #{url}" ::Utils::Curl.curl_download url, to: path rescue ErrorDuringExecution raise CaskUnavailableError.new(token, "Failed to download #{Formatter.url(url)}.") end super end |