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
- #name ⇒ String readonly private
- #url ⇒ URI::Generic readonly private
Attributes inherited from FromPathLoader
Attributes inherited from AbstractContentLoader
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(url) ⇒ void constructor private
- #load(config:) ⇒ Cask private
Methods inherited from FromPathLoader
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #pretty_upgradable
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.
266 267 268 269 270 271 272 273 |
# File 'cask/cask_loader.rb', line 266 def initialize(url) @url = T.let(URI(url), URI::Generic) url_path = @url.path raise "unexpected nil url.path" unless url_path @name = T.let(File.basename(url_path), String) super Cache.path/name end |
Instance Attribute Details
#name ⇒ 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.
263 264 265 |
# File 'cask/cask_loader.rb', line 263 def name @name end |
#url ⇒ URI::Generic (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.
260 261 262 |
# File 'cask/cask_loader.rb', line 260 def url @url end |
Class Method Details
.try_new(ref, warn: false) ⇒ T.attached_class?
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.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'cask/cask_loader.rb', line 238 def self.try_new(ref, warn: false) return if Homebrew::EnvConfig.forbid_packages_from_paths? # Cache compiled regex @uri_regex ||= T.let( begin uri_regex = ::URI::RFC2396_PARSER.make_regexp Regexp.new("\\A#{uri_regex.source}\\Z", uri_regex.) end, T.nilable(Regexp), ) uri = ref.to_s return unless uri.match?(@uri_regex) uri = URI(uri) return unless uri.path new(uri) end |
Instance Method Details
#load(config:) ⇒ Cask
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.
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'cask/cask_loader.rb', line 276 def load(config:) path.dirname.mkpath if ALLOWED_URL_SCHEMES.exclude?(url.scheme) raise UnsupportedInstallationMethod, "Non-checksummed download of #{name} formula file from an arbitrary URL is unsupported! " \ "`brew version-install` to install a formula file from your own custom tap " \ "instead." end begin ohai "Downloading #{url}" ::Utils::Curl.curl_download url.to_s, to: path rescue ErrorDuringExecution raise CaskUnavailableError.new(token, "Failed to download #{Formatter.url(url)}.") end super end |