Class: Aws::Cfn::Dsl::Template
- Inherits:
-
TemplateDSL
- Object
- TemplateDSL
- Aws::Cfn::Dsl::Template
- Defined in:
- lib/aws/cfn/dsl/template.rb
Instance Attribute Summary collapse
-
#dict ⇒ Object
readonly
Returns the value of attribute dict.
Instance Method Summary collapse
- #file(b) ⇒ Object
- #hash_refs(line, scope) ⇒ Object
-
#initialize(path = nil, &block) ⇒ Template
constructor
A new instance of Template.
- #mapping(name, options = nil) ⇒ Object
-
#output(name, options = nil) ⇒ Object
def resource_file(p) file “Resources/#p.rb” end.
-
#parameter(name, options = nil) ⇒ Object
def mapping_file(p) file “Mappings/#p.rb” end.
-
#resource(name, options = nil) ⇒ Object
def parameter_file(p) file “Parameters/#p.rb” end.
Constructor Details
#initialize(path = nil, &block) ⇒ Template
Returns a new instance of Template.
17 18 19 20 21 22 |
# File 'lib/aws/cfn/dsl/template.rb', line 17 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 |
Instance Attribute Details
#dict ⇒ Object (readonly)
Returns the value of attribute dict.
11 12 13 |
# File 'lib/aws/cfn/dsl/template.rb', line 11 def dict @dict end |
Instance Method Details
#file(b) ⇒ Object
24 25 26 27 |
# File 'lib/aws/cfn/dsl/template.rb', line 24 def file(b) block = File.read File.join(@path,b) eval block end |
#hash_refs(line, scope) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/aws/cfn/dsl/template.rb', line 73 def hash_refs(line,scope) match = line.match %r/^(.*?)(\{\s*:\S+\s*=>.*?\}|\{\s*\S+:\s*.*?\})(.*)$/ if match h = nil eval "h = #{match[2]}", binding k = h.keys[0] v = h.delete(k) v = if v.is_a?Array v.map{|e| e.to_s } else v.to_s end h[k.to_s] = v scope[:logger].debug h [match[1], h, hash_refs(match[3],scope) ] else "#{line}\n" end end |
#mapping(name, options = nil) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/aws/cfn/dsl/template.rb', line 29 def mapping(name, =nil) if .nil? file "Mappings/#{name}.rb" else super(name,) end end |
#output(name, options = nil) ⇒ Object
def resource_file(p)
file "Resources/#{p}.rb"
end
65 66 67 68 69 70 71 |
# File 'lib/aws/cfn/dsl/template.rb', line 65 def output(name, =nil) if .nil? file "Outputs/#{name}.rb" else super(name,) end end |
#parameter(name, options = nil) ⇒ Object
def mapping_file(p)
file "Mappings/#{p}.rb"
end
41 42 43 44 45 46 47 |
# File 'lib/aws/cfn/dsl/template.rb', line 41 def parameter(name, =nil) if .nil? file "Parameters/#{name}.rb" else super(name,) end end |
#resource(name, options = nil) ⇒ Object
def parameter_file(p)
file "Parameters/#{p}.rb"
end
53 54 55 56 57 58 59 |
# File 'lib/aws/cfn/dsl/template.rb', line 53 def resource(name, =nil) if .nil? file "Resources/#{name}.rb" else super(name,) end end |