From 2bf1f93721fbcd96c6f4799838eaf13596dda513 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Mon, 29 Dec 2014 14:53:22 -0500 Subject: [PATCH] Extract method --- Library/Homebrew/formulary.rb | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index f4fb6bf1b3..3ee8537041 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -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.