Class: Formulary::FromAPILoader 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.

Load a formula from the API.

Instance Attribute Summary

Attributes inherited from FormulaLoader

#alias_path, #name, #path, #tap

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FormulaLoader

#get_formula

Methods included from Context

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

Constructor Details

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

  • name (String)
  • tap (Tap) (defaults to: T.unsafe(nil))
  • alias_name (String) (defaults to: T.unsafe(nil))


934
935
936
937
938
939
940
941
# File 'formulary.rb', line 934

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

  super(name, Formulary.core_path(name), **options)
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)


906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
# File 'formulary.rb', line 906

def self.try_new(ref, from: T.unsafe(nil), warn: false)
  return if Homebrew::EnvConfig.no_install_from_api?
  return unless ref.is_a?(String)
  return unless (name = ref[HOMEBREW_DEFAULT_TAP_FORMULA_REGEX, :name])
  if !Homebrew::API::Formula.all_formulae.key?(name) &&
     !Homebrew::API::Formula.all_aliases.key?(name) &&
     !Homebrew::API::Formula.all_renames.key?(name)
    return
  end

  alias_name = name

  ref = "#{CoreTap.instance}/#{name}"

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

  name, tap, type = name_tap_type

  options =  if type == :alias
    { alias_name: alias_name.downcase }
  else
    {}
  end

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

Instance Method Details

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



943
944
945
946
# File 'formulary.rb', line 943

def klass(flags:, ignore_errors:)
  load_from_api(flags:) unless Formulary.formula_class_defined_from_api?(name)
  Formulary.formula_class_get_from_api(name)
end