From f47e43aa2ba6ff772b13db62ea2c321ea513516f Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Mon, 6 May 2013 16:08:49 -0500 Subject: [PATCH] Extract string and class logic from parse_spec --- Library/Homebrew/dependency_collector.rb | 28 +++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index e53b8da0a4..69e5978c3c 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -51,26 +51,26 @@ class DependencyCollector def parse_spec spec, tag case spec when String - if tag && LANGUAGE_MODULES.include?(tag) - LanguageModuleDependency.new(tag, spec) - else - Dependency.new(spec, tag) - end + parse_string_spec(spec, tag) when Symbol parse_symbol_spec(spec, tag) when Dependency, Requirement spec when Class - if spec < Requirement - spec.new(tag) - else - raise "#{spec} is not a Requirement subclass" - end + parse_class_spec(spec, tag) else raise "Unsupported type #{spec.class} for #{spec}" end end + def parse_string_spec(spec, tag) + if tag && LANGUAGE_MODULES.include?(tag) + LanguageModuleDependency.new(tag, spec) + else + Dependency.new(spec, tag) + end + end + def parse_symbol_spec spec, tag case spec when :autoconf, :automake, :bsdmake, :libtool, :libltdl @@ -95,6 +95,14 @@ class DependencyCollector end end + def parse_class_spec(spec, tag) + if spec < Requirement + spec.new(tag) + else + raise "#{spec} is not a Requirement subclass" + end + end + def x11_dep(spec, tag) if MacOS.version >= :mountain_lion Dependency.new(spec.to_s, tag)