Class: Formulary::FormulaLoader

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/formulary.rb

Overview

A FormulaLoader returns instances of formulae. Subclasses implement loaders for particular sources of formulae.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, path) ⇒ FormulaLoader

Returns a new instance of FormulaLoader



79
80
81
82
# File 'Library/Homebrew/formulary.rb', line 79

def initialize(name, path)
  @name = name
  @path = path.resolved_path
end

Instance Attribute Details

#alias_pathObject (readonly)

The name used to install the formula



77
78
79
# File 'Library/Homebrew/formulary.rb', line 77

def alias_path
  @alias_path
end

#nameObject (readonly)

The formula's name



73
74
75
# File 'Library/Homebrew/formulary.rb', line 73

def name
  @name
end

#pathObject (readonly)

The formula's ruby file's path or filename



75
76
77
# File 'Library/Homebrew/formulary.rb', line 75

def path
  @path
end

Instance Method Details

#get_formula(spec, alias_path: nil) ⇒ Object

Gets the formula instance.

`alias_path` can be overridden here in case an alias was used to refer to a formula that was loaded in another way.



88
89
90
# File 'Library/Homebrew/formulary.rb', line 88

def get_formula(spec, alias_path: nil)
  klass.new(name, path, spec, alias_path: alias_path || self.alias_path)
end

#klassObject



92
93
94
95
# File 'Library/Homebrew/formulary.rb', line 92

def klass
  load_file unless Formulary.formula_class_defined?(path)
  Formulary.formula_class_get(path)
end