Class: Lono::Output::Template
- Inherits:
-
Object
- Object
- Lono::Output::Template
- Extended by:
- Memoist
- Defined in:
- lib/lono/output/template.rb
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(blueprint, template) ⇒ Template
constructor
A new instance of Template.
- #optional_parameters ⇒ Object
- #parameter_groups ⇒ Object
- #parameters ⇒ Object
- #required_parameters ⇒ Object
Constructor Details
#initialize(blueprint, template) ⇒ Template
Returns a new instance of Template.
5 6 7 |
# File 'lib/lono/output/template.rb', line 5 def initialize(blueprint, template) @blueprint, @template = blueprint, template end |
Instance Method Details
#data ⇒ Object
32 33 34 35 36 |
# File 'lib/lono/output/template.rb', line 32 def data template_path = "#{Lono.config.output_path}/#{@blueprint}/templates/#{@template}.yml" check_template_exists!(template_path) YAML.load(IO.read(template_path)) end |
#optional_parameters ⇒ Object
13 14 15 |
# File 'lib/lono/output/template.rb', line 13 def optional_parameters parameters.reject { |logical_id, p| p["Default"].nil? } end |
#parameter_groups ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lono/output/template.rb', line 21 def parameter_groups interface = data.dig("Metadata", "AWS::CloudFormation::Interface") return unless interface pgs = interface["ParameterGroups"] pgs.inject({}) do |result, pg| k = pg["Label"]["default"] v = pg["Parameters"] result.merge(k => v) end end |
#parameters ⇒ Object
17 18 19 |
# File 'lib/lono/output/template.rb', line 17 def parameters data["Parameters"] || [] end |
#required_parameters ⇒ Object
9 10 11 |
# File 'lib/lono/output/template.rb', line 9 def required_parameters parameters.select { |logical_id, p| p["Default"].nil? } end |