Class: LintRoller::Support::MergesUpstreamMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/lint_roller/support/merges_upstream_metadata.rb

Instance Method Summary collapse

Instance Method Details

#merge(plugin_yaml, upstream_yaml) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/lint_roller/support/merges_upstream_metadata.rb', line 4

def merge(plugin_yaml, upstream_yaml)
  common_upstream_values = upstream_yaml.select { |key| plugin_yaml.key?(key) }

  plugin_yaml.merge(common_upstream_values) { |key, plugin_value, upstream_value|
    if plugin_value.is_a?(Hash) && upstream_value.is_a?(Hash)
      plugin_value.merge(upstream_value) { |sub_key, plugin_sub_value, upstream_sub_value|
        if plugin_value.key?(sub_key)
          plugin_sub_value
        else
          upstream_sub_value
        end
      }
    else
      plugin_value
    end
  }
end