Class: Formulary::FromPathLoader 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 formulae from disk using a path.

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, #klass

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_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Methods included from Context

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

Constructor Details

#initialize(path, alias_path: nil, tap: 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:



671
672
673
674
675
676
677
678
679
680
# File 'formulary.rb', line 671

def initialize(path, alias_path: nil, tap: nil)
  path = Pathname(path).expand_path
  name = path.basename(".rb").to_s
  alias_path = alias_path&.expand_path
  alias_dir = alias_path&.dirname

  alias_path = nil if alias_dir != tap&.alias_dir

  super(name, path, alias_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.

Parameters:

Returns:



639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
# File 'formulary.rb', line 639

def self.from_path(path)
  path = Pathname(path)
  return unless path.expand_path.exist?

  if (tap = Tap.from_path(path))
    # Only treat symlinks in taps as aliases.
    if path.symlink?
      alias_path = path
      path = Utils::Path.resolved_path(alias_path)
    end
  else
    # Don't treat cache symlinks as aliases.
    tap = Homebrew::API.tap_from_source_download(path)
  end

  return if path.extname != ".rb"

  if path.parent.basename.to_s == ".brew"
    begin
      keg = Keg.for(path)
    rescue NotAKegError
      keg = nil
    end
    if keg && path.realpath == keg/".brew/#{keg.name}.rb"
      return FromKegLoader.new(keg.name, path, tap: keg.tab.tap)
    end
  end

  new(path, alias_path:, tap:)
end

.try_new(_ref, from: nil, warn: false) ⇒ nil

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)
  • from (Symbol, nil) (defaults to: nil)
  • warn (Boolean) (defaults to: false)

Returns:

  • (nil)


631
632
633
634
# File 'formulary.rb', line 631

def self.try_new(_ref, from: nil, warn: false)
  Formulary.odeprecated "Formulary::FromPathLoader.try_new", "Formulary.from_path"
  nil
end