Class: Cask::CaskLoader::FromURILoader Private
- Inherits:
-
FromPathLoader
- Object
- FromContentLoader
- FromPathLoader
- Cask::CaskLoader::FromURILoader
- Defined in:
- Library/Homebrew/cask/cask_loader.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Loads a cask from a URI.
Instance Attribute Summary collapse
- #url ⇒ Object readonly private
Attributes inherited from FromPathLoader
Attributes inherited from FromContentLoader
Class Method Summary collapse
- .can_load?(ref) ⇒ Boolean private
Instance Method Summary collapse
-
#initialize(url) ⇒ FromURILoader
constructor
private
A new instance of FromURILoader.
- #load(config:) ⇒ Object private
Constructor Details
#initialize(url) ⇒ FromURILoader
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of FromURILoader.
106 107 108 109 |
# File 'Library/Homebrew/cask/cask_loader.rb', line 106 def initialize(url) @url = URI(url) super Cache.path/File.basename(@url.path) end |
Instance Attribute Details
#url ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
104 105 106 |
# File 'Library/Homebrew/cask/cask_loader.rb', line 104 def url @url end |
Class Method Details
.can_load?(ref) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
93 94 95 96 97 98 99 100 101 102 |
# File 'Library/Homebrew/cask/cask_loader.rb', line 93 def self.can_load?(ref) uri_regex = ::URI::DEFAULT_PARSER.make_regexp return false unless ref.to_s.match?(Regexp.new("\\A#{uri_regex.source}\\Z", uri_regex.)) uri = URI(ref) return false unless uri return false unless uri.path true end |
Instance Method Details
#load(config:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'Library/Homebrew/cask/cask_loader.rb', line 111 def load(config:) path.dirname.mkpath begin ohai "Downloading #{url}." curl_download url, to: path rescue ErrorDuringExecution raise CaskUnavailableError.new(token, "Failed to download #{Formatter.url(url)}.") end super end |