Class: Formulary::FromBottleLoader Private
- Inherits:
-
FormulaLoader
- Object
- FormulaLoader
- Formulary::FromBottleLoader
- 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
- #get_formula(spec, alias_path: nil, force_bottle: false, flags: [], ignore_errors: false) ⇒ Formula private
- #initialize(bottle_name) ⇒ void constructor private
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_incompatible, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Methods inherited from FormulaLoader
Methods included from Context
current, current=, #debug?, #deferred_environment_expansion?, #quiet?, #verbose?, #with_context
Constructor Details
#initialize(bottle_name) ⇒ 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.
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'formulary.rb', line 403 def initialize(bottle_name) bottle_path = Pathname(bottle_name).realpath @bottle_path = T.let(bottle_path, Pathname) name, full_name = Utils::Bottles.resolve_formula_names(@bottle_path) tap, = Tap.with_formula_name(full_name) # We might not have tap information with --only-json-tab bottles. # In this scenario we make a best effort guess, assuming Homebrew/core # unless we find it in another tap we have installed. fallback_path = Formulary.path(full_name) tap ||= Tap.from_path(fallback_path) # Mimic a Cellar path to simulate relaxed deprecation behaviour shared with postinstalls. version = Utils::Bottles.resolve_version(@bottle_path) cellar_formula_path = HOMEBREW_CELLAR/name/version/".brew"/"#{name}.rb" @cellar_formula_path = T.let(cellar_formula_path, Pathname) super name, fallback_path, tap: end |
Class Method Details
.from_path(path) ⇒ 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.
397 398 399 400 |
# File 'formulary.rb', line 397 def self.from_path(path) ref = path.to_s new(ref) if HOMEBREW_BOTTLES_EXTNAME_REGEX.match?(ref) && File.exist?(ref) end |
.try_new(ref) ⇒ 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.
391 392 393 |
# File 'formulary.rb', line 391 def self.try_new(ref) from_path(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.
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
# File 'formulary.rb', line 432 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, @cellar_formula_path, contents, spec, tap:, force_bottle:, flags:, ignore_errors:, from_metadata: true) 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 |