Class: Formulary::FromTapLoader Private

Inherits:
FormulaLoader show all
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 tapped formulae.

Direct Known Subclasses

FromNameLoader

Instance Attribute Summary collapse

Attributes inherited from FormulaLoader

#alias_path, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FormulaLoader

#klass

Methods included from Context

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

Constructor Details

#initialize(name, path, tap:, alias_name: T.unsafe(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.

Parameters:



784
785
786
787
788
789
790
791
# File 'formulary.rb', line 784

def initialize(name, path, tap:, alias_name: T.unsafe(nil))
  options = {
    alias_path: (tap.alias_dir/alias_name if alias_name),
    tap:,
  }.compact

  super(name, path, **options)
end

Instance Attribute Details

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

Returns:



759
760
761
# File 'formulary.rb', line 759

def path
  @path
end

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

Returns:



756
757
758
# File 'formulary.rb', line 756

def tap
  @tap
end

Class Method Details

.try_new(ref, from: T.unsafe(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.

Parameters:

  • ref (String, Pathname, URI::Generic)
  • from (Symbol) (defaults to: T.unsafe(nil))
  • warn (Boolean) (defaults to: false)

Returns:

  • (T.attached_class, nil)


765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
# File 'formulary.rb', line 765

def self.try_new(ref, from: T.unsafe(nil), warn: false)
  ref = ref.to_s

  return unless (name_tap_type = Formulary.tap_formula_name_type(ref, warn:))

  name, tap, type = name_tap_type
  path = Formulary.find_formula_in_tap(name, tap)

  options = if type == :alias
    # TODO: Simplify this by making `tap_formula_name_type` return the alias name.
    { alias_name: T.must(ref[HOMEBREW_TAP_FORMULA_REGEX, :name]).downcase }
  else
    {}
  end

  new(name, path, tap:, **options)
end

Instance Method Details

#get_formula(spec, alias_path: nil, force_bottle: false, flags: [], ignore_errors: false) ⇒ 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.



793
794
795
796
797
798
799
800
801
# File 'formulary.rb', line 793

def get_formula(spec, alias_path: nil, force_bottle: false, flags: [], ignore_errors: false)
  super
rescue FormulaUnreadableError => e
  raise TapFormulaUnreadableError.new(tap, name, e.formula_error), "", e.backtrace
rescue FormulaClassUnavailableError => e
  raise TapFormulaClassUnavailableError.new(tap, name, e.path, e.class_name, e.class_list), "", e.backtrace
rescue FormulaUnavailableError => e
  raise TapFormulaUnavailableError.new(tap, name), "", e.backtrace
end

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



803
804
805
806
807
808
# File 'formulary.rb', line 803

def load_file(flags:, ignore_errors:)
  super
rescue MethodDeprecatedError => e
  e.issues_url = tap.issues_url || tap.to_s
  raise
end