class AwsCftTools::TemplateSet
Management of a set of template sources.
Attributes
dependency_tree[R]
known_exports[R]
Public Class Methods
new(list = [])
click to toggle source
@param list [Array<AwsCftTools::Template>] the templates in the set
Calls superclass method
# File lib/aws_cft_tools/template_set.rb, line 36 def initialize(list = []) @dependency_tree = AwsCftTools::DependencyTree.new @sorted_names = [] @known_exports = [] super(list) list.each { |template| process_template_addition(template) } end
Public Instance Methods
dependencies_for(template)
click to toggle source
@param template [AwsCftTools::Template] @return [AwsCftTools::TemplateSet] set of templates on which the given template depends
# File lib/aws_cft_tools/template_set.rb, line 80 def dependencies_for(template) templates_for(@dependency_tree.dependencies_for(template.filename.to_s)) end
dependents_for(template)
click to toggle source
@param template [AwsCftTools::Template] @return [AwsCftTools::TemplateSet] set of templates that depend on the given template
# File lib/aws_cft_tools/template_set.rb, line 88 def dependents_for(template) templates_for(@dependency_tree.dependents_for(template.filename.to_s)) end
initialize_clone(other)
click to toggle source
@!visibility private
# File lib/aws_cft_tools/template_set.rb, line 46 def initialize_clone(other) initialize_copy(other) end
initialize_copy(other)
click to toggle source
@!visibility private
Calls superclass method
# File lib/aws_cft_tools/template_set.rb, line 51 def initialize_copy(other) super(other) @dependency_tree = other.dependency_tree.clone end
known_exports=(list)
click to toggle source
Set the list of known exported values in CloudFormation
@param list [Array<String>]
# File lib/aws_cft_tools/template_set.rb, line 61 def known_exports=(list) @known_exports |= list list.each do |name| @dependency_tree.exported(name) end end
templates_for(filenames)
click to toggle source
@param filenames [Array<String>] @return [AwsCftTools::TemplateSet] set of templates with the given filenames
# File lib/aws_cft_tools/template_set.rb, line 72 def templates_for(filenames) select { |template| filenames.include?(template.filename.to_s) } end
Private Instance Methods
process_template_addition(template)
click to toggle source
# File lib/aws_cft_tools/template_set.rb, line 111 def process_template_addition(template) process_template_inputs(template) process_template_outputs(template) process_template_dependencies(template) resort_templates self end
process_template_dependencies(template)
click to toggle source
# File lib/aws_cft_tools/template_set.rb, line 107 def process_template_dependencies(template) templates_for(template.template_dependencies).each { |other| linked(other, template) } end
process_template_inputs(template)
click to toggle source
# File lib/aws_cft_tools/template_set.rb, line 103 def process_template_inputs(template) template.inputs.each { |name| required(template, name) } end
process_template_outputs(template)
click to toggle source
# File lib/aws_cft_tools/template_set.rb, line 99 def process_template_outputs(template) template.outputs.each { |name| provided(template, name) } end
resort_templates()
click to toggle source
# File lib/aws_cft_tools/template_set.rb, line 94 def resort_templates @sorted_names = @dependency_tree.sort sort_by! { |template| @sorted_names.index(template.filename.to_s) || -1 } end