Sha256: 910652ea8493692d137834418198376321cc3a9af0cbaaa8e489a4cd95de689c

Contents?: true

Size: 919 Bytes

Versions: 16

Compression:

Stored size: 919 Bytes

Contents

require "yaml"

module Jack
  module Config
    # Class does very specific formatting for the eb config files:
    #
    #   * Makes sure that the keys are sorted so we can compare them
    #   * It also scripts out the generated DateModified and DateCreated Metadata
    class YamlFormatter
      def process(file)
        data = YAML.load_file(file)
        data = strip_metadata_dates(data)
        dump = YAML.dump(data).gsub("!ruby/object:Hash", '')
        dump = dump.split("\n")[1..-1].join("\n") + "\n" # strip first line
        outfile = "#{file}.sorted"
        File.open(outfile, 'w') { |f| f.write(dump) }
        FileUtils.mv(outfile, file)
      end

      def strip_metadata_dates(data)
        metadata = data['EnvironmentConfigurationMetadata']
        if metadata
          metadata.delete('DateModified')
          metadata.delete('DateCreated')
        end
        data
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
jack-eb-0.2.0 lib/jack/config/yaml_formatter.rb
jack-eb-0.1.6 lib/jack/config/yaml_formatter.rb
jack-eb-0.1.5 lib/jack/config/yaml_formatter.rb
jack-eb-0.1.4 lib/jack/config/yaml_formatter.rb
jack-eb-0.1.3 lib/jack/config/yaml_formatter.rb
jack-eb-0.1.2 lib/jack/config/yaml_formatter.rb
jack-eb-0.1.1 lib/jack/config/yaml_formatter.rb
jack-eb-0.1.0 lib/jack/config/yaml_formatter.rb
jack-eb-0.0.9 lib/jack/config/yaml_formatter.rb
jack-eb-0.0.8 lib/jack/config/yaml_formatter.rb
jack-eb-0.0.7 lib/jack/config/yaml_formatter.rb
jack-eb-0.0.6 lib/jack/config/yaml_formatter.rb
jack-eb-0.0.4 lib/jack/config/yaml_formatter.rb
jack-eb-0.0.3 lib/jack/config/yaml_formatter.rb
jack-eb-0.0.2 lib/jack/config/yaml_formatter.rb
jack-eb-0.0.1 lib/jack/config/yaml_formatter.rb