class TemplateDiscovery
Container for discovering templates
Public Instance Methods
discover_templates(input_json_path:, template_pattern: '..*\.json|..*\.yaml|..*\.yml|..*\.template')
click to toggle source
input_json_path can be a directory, filename, or File
# File lib/cfn-nag/template_discovery.rb, line 6 def discover_templates(input_json_path:, template_pattern: '..*\.json|..*\.yaml|..*\.yml|..*\.template') if ::File.directory? input_json_path return find_templates_in_directory(directory: input_json_path, template_pattern: template_pattern) end return [render_path(input_json_path)] if ::File.file? input_json_path raise "#{input_json_path} is not a proper path" end
Private Instance Methods
find_templates_in_directory(directory:, template_pattern:)
click to toggle source
# File lib/cfn-nag/template_discovery.rb, line 25 def find_templates_in_directory(directory:, template_pattern:) templates = [] Dir[File.join(directory, '**/**')].each do |file_name| if file_name.match?(template_pattern) templates << file_name end end templates end
render_path(path)
click to toggle source
# File lib/cfn-nag/template_discovery.rb, line 19 def render_path(path) return path.path if path.is_a? File path end