lib/hieracles/formats/console.rb in hieracles-0.1.6 vs lib/hieracles/formats/console.rb in hieracles-0.1.7
- old
+ new
@@ -39,11 +39,11 @@
def paths(_)
@node.paths.join("\n") + "\n"
end
def build_head(without_common)
- output = ''
+ output = "[-] (merged)\n"
@node.files(without_common).each_with_index do |f, i|
output << format("#{COLORS[i]}\n", "[#{i}] #{f}")
@colors[f] = i
end
"#{output}\n"
@@ -53,14 +53,27 @@
output = ''
if !filter || Regexp.new(filter).match(key)
first = value.pop
filecolor_index = @colors[first[:file]]
filecolor = COLORS[filecolor_index]
- output << format("#{filecolor} #{COLORS[5]} %s\n",
- "[#{filecolor_index}]",
- key,
- first[:value].to_s.gsub('%', '%%')
- )
+ if first[:merged] != first[:value]
+ output << format("%s #{COLORS[5]} %s\n",
+ "[-]",
+ key,
+ first[:merged].to_s.gsub('%', '%%')
+ )
+ output << format(" #{COLORS[8]} #{COLORS[8]} #{COLORS[8]}\n",
+ "[#{filecolor_index}]",
+ key,
+ first[:value].to_s.gsub('%', '%%')
+ )
+ else
+ output << format("#{filecolor} #{COLORS[5]} %s\n",
+ "[#{filecolor_index}]",
+ key,
+ first[:value].to_s.gsub('%', '%%')
+ )
+ end
while value.count > 0
overriden = value.pop
filecolor_index = @colors[overriden[:file]]
output << format(" #{COLORS[8]}\n",
"[#{filecolor_index}] #{key} #{overriden[:value]}"