lib/hieracles/node.rb in hieracles-0.1.6 vs lib/hieracles/node.rb in hieracles-0.1.7

- old
+ new

@@ -53,11 +53,11 @@ if data s = to_shallow_hash(data) s.each do |k,v| params[k] ||= [] # f needs interpolation - params[k] << { value: v, file: f} + params[k] << { value: v, file: f, merged: merge_value(params[k], v) } end end end params.sort end @@ -118,11 +118,32 @@ case @hiera.merge_behavior when :deeper left.deep_merge!(right) when :deep left.deep_merge(right) - else # Native and undefined + else local_merge!(left, right) + end + end + + def merge_value(previous, value) + if value.is_a? Array + if previous == [] + deep_sort(value) + else + left = previous.last[:merged] + case @hiera.merge_behavior + # TODO: handle the case where right is not an array + when :deeper + deep_sort(left | value) + when :deep + deep_sort(left | value) + else + deep_sort(value) + end + end + else + value end end end end