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 def parse_spec spec, tag
case spec case spec
when String when String
if tag && LANGUAGE_MODULES.include?(tag) parse_string_spec(spec, tag)
LanguageModuleDependency.new(tag, spec)
else
Dependency.new(spec, tag)
end
when Symbol when Symbol
parse_symbol_spec(spec, tag) parse_symbol_spec(spec, tag)
when Dependency, Requirement when Dependency, Requirement
spec spec
when Class when Class
if spec < Requirement parse_class_spec(spec, tag)
spec.new(tag)
else
raise "#{spec} is not a Requirement subclass"
end
else else
raise "Unsupported type #{spec.class} for #{spec}" raise "Unsupported type #{spec.class} for #{spec}"
end end
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 def parse_symbol_spec spec, tag
case spec case spec
when :autoconf, :automake, :bsdmake, :libtool, :libltdl when :autoconf, :automake, :bsdmake, :libtool, :libltdl
@ -95,6 +95,14 @@ class DependencyCollector
end end
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) def x11_dep(spec, tag)
if MacOS.version >= :mountain_lion if MacOS.version >= :mountain_lion
Dependency.new(spec.to_s, tag) Dependency.new(spec.to_s, tag)