Class: Lono::Template::Strategy::Dsl::Builder
- Inherits:
-
Object
- Object
- Lono::Template::Strategy::Dsl::Builder
- Extended by:
- Memoist
- Includes:
- Extensions::Loader, Context::Loader, Syntax, Util
- Defined in:
- lib/lono/template/strategy/dsl/builder/syntax.rb,
lib/lono/template/strategy/dsl/builder.rb,
lib/lono/template/strategy/dsl/builder/fn.rb,
lib/lono/template/strategy/dsl/builder/helpers.rb,
lib/lono/template/strategy/dsl/builder/squeezer.rb,
lib/lono/template/strategy/dsl/builder/stringify.rb
Overview
Built-in helpers for the DSL form
Defined Under Namespace
Modules: Fn, Helpers, Section, Stringify, Syntax Classes: Squeezer
Constant Summary
Constants included from Fn
Instance Method Summary collapse
- #build ⇒ Object
- #finalize ⇒ Object
-
#initialize(options = {}) ⇒ Builder
constructor
A new instance of Builder.
-
#load_extensions ⇒ Object
load_extensions and evaluate extend_with methods earlier than load_context so project helpers can override extensions.
- #to_yaml ⇒ Object
- #write_output ⇒ Object
Methods included from Common::Helpers
#extract_scripts, #scripts_name, #scripts_s3_path, #setting
Methods included from Syntax::ExtendWith
Methods included from Syntax::ParameterGroup
Methods included from Section::Methods
#aws_template_format_version, #condition, #description, #mapping, #metadata, #output, #parameter, #resource, #section, #transform
Methods included from Evaluate
#evaluate_template_path, #template_evaluation_error
Methods included from Fn
#conditional_ref, define_methods, #fn, #fn_id, #get_att, #get_azs, included, #join, #ref, #sub
Methods included from Extensions::Loader
#find_extensions_root_path, #load_all_extension_helpers, #load_extension_helpers
Methods included from Context::Loader::LoadFiles
Methods included from Util
Constructor Details
#initialize(options = {}) ⇒ Builder
Returns a new instance of Builder.
10 11 12 13 14 15 16 |
# File 'lib/lono/template/strategy/dsl/builder.rb', line 10 def initialize(={}) = @stack, @blueprint, @template, @param = Lono::Conventions.new().values @template_path = "#{Lono.config.templates_path}/#{@template}.rb" @parameters = [] # registry @cfn = {} end |
Instance Method Details
#build ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/lono/template/strategy/dsl/builder.rb', line 18 def build load_extensions # load_extensions before project helpers load_context # variables and project helpers evaluate_template_path(@template_path) # modifies @cfn finalize to_yaml write_output @cfn end |
#finalize ⇒ Object
34 35 36 37 |
# File 'lib/lono/template/strategy/dsl/builder.rb', line 34 def finalize o = .merge(parameters: @parameters) @cfn = Finalizer.new(@cfn, o).run end |
#load_extensions ⇒ Object
load_extensions and evaluate extend_with methods earlier than load_context so project helpers can override extensions
29 30 31 32 |
# File 'lib/lono/template/strategy/dsl/builder.rb', line 29 def load_extensions # evaluates extend_with Lono::Extensions::Preparer.new().run load_all_extension_helpers # after Extensions::Preparer#run end |
#to_yaml ⇒ Object
39 40 41 42 43 44 |
# File 'lib/lono/template/strategy/dsl/builder.rb', line 39 def to_yaml # https://stackoverflow.com/questions/24508364/how-to-emit-yaml-in-ruby-expanding-aliases # Trick to prevent YAML from emitting aliases @cfn = YAML.load(@cfn.to_json) @results = YAML.dump(@cfn) end |
#write_output ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/lono/template/strategy/dsl/builder.rb', line 46 def write_output path = "#{Lono.config.output_path}/#{@blueprint}/templates/#{@template}.yml" ensure_parent_dir(path) IO.write(path, @results) Lono::Yamler::Validator.new(path).validate! unless [:quiet] pretty_path = path.sub("#{Lono.root}/",'') puts " #{pretty_path}" end end |