class Stacker::Stack::Template::JSONFormatter
Constants
- STR
Public Class Methods
format(object)
click to toggle source
# File lib/stacker/stack/template.rb, line 106 def self.format object formatted = JSON.pretty_generate object # put empty arrays on a single line formatted.gsub! /: \[\s*\]/m, ': []' # put { "Ref": ... } on a single line formatted.gsub! /\{\s+\"Ref\"\:\s+(?<ref>#{STR})\s+\}/m, '{ "Ref": \\k<ref> }' # put { "Fn::GetAtt": ... } on a single line formatted.gsub! /\{\s+\"Fn::GetAtt\"\: \[\s+(?<key>#{STR}),\s+(?<val>#{STR})\s+\]\s+\}/m, '{ "Fn::GetAtt": [ \\k<key>, \\k<val> ] }' formatted + "\n" end