mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Extract string and class logic from parse_spec
This commit is contained in:
parent
9ec3102e57
commit
f47e43aa2b
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user