class AwsCftTools::Client::Templates
All of the business logic behind direct interaction with the AWS Template
sources.
Constants
- DEFAULT_PARAMETER_DIR
Default parameters directory in the project.
- DEFAULT_TEMPLATE_DIR
Default template directory in the project.
- TEMPLATE_FILE_EXTENSIONS
Default set of file extensions that might contain templates.
Public Class Methods
new(options)
click to toggle source
@param options [Hash] client configuration @option options [String] :environment the operational environment in which to act @option options [String] :parameter_dir @option options [String] :region the AWS region in which to act @option options [Pathname] :root @option options [String] :template_dir
Calls superclass method
AwsCftTools::Client::Base::new
# File lib/aws_cft_tools/client/templates.rb, line 33 def initialize(options) super({ template_dir: DEFAULT_TEMPLATE_DIR, parameter_dir: DEFAULT_PARAMETER_DIR }.merge(options)) end
Public Instance Methods
templates()
click to toggle source
Lists all templates.
@return AwsCftTools::TemplateSet
# File lib/aws_cft_tools/client/templates.rb, line 45 def templates template_file_root = (options[:root] + options[:template_dir]).cleanpath filtered_by_region( filtered_by_environment( all_templates( template_file_root ) ) ) end
Private Instance Methods
all_templates(root)
click to toggle source
# File lib/aws_cft_tools/client/templates.rb, line 66 def all_templates(root) AwsCftTools::TemplateSet.new(glob_templates(root)).tap do |set| set.known_exports = options[:client].exports.map(&:name) end end
file_to_template(root, file)
click to toggle source
# File lib/aws_cft_tools/client/templates.rb, line 79 def file_to_template(root, file) AwsCftTools::Template.new(file.relative_path_from(root), options) end
filtered_by_environment(set)
click to toggle source
# File lib/aws_cft_tools/client/templates.rb, line 58 def filtered_by_environment(set) set.select { |template| template.environment?(options[:environment]) } end
filtered_by_region(set)
click to toggle source
# File lib/aws_cft_tools/client/templates.rb, line 62 def filtered_by_region(set) set.select { |template| template.region?(options[:region]) } end
glob_templates(root)
click to toggle source
# File lib/aws_cft_tools/client/templates.rb, line 72 def glob_templates(root) Pathname.glob(root + '**/*') .select { |file| TEMPLATE_FILE_EXTENSIONS.include?(file.extname) } .map { |file| file_to_template(root, file) } .select(&:template?) end