lib/licensed/reporters/json_reporter.rb in licensed-3.1.0 vs lib/licensed/reporters/json_reporter.rb in licensed-3.2.0

- old
+ new

@@ -2,34 +2,32 @@ require "json" module Licensed module Reporters class JsonReporter < Reporter - def report_run(command) - super do |report| - result = yield report - - report["apps"] = report.reports.map(&:to_h) if report.reports.any? - shell.info JSON.pretty_generate(report.to_h) - - result - end + # Report all information from the command run to the shell as a JSON object + # + # command - The command being run + # report - A report object containing information about the command run + def end_report_command(command, report) + report["apps"] = report.reports.map(&:to_h) if report.reports.any? + shell.info JSON.pretty_generate(report.to_h) end - def report_app(app) - super do |report| - result = yield report - report["sources"] = report.reports.map(&:to_h) if report.reports.any? - result - end + # Add source report information to the app report hash + # + # app - An application configuration + # report - A report object containing information about the app evaluation + def end_report_app(app, report) + report["sources"] = report.reports.map(&:to_h) if report.reports.any? end - def report_source(source) - super do |report| - result = yield report - report["dependencies"] = report.reports.map(&:to_h) if report.reports.any? - result - end + # Add dependency report information to the source report hash + # + # source - A dependency source enumerator + # report - A report object containing information about the source evaluation + def end_report_source(source, report) + report["dependencies"] = report.reports.map(&:to_h) if report.reports.any? end end end end