Class: Formulary::FormulaLoader

Inherits:
Object
  • Object
show all
Defined in:
brew/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



104
105
106
107
# File 'brew/Library/Homebrew/formulary.rb', line 104

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

Instance Attribute Details

#alias_pathObject (readonly)

The name used to install the formula



102
103
104
# File 'brew/Library/Homebrew/formulary.rb', line 102

def alias_path
  @alias_path
end

#nameObject (readonly)

The formula’s name



98
99
100
# File 'brew/Library/Homebrew/formulary.rb', line 98

def name
  @name
end

#pathObject (readonly)

The formula’s ruby file’s path or filename



100
101
102
# File 'brew/Library/Homebrew/formulary.rb', line 100

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.



113
114
115
# File 'brew/Library/Homebrew/formulary.rb', line 113

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

#klassObject



117
118
119
120
# File 'brew/Library/Homebrew/formulary.rb', line 117

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