Track initialized specs

This commit is contained in:
Jack Nagel 2013-09-17 21:25:39 -05:00
parent 6116450328
commit 360a099faa

View File

@ -644,45 +644,55 @@ class Formula
Checksum::TYPES.each do |cksum| Checksum::TYPES.each do |cksum|
class_eval <<-EOS, __FILE__, __LINE__ + 1 class_eval <<-EOS, __FILE__, __LINE__ + 1
def #{cksum}(val) def #{cksum}(val)
@stable ||= SoftwareSpec.new @stable ||= create_spec(SoftwareSpec)
@stable.#{cksum}(val) @stable.#{cksum}(val)
end end
EOS EOS
end end
def specs
@specs ||= []
end
def create_spec(klass)
spec = klass.new
specs << spec
spec
end
def build def build
@build ||= BuildOptions.new(ARGV.options_only) @build ||= BuildOptions.new(ARGV.options_only)
end end
def url val, specs={} def url val, specs={}
@stable ||= SoftwareSpec.new @stable ||= create_spec(SoftwareSpec)
@stable.url(val, specs) @stable.url(val, specs)
end end
def stable &block def stable &block
return @stable unless block_given? return @stable unless block_given?
@stable ||= SoftwareSpec.new @stable ||= create_spec(SoftwareSpec)
@stable.instance_eval(&block) @stable.instance_eval(&block)
end end
def bottle *, &block def bottle *, &block
return @bottle unless block_given? return @bottle unless block_given?
@bottle ||= Bottle.new @bottle ||= create_spec(Bottle)
@bottle.instance_eval(&block) @bottle.instance_eval(&block)
end end
def devel &block def devel &block
return @devel unless block_given? return @devel unless block_given?
@devel ||= SoftwareSpec.new @devel ||= create_spec(SoftwareSpec)
@devel.instance_eval(&block) @devel.instance_eval(&block)
end end
def head val=nil, specs={}, &block def head val=nil, specs={}, &block
if block_given? if block_given?
@head ||= HeadSoftwareSpec.new @head ||= create_spec(HeadSoftwareSpec)
@head.instance_eval(&block) @head.instance_eval(&block)
elsif val elsif val
@head ||= HeadSoftwareSpec.new @head ||= create_spec(HeadSoftwareSpec)
@head.url(val, specs) @head.url(val, specs)
else else
@head @head
@ -690,18 +700,18 @@ class Formula
end end
def version val=nil def version val=nil
@stable ||= SoftwareSpec.new @stable ||= create_spec(SoftwareSpec)
@stable.version(val) @stable.version(val)
end end
def mirror val def mirror val
@stable ||= SoftwareSpec.new @stable ||= create_spec(SoftwareSpec)
@stable.mirror(val) @stable.mirror(val)
end end
# Define a named resource using a SoftwareSpec style block # Define a named resource using a SoftwareSpec style block
def resource name, &block def resource name, &block
@stable ||= SoftwareSpec.new @stable ||= create_spec(SoftwareSpec)
@stable.resource(name, &block) @stable.resource(name, &block)
end end