lib/puppet-check/output_results.rb in puppet-check-1.3.0 vs lib/puppet-check/output_results.rb in puppet-check-1.3.1

- old
+ new

@@ -14,31 +14,29 @@ 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 - unless 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 + 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 # output the results as yaml or json def self.markup - require 'yaml' - require 'json' - # 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