Method: Hieracles::Formats::Console#show_params

Defined in:
lib/hieracles/formats/console.rb

#show_params(without_common, args) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/hieracles/formats/console.rb', line 76

def show_params(without_common, args)
  filter = args[0]
  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"
  @node.params(without_common).each do |key, v|
    if !filter || Regexp.new(filter).match(key)
      filecolor_index = @colors[v[:file]]
      if v[:overriden]
        output << format(
          "%s #{COLORS[7]} %s\n", "[-]",
          key,
          sanitize(v[:value])
          )
        v[:found_in].each do |val|
          filecolor_index = @colors[val[:file]]
          output << format(
            "    #{COLORS[8]}\n",
            "[#{filecolor_index}] #{key} #{val[:value]}"
            )
        end
      else
        filecolor = COLORS[filecolor_index]
        output << format(
          "#{filecolor} #{COLORS[7]} %s\n", "[#{filecolor_index}]",
          key,
          sanitize(v[:value])
          )
      end
    end
  end
  output
end