Extract string and class logic from parse_spec

This commit is contained in:
Jack Nagel 2013-05-06 16:08:49 -05:00
parent 9ec3102e57
commit f47e43aa2b

View File

@ -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)