lib/hieracles/formats/yaml.rb in hieracles-0.3.0 vs lib/hieracles/formats/yaml.rb in hieracles-0.3.1
- old
+ new
@@ -37,11 +37,11 @@
commented_yaml_tree(args, false)
end
def commented_yaml_tree(filter, without_common = true)
tree = @node.params_tree(without_common)
- params = Hash[@node.params(without_common)]
+ params = @node.params(without_common)
mergetree('---', [], tree, params)
end
def mergetree(output, key, leaf, params)
indent = ' ' * key.count
@@ -59,17 +59,12 @@
def add_array(output, key, leaf, params, indent)
yaml = leaf.to_yaml[4..-1]
aryaml = yaml.each_line.map do |l|
indent + l
end
- if @node.hiera.merge_behavior == :deep ||
- @node.hiera.merge_behavior == :deeper
- params[key.join('.')].each do |f|
- output += "\n" + indent + "# " + f[:file]
- end
- else
- output += "\n" + indent + "# " + params[key.join('.')].last[:file]
+ params[key.join('.')][:found_in].each do |k|
+ output += "\n" + indent + "# " + k[:file]
end
output += "\n" + aryaml.join().chomp
output
end
@@ -99,15 +94,13 @@
private
def added(output, key, leaf, params)
output += leaf.to_s
- if params["#{key.join('.')}"]
- params["#{key.join('.')}"].each do |k|
- if k[:value].to_s == leaf.to_s
- output += " # " + k[:file]
- break
- end
+ k = params["#{key.join('.')}"]
+ if k
+ k[:found_in].each do |i|
+ output += " # " + i[:file]
end
end
output
end