Class: OutputResults
- Inherits:
-
Object
- Object
- OutputResults
- Defined in:
- lib/puppet-check/output_results.rb
Overview
class to handle outputting diagnostic results in desired format
Class Method Summary collapse
-
.markup ⇒ Object
output the results as yaml or json.
-
.text ⇒ Object
output the results as text.
Class Method Details
.markup ⇒ Object
output the results as yaml or json
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/puppet-check/output_results.rb', line 25 def self.markup # generate output hash hash = {} hash['errors'] = PuppetCheck.error_files unless PuppetCheck.error_files.empty? hash['warnings'] = PuppetCheck.warning_files unless PuppetCheck.warning_files.empty? hash['clean'] = PuppetCheck.clean_files unless PuppetCheck.clean_files.empty? hash['ignored'] = PuppetCheck.ignored_files unless PuppetCheck.ignored_files.empty? # convert hash to markup language if PuppetCheck.output_format == 'yaml' require 'yaml' puts Psych.dump(hash, indentation: 2) elsif PuppetCheck.output_format == 'json' require 'json' puts JSON.pretty_generate(hash) else raise "puppet-check: Unsupported output format '#{PuppetCheck.output_format}' was specified." end end |
.text ⇒ Object
output the results as text
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/puppet-check/output_results.rb', line 6 def self.text unless PuppetCheck.error_files.empty? print "\033[31mThe following files have errors:\033[0m\n-- " puts PuppetCheck.error_files.join("\n\n-- ") end unless PuppetCheck.warning_files.empty? print "\n\033[33mThe following files have warnings:\033[0m\n-- " puts PuppetCheck.warning_files.join("\n\n-- ") end unless PuppetCheck.clean_files.empty? print "\n\033[32mThe following files have no errors or warnings:\033[0m\n-- " puts PuppetCheck.clean_files.join("\n-- ") end return if PuppetCheck.ignored_files.empty? print "\n\033[36mThe following files have unrecognized formats and therefore were not processed:\033[0m\n-- " puts PuppetCheck.ignored_files.join("\n-- ") end |