Class: Formulary::FromBottleLoader Private

Inherits:
FormulaLoader show all
Includes:
Utils::Output::Mixin
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 a formula from a bottle.

Instance Attribute Summary

Attributes inherited from FormulaLoader

#alias_path, #name, #path, #tap

Class Method Summary collapse

Instance Method Summary collapse

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 inherited from FormulaLoader

#klass

Methods included from Context

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

Constructor Details

#initialize(bottle_name, warn: false) ⇒ 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:

  • bottle_name (String)
  • warn (Boolean) (defaults to: false)


661
662
663
664
665
# File 'formulary.rb', line 661

def initialize(bottle_name, warn: false)
  @bottle_path = T.let(Pathname(bottle_name).realpath, Pathname)
  name, full_name = Utils::Bottles.resolve_formula_names(@bottle_path)
  super name, Formulary.path(full_name)
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.

Parameters:

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

Returns:

  • (T.attached_class, nil)


652
653
654
655
656
657
658
# File 'formulary.rb', line 652

def self.try_new(ref, from: nil, warn: false)
  return if Homebrew::EnvConfig.forbid_packages_from_paths?

  ref = ref.to_s

  new(ref) if HOMEBREW_BOTTLES_EXTNAME_REGEX.match?(ref) && File.exist?(ref)
end

Instance Method Details

#get_formula(spec, alias_path: nil, force_bottle: false, flags: [], ignore_errors: false) ⇒ Formula

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:

  • spec (Symbol)
  • alias_path (Pathname, String, nil) (defaults to: nil)
  • force_bottle (Boolean) (defaults to: false)
  • flags (Array<String>) (defaults to: [])
  • ignore_errors (Boolean) (defaults to: false)

Returns:



676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
# File 'formulary.rb', line 676

def get_formula(spec, alias_path: nil, force_bottle: false, flags: [], ignore_errors: false)
  formula = begin
    contents = Utils::Bottles.formula_contents(@bottle_path, name:)
    Formulary.from_contents(name, path, contents, spec, force_bottle:,
                            flags:, ignore_errors:)
  rescue FormulaUnreadableError => e
    opoo <<~EOS
      Unreadable formula in #{@bottle_path}:
      #{e}
    EOS
    super
  rescue BottleFormulaUnavailableError => e
    opoo <<~EOS
      #{e}
      Falling back to non-bottle formula.
    EOS
    super
  end
  formula.local_bottle_path = @bottle_path
  formula
end