class StackMaster::SparkleFormation::CloudFormationLineFormatter
Splits up long strings with multiple lines in them to multiple strings in the CF array. Makes the compiled template and diffs more readable.
Public Class Methods
format(template)
click to toggle source
# File lib/stack_master/sparkle_formation/template_file.rb, line 55 def self.format(template) new(template).format end
new(template)
click to toggle source
# File lib/stack_master/sparkle_formation/template_file.rb, line 59 def initialize(template) @template = template end
Public Instance Methods
format()
click to toggle source
# File lib/stack_master/sparkle_formation/template_file.rb, line 63 def format @template.flat_map do |lines| lines = lines.to_s if Symbol === lines if String === lines newlines = [] lines.count("\n").times do newlines << "\n" end newlines = lines.split("\n").map do |line| "#{line}#{newlines.pop}" end if lines.start_with?("\n") newlines.insert(0, "\n") end newlines else lines end end end