Sha256: 9e866c6d3637c35bc3978a7cc2554d7e534f9d4515ab47cec73cc8adeac4cafd
Contents?: true
Size: 877 Bytes
Versions: 1046
Compression:
Stored size: 877 Bytes
Contents
require 'json' module Aws module Resources class Source def initialize(definition, file = nil) @definition = definition @file = file end # @return [Hash] attr_reader :definition # @return [String, nil] attr_reader :file def format json = JSON.pretty_generate(definition, indent: ' ', space: '') stack = [[]] json.lines.each do |line| if line.match(/({|\[)$/) stack.push([]) end stack.last.push(line) if line.match(/(}|\]),?$/) frame = stack.pop if frame.size == 3 && !frame[1].match(/[{}]/) frame = [frame[0].rstrip, '', frame[1].strip, '', frame[2].lstrip] end stack.last.push(frame.join) end end stack.last.join end end end end
Version data entries
1,046 entries across 1,046 versions & 2 rubygems