mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Extract method
This commit is contained in:
parent
4d584d37f7
commit
2bf1f93721
@ -59,19 +59,7 @@ class Formulary
|
||||
raise FormulaUnavailableError.new(name)
|
||||
end
|
||||
|
||||
unless have_klass
|
||||
STDERR.puts "#{$0} (#{self.class.name}): loading #{path}" if ARGV.debug?
|
||||
begin
|
||||
require path
|
||||
rescue NoMethodError
|
||||
# This is a programming error in an existing formula, and should not
|
||||
# have a "no such formula" message.
|
||||
raise
|
||||
rescue LoadError, NameError
|
||||
raise if ARGV.debug? # let's see the REAL error
|
||||
raise FormulaUnavailableError.new(name)
|
||||
end
|
||||
end
|
||||
load_file unless have_klass
|
||||
|
||||
klass = Formulary.get_formula_class(class_name)
|
||||
if klass == Formula || !(klass < Formula)
|
||||
@ -79,6 +67,22 @@ class Formulary
|
||||
end
|
||||
klass
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_file
|
||||
STDERR.puts "#{$0} (#{self.class.name}): loading #{path}" if ARGV.debug?
|
||||
begin
|
||||
require(path)
|
||||
rescue NoMethodError
|
||||
# This is a programming error in an existing formula, and should not
|
||||
# have a "no such formula" message.
|
||||
raise
|
||||
rescue LoadError, NameError
|
||||
raise if ARGV.debug? # let's see the REAL error
|
||||
raise FormulaUnavailableError.new(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Loads formulae from bottles.
|
||||
|
Loading…
x
Reference in New Issue
Block a user