class Aws::Cfn::Dsl::Template
Attributes
dict[R]
Public Class Methods
new(path=nil,&block)
click to toggle source
Calls superclass method
# File lib/aws/cfn/dsl/template.rb, line 15 def initialize(path=nil,&block) @path = path || File.dirname(caller[2].split(%r'\s+').shift.split(':')[0]) super() do # We do nothing with the template for now end end
Public Instance Methods
file(b)
click to toggle source
# File lib/aws/cfn/dsl/template.rb, line 22 def file(b) block = File.read File.join(@path,b) eval block end
hash_refs(line,scope)
click to toggle source
# File lib/aws/cfn/dsl/template.rb, line 71 def hash_refs(line,scope) block_regex = %r/\{\s*:\S+\s*=>.*?\}|\{\s*\S+:\s*.*?\}/ match = line.match %r/^(\s*[^#].*?)(#{block_regex})(.*)$/ if match left = match[1] code = match[2] tail = match[3] while true lbraces = code.gsub(%r/[^{]+/, '') rbraces = code.gsub(%r/[^}]+/, '') if lbraces.size != rbraces.size nest = tail.match %r/^(.*?\})(.*)$/ if nest code += nest[1] tail = nest[2] else abort! "Mismatched {}'s" end else break end end h = nil eval "h = #{code}", binding k = h.keys[0] v = h.delete(k) v = scope[:compiler].sym_to_s(v) h[k.to_s] = v scope[:logger].debug h [left, h, tail.size > 0 ? hash_refs(tail,scope) : tail ] else "#{line}\n" end end
mapping(name, options=nil)
click to toggle source
Calls superclass method
# File lib/aws/cfn/dsl/template.rb, line 27 def mapping(name, options=nil) if options.nil? file "Mappings/#{name}.rb" else super(name,options) end end
output(name, options=nil)
click to toggle source
def resource_file(p)
file "Resources/#{p}.rb"
end
Calls superclass method
# File lib/aws/cfn/dsl/template.rb, line 63 def output(name, options=nil) if options.nil? file "Outputs/#{name}.rb" else super(name,options) end end
parameter(name, options=nil)
click to toggle source
def mapping_file(p)
file "Mappings/#{p}.rb"
end
Calls superclass method
# File lib/aws/cfn/dsl/template.rb, line 39 def parameter(name, options=nil) if options.nil? file "Parameters/#{name}.rb" else super(name,options) end end
resource(name, options=nil)
click to toggle source
def parameter_file(p)
file "Parameters/#{p}.rb"
end
Calls superclass method
# File lib/aws/cfn/dsl/template.rb, line 51 def resource(name, options=nil) if options.nil? file "Resources/#{name}.rb" else super(name,options) end end