Sha256: 234d2c3fa54d4f910bcb6737d273698a9abe85c56f6d64ff0efab9c948448452
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
module Aws module Cfn module Compiler module Save def save_section(dir, file, format, section, hash, join='/', brick=nil) brick ||= "brick #{hash.keys[0]}" path = File.join(File.expand_path(dir), file) filn = if @config[:expandedpaths] path else File.join(dir, file) end logStep "Saving #{brick} to #{filn} " # noinspection RubyAssignmentExpressionInConditionalInspection if match = file.match(%r'\.(.*)$') if (section != '') and (not formats_compatible?(format, match[1])) msg = "The file extension (#{match[1]}) does not match the chosen output format (#{format})!" if @config[:force] logger.warn msg else abort! "#{msg}\n\tIf you are SURE this is what you want then use the --force option!" end end end if i_am_maintainer(path) or @config[:force] begin File.open path, File::CREAT|File::TRUNC|File::RDWR, 0644 do |f| case format when /ruby|rb|yaml|yml/ f.write maintainer_comment('') f.write hash.to_yaml line_width: 1024, indentation: 4, canonical: false when /json|js/ # You wish ... f.write maintainer_comment('') f.write JSON.pretty_generate(hash, { indent: "\t", space: ' '}) else abort! "Internal: Unsupported format #{format}. Should have noticed this earlier!" end f.close end @logger.info " decompiled #{filn}." rescue abort! "!!! Could not write compiled file #{path}: #{$!}" end else @logger.warn " Did not overwrite #{filn}." end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aws-cfn-compiler-0.7.0 | lib/aws/cfn/compiler/mixins/save.rb |