Class: Formulary::TapLoader Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Loads tapped formulae.

Instance Attribute Summary collapse

Attributes inherited from FormulaLoader

#alias_path, #name, #path

Instance Method Summary collapse

Methods inherited from FormulaLoader

#klass

Methods included from Context

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

Constructor Details

#initialize(tapped_name, from: nil) ⇒ TapLoader

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TapLoader.


246
247
248
249
250
# File 'Library/Homebrew/formulary.rb', line 246

def initialize(tapped_name, from: nil)
  warn = ![:keg, :rack].include?(from)
  name, path = formula_name_path(tapped_name, warn: warn)
  super name, path
end

Instance Attribute Details

#tapObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


244
245
246
# File 'Library/Homebrew/formulary.rb', line 244

def tap
  @tap
end

Instance Method Details

#formula_name_path(tapped_name, warn: true) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'Library/Homebrew/formulary.rb', line 252

def formula_name_path(tapped_name, warn: true)
  user, repo, name = tapped_name.split("/", 3).map(&:downcase)
  @tap = Tap.fetch user, repo
  formula_dir = @tap.formula_dir || @tap.path
  path = formula_dir/"#{name}.rb"

  unless path.file?
    if (possible_alias = @tap.alias_dir/name).file?
      path = possible_alias.resolved_path
      name = path.basename(".rb").to_s
    elsif (new_name = @tap.formula_renames[name]) &&
          (new_path = formula_dir/"#{new_name}.rb").file?
      old_name = name
      path = new_path
      name = new_name
      new_name = @tap.core_tap? ? name : "#{@tap}/#{name}"
    elsif (new_tap_name = @tap.tap_migrations[name])
      new_tap_user, new_tap_repo, = new_tap_name.split("/")
      new_tap_name = "#{new_tap_user}/#{new_tap_repo}"
      new_tap = Tap.fetch new_tap_name
      new_tap.install unless new_tap.installed?
      new_tapped_name = "#{new_tap_name}/#{name}"
      name, path = formula_name_path(new_tapped_name, warn: false)
      old_name = tapped_name
      new_name = new_tap.core_tap? ? name : new_tapped_name
    end

    opoo "Use #{new_name} instead of deprecated #{old_name}" if warn && old_name && new_name
  end

  [name, path]
end

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


285
286
287
288
289
290
291
292
293
# File 'Library/Homebrew/formulary.rb', line 285

def get_formula(spec, alias_path: nil, force_bottle: false, flags: [])
  super
rescue FormulaUnreadableError => e
  raise TapFormulaUnreadableError.new(tap, name, e.formula_error), "", e.backtrace
rescue FormulaClassUnavailableError => e
  raise TapFormulaClassUnavailableError.new(tap, name, e.path, e.class_name, e.class_list), "", e.backtrace
rescue FormulaUnavailableError => e
  raise TapFormulaUnavailableError.new(tap, name), "", e.backtrace
end

#load_file(flags:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


295
296
297
298
299
300
# File 'Library/Homebrew/formulary.rb', line 295

def load_file(flags:)
  super
rescue MethodDeprecatedError => e
  e.issues_url = tap.issues_url || tap.to_s
  raise
end