Module: AwsCftTools::Template::Metadata
- Included in:
- AwsCftTools::Template
- Defined in:
- lib/aws_cft_tools/template/metadata.rb
Overview
Simple derived information about templates.
Constant Summary collapse
- CONTENT_TYPES =
Mapping of filename extensions to content types.
{ '.json' => 'json', '.rb' => 'dsl', '.yml' => 'yaml', '.yaml' => 'yaml' }.freeze
Instance Method Summary collapse
-
#name ⇒ String
The name of the stack built by this template.
-
#parameters ⇒ Hash
The parsed parameters for this template in the deployment environment.
-
#template ⇒ Hash
The parsed template as a Ruby data structure.
-
#template? ⇒ Boolean
Queries if the template source looks like a CloudFormation template.
-
#template_source_for_aws ⇒ String
The JSON or YAML source that can be submitted to AWS to build the stack.
-
#template_type ⇒ String
The type of template content.
Instance Method Details
#name ⇒ String
The name of the stack built by this template.
41 42 43 44 |
# File 'lib/aws_cft_tools/template/metadata.rb', line 41 def name @name ||= @options[:environment] + '-' + filename.to_s.sub(/\.(ya?ml|json|rb)$/, '').split(%r{/}).reverse.join('-') end |
#parameters ⇒ Hash
The parsed parameters for this template in the deployment environment.
66 67 68 |
# File 'lib/aws_cft_tools/template/metadata.rb', line 66 def parameters @parameters ||= parameters_for_filename_and_environment(parameters_source, @options[:environment]) end |
#template ⇒ Hash
The parsed template as a Ruby data structure.
50 51 52 |
# File 'lib/aws_cft_tools/template/metadata.rb', line 50 def template @template ||= template_content_for_filename(template_file) end |
#template? ⇒ Boolean
Queries if the template source looks like a CloudFormation template.
33 34 35 |
# File 'lib/aws_cft_tools/template/metadata.rb', line 33 def template? template && template['AWSTemplateFormatVersion'] end |
#template_source_for_aws ⇒ String
The JSON or YAML source that can be submitted to AWS to build the stack.
58 59 60 |
# File 'lib/aws_cft_tools/template/metadata.rb', line 58 def template_source_for_aws template_type == 'dsl' ? JSON.pretty_generate(template) : template_source end |
#template_type ⇒ String
The type of template content.
25 26 27 |
# File 'lib/aws_cft_tools/template/metadata.rb', line 25 def template_type content_type(template_file) end |