Class: OutputResults
- Inherits:
-
Object
- Object
- OutputResults
- Defined in:
- lib/puppet-check/output_results.rb
Overview
class to handle outputting diagnostic results in desired format
Constant Summary collapse
- HEADER =
{ errors: "\033[31mThe following files have errors:\033[0m\n", warnings: "\033[33mThe following files have warnings:\033[0m\n", clean: "\033[32mThe following files have no errors or warnings:\033[0m\n-- ", ignored: "\033[36mThe following files have unrecognized formats and therefore were not processed:\033[0m\n-- " }.freeze
Class Method Summary collapse
-
.run(files, format) ⇒ Object
output the results in various formats.
Class Method Details
.run(files, format) ⇒ Object
output the results in various formats
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/puppet-check/output_results.rb', line 13 def self.run(files, format) # remove empty entries files.delete_if { |_, sorted_files| sorted_files.empty? } # output hash according to specified format case format when 'text' text(files) when 'yaml' require 'yaml' # maintain filename format consistency among output formats files.transform_keys!(&:to_s) puts Psych.dump(files, indentation: 2) when 'json' require 'json' puts JSON.pretty_generate(files) else raise "puppet-check: Unsupported output format '#{format}' was specified." end end |