Module: Awshark::CloudFormation::Files
- Included in:
- Parameters, Template
- Defined in:
- lib/awshark/cloud_formation/files.rb
Instance Method Summary collapse
Instance Method Details
#parse_file(filepath) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/awshark/cloud_formation/files.rb', line 6 def parse_file(filepath) return nil if filepath.blank? content = File.read(filepath) parse_string(filepath, content) end |
#parse_string(filename, content) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/awshark/cloud_formation/files.rb', line 14 def parse_string(filename, content) case File.extname(filename) when '.json' JSON.parse(content) when '.yml', '.yaml' YAML.safe_load(content, permitted_classes: [Date, Time], aliases: true) else raise ArgumentError, "Unsupported file extension for parsing, #{filepath}" end end |