Handle legacy options in the method_added hook

We only need to process the legacy options at load time, not each time
the class is instantiated, and only when there is an options method
defined.
This commit is contained in:
Jack Nagel 2014-08-10 21:45:23 -05:00
parent f306e56d21
commit d122ae8eea
2 changed files with 8 additions and 8 deletions

View File

@ -37,7 +37,6 @@ class Formula
@active_spec = determine_active_spec(spec) @active_spec = determine_active_spec(spec)
validate_attributes :url, :name, :version validate_attributes :url, :name, :version
active_spec.add_legacy_options(options)
@pkg_version = PkgVersion.new(version, revision) @pkg_version = PkgVersion.new(version, revision)
@pin = FormulaPin.new(self) @pin = FormulaPin.new(self)
end end
@ -213,9 +212,6 @@ class Formula
# tell the user about any caveats regarding this package, return a string # tell the user about any caveats regarding this package, return a string
def caveats; nil end def caveats; nil end
# any e.g. configure options for this package
def options; [] end
# Deprecated # Deprecated
DATA = :DATA DATA = :DATA
def patches; {} end def patches; {} end
@ -592,6 +588,14 @@ class Formula
raise "You cannot override Formula#brew in class #{name}" raise "You cannot override Formula#brew in class #{name}"
when :test when :test
@test_defined = true @test_defined = true
when :options
instance = allocate
specs.each do |spec|
instance.options.each do |opt, desc|
spec.options << Option.new(opt[/^--(.+)$/, 1], desc)
end
end
end end
end end

View File

@ -127,10 +127,6 @@ class SoftwareSpec
options << Option.new("without-#{name}", "Build without #{name} support") options << Option.new("without-#{name}", "Build without #{name} support")
end end
end end
def add_legacy_options(list)
list.each { |opt, desc| options << Option.new(opt[/^--(.+)$/, 1], desc) }
end
end end
class HeadSoftwareSpec < SoftwareSpec class HeadSoftwareSpec < SoftwareSpec