Class: Formulary::FromURILoader Private
- Inherits:
-
FormulaLoader
- Object
- FormulaLoader
- Formulary::FromURILoader
- 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 formula from a URI.
Instance Attribute Summary collapse
- #url ⇒ URI::Generic, String readonly private
Attributes inherited from FormulaLoader
#alias_path, #name, #path, #tap
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(url, from: nil) ⇒ void constructor private
- #load_file(flags:, ignore_errors:) ⇒ void private
Methods inherited from FormulaLoader
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
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.
812 813 814 815 816 817 818 819 820 |
# File 'formulary.rb', line 812 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 ⇒ URI::Generic, 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.
809 810 811 |
# File 'formulary.rb', line 809 def url @url end |
Class Method Details
.try_new(ref, from: nil, 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.
789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 |
# File 'formulary.rb', line 789 def self.try_new(ref, from: nil, 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 return unless uri.scheme.present? new(uri, from:) end |
Instance Method Details
#load_file(flags:, ignore_errors:) ⇒ 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.
This method returns an undefined value.
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 |
# File 'formulary.rb', line 823 def load_file(flags:, ignore_errors:) url_scheme = URI(url).scheme if ALLOWED_URL_SCHEMES.exclude?(url_scheme) raise UnsupportedInstallationMethod, "Non-checksummed download of #{name} formula file from an arbitrary URL is unsupported! " \ "Use `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) Utils::Curl.curl_download url.to_s, to: path super rescue MethodDeprecatedError => e if (match_data = url.to_s.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 |