Class: Formulary::FromUrlLoader Private
- Inherits:
-
FormulaLoader
- Object
- FormulaLoader
- Formulary::FromUrlLoader
- Defined in:
- Library/Homebrew/formulary.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 formulae from URLs.
Instance Attribute Summary collapse
- #url ⇒ Object readonly private
Attributes inherited from FormulaLoader
Instance Method Summary collapse
-
#initialize(url) ⇒ FromUrlLoader
constructor
private
A new instance of FromUrlLoader.
- #load_file(flags:) ⇒ Object private
Methods inherited from FormulaLoader
Methods included from Context
current, current=, #debug?, #quiet?, #verbose?, #with_context
Constructor Details
#initialize(url) ⇒ FromUrlLoader
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 FromUrlLoader.
213 214 215 216 217 218 |
# File 'Library/Homebrew/formulary.rb', line 213 def initialize(url) @url = url uri = URI(url) formula = File.basename(uri.path, ".rb") super formula, HOMEBREW_CACHE_FORMULA/File.basename(uri.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.
211 212 213 |
# File 'Library/Homebrew/formulary.rb', line 211 def url @url end |
Instance Method Details
#load_file(flags:) ⇒ 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.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'Library/Homebrew/formulary.rb', line 220 def load_file(flags:) if %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(?:/Formula)?/(?<formula_name>[\[email protected]]+).rb} =~ url # rubocop:disable Style/CaseLikeIf odisabled "Installation of #{formula_name} from a GitHub commit URL", "'brew extract #{formula_name}' to stable tap on GitHub" elsif url.match?(%r{^(https?|ftp)://}) odisabled "Non-checksummed download of #{name} formula file from an arbitrary URL", "'brew extract' or 'brew create' and 'brew tap-new' to create a "\ "formula file in a tap on GitHub" end HOMEBREW_CACHE_FORMULA.mkpath FileUtils.rm_f(path) curl_download url, to: path super rescue MethodDeprecatedError => e if %r{github.com/(?<user>[\w-]+)/(?<repo>[\w-]+)/} =~ url e.issues_url = "https://github.com/#{user}/#{repo}/issues/new" end raise end |