lib/hieracles/formats/console.rb in hieracles-0.2.2 vs lib/hieracles/formats/console.rb in hieracles-0.3.0
- old
+ new
@@ -33,20 +33,26 @@
build_list(@node.facts, @node.notifications, filter)
end
def build_list(hash, notifications, filter)
back = ''
- back << build_notifications(notifications) if notifications
- if filter[0]
- hash.select! { |k, v| Regexp.new(filter[0]).match(k.to_s) }
- end
- length = max_key_length(hash) + 2
- title = format(COLORS[8], "%-#{length}s")
- hash.each do |k, v|
- if v.class.name == 'Hash' || v.class.name == 'Array'
- v = v.ai({ indent: 10, raw: true}).strip
+ if hash.class.name == 'Array'
+ hash.each do |v|
+ back << "#{v}\n"
end
- back << format("#{title} %s\n", k, v)
+ else
+ back << build_notifications(notifications) if notifications
+ if filter[0]
+ hash.select! { |k, v| Regexp.new(filter[0]).match(k.to_s) }
+ end
+ length = max_key_length(hash) + 2
+ title = format(COLORS[8], "%-#{length}s")
+ hash.each do |k, v|
+ if v.class.name == 'Hash' || v.class.name == 'Array'
+ v = v.ai({ indent: 10, raw: true}).strip
+ end
+ back << format("#{title} %s\n", k, v)
+ end
end
back
end
def build_notifications(notifications)