Class: BabelDiff::YamlMerger

Inherits:
Struct
  • Object
show all
Defined in:
lib/babel_diff/yaml_merger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#flattened_contents_to_mergeObject

Returns the value of attribute flattened_contents_to_merge

Returns:

  • (Object)

    the current value of flattened_contents_to_merge



2
3
4
# File 'lib/babel_diff/yaml_merger.rb', line 2

def flattened_contents_to_merge
  @flattened_contents_to_merge
end

#original_contentsObject

Returns the value of attribute original_contents

Returns:

  • (Object)

    the current value of original_contents



2
3
4
# File 'lib/babel_diff/yaml_merger.rb', line 2

def original_contents
  @original_contents
end

Instance Method Details

#contents_to_mergeObject



15
16
17
# File 'lib/babel_diff/yaml_merger.rb', line 15

def contents_to_merge
  YAML.load(flattened_contents_to_merge)
end

#merged_yamlObject



4
5
6
7
8
9
# File 'lib/babel_diff/yaml_merger.rb', line 4

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

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

#original_hashObject



11
12
13
# File 'lib/babel_diff/yaml_merger.rb', line 11

def original_hash
  YAML.load(original_contents)
end