Sha256: f4f7a86b29ffc68a95e996183c643bd8650b5f7bbd649ca0f39733dd4f54380f

Contents?: true

Size: 452 Bytes

Versions: 1

Compression:

Stored size: 452 Bytes

Contents

module BabelDiff
  class YamlMerger < Struct.new(:original_contents, :flattened_contents_to_merge)

    def merged_yaml
      flat_original = HashFlattener.new(original_hash).flatten

      flat_original.merge!(contents_to_merge)
      HashFlattener.new(flat_original).unflatten.to_yaml
    end

    def original_hash
      YAML.load(original_contents)
    end

    def contents_to_merge
      YAML.load(flattened_contents_to_merge)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
babel_diff-1.1.0 lib/babel_diff/yaml_merger.rb