Class: Formulary::FromUrlLoader Private
- Inherits:
-
FormulaLoader
- Object
- FormulaLoader
- Formulary::FromUrlLoader
- Defined in:
- formulary.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 formulae from URLs.
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
private
Attributes inherited from FormulaLoader
#alias_path, #name, #path, #tap
Instance Method Summary collapse
-
#initialize(url, from: nil) ⇒ void
constructor
private
-
#load_file(flags:, ignore_errors:) ⇒ Object
private
Methods inherited from FormulaLoader
Methods included from Context
current, current=, #debug?, #quiet?, #verbose?, #with_context
Constructor Details
#initialize(url, from: nil) ⇒ 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.
523 524 525 526 527 528 529 530 531 |
# File 'formulary.rb', line 523 def initialize(url, from: nil) @url = url @from = from uri_path = URI(url).path raise ArgumentError, "URL has no path component" unless uri_path 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. 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.
520 521 522 |
# File 'formulary.rb', line 520 def url @url end |
Instance Method Details
#load_file(flags:, ignore_errors:) ⇒ 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.
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
# File 'formulary.rb', line 533 def load_file(flags:, ignore_errors:) match = url.match(%r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(?:/Formula)?/(?<name>[\w+-.@]+).rb}) if match raise UnsupportedInstallationMethod, "Installation of #{match[:name]} from a GitHub commit URL is unsupported! " \ "`brew extract #{match[:name]}` to a stable tap on GitHub instead." elsif url.match?(%r{^(https?|ftp)://}) raise UnsupportedInstallationMethod, "Non-checksummed download of #{name} formula file from an arbitrary URL is unsupported! " \ "`brew extract` or `brew create` and `brew tap-new` to create a formula file in a tap " \ "on GitHub instead." end HOMEBREW_CACHE_FORMULA.mkpath FileUtils.rm_f(path) curl_download url, to: path super rescue MethodDeprecatedError => e if (match_data = url.match(%r{github.com/(?<user>[\w-]+)/(?<repo>[\w-]+)/}).presence) e.issues_url = "https://github.com/#{match_data[:user]}/#{match_data[:repo]}/issues/new" end raise end |