Class: Formulary::FromUrlLoader Private

Inherits:
FormulaLoader show all
Extended by:
T::Sig
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

Attributes inherited from FormulaLoader

#alias_path, #name, #path

Instance Method Summary collapse

Methods inherited from FormulaLoader

#get_formula, #klass

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

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.

Parameters:



268
269
270
271
272
273
# File 'formulary.rb', line 268

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

#urlObject (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.



265
266
267
# File 'formulary.rb', line 265

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.



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'formulary.rb', line 275

def load_file(flags:, ignore_errors:)
  if %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(?:/Formula)?/(?<formula_name>[\w+-.@]+).rb} =~ url
    raise UsageError, "Installation of #{formula_name} from a GitHub commit URL is unsupported! " \
                      "`brew extract #{formula_name}` to a stable tap on GitHub instead."
  elsif url.match?(%r{^(https?|ftp)://})
    raise UsageError, "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 %r{github.com/(?<user>[\w-]+)/(?<repo>[\w-]+)/} =~ url
    e.issues_url = "https://github.com/#{user}/#{repo}/issues/new"
  end
  raise
end