Sha256: 2ea87b21f92352d5f4e669a68e03a45b1553e71c8e34d9a146985dd3fe6ef5b2

Contents?: true

Size: 1.16 KB

Versions: 37

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true
require "json"

module Licensed
  module Reporters
    class JsonReporter < Reporter
      # 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

      # 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

      # 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

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
licensed-5.0.3 lib/licensed/reporters/json_reporter.rb
licensed-5.0.2 lib/licensed/reporters/json_reporter.rb
licensed-5.0.1 lib/licensed/reporters/json_reporter.rb
licensed-5.0.0 lib/licensed/reporters/json_reporter.rb
licensed-4.5.0 lib/licensed/reporters/json_reporter.rb
licensed-4.4.0 lib/licensed/reporters/json_reporter.rb
licensed-4.3.1 lib/licensed/reporters/json_reporter.rb
licensed-4.3.0 lib/licensed/reporters/json_reporter.rb
licensed-4.2.0 lib/licensed/reporters/json_reporter.rb
licensed-4.1.0 lib/licensed/reporters/json_reporter.rb
licensed-4.0.4 lib/licensed/reporters/json_reporter.rb
licensed-4.0.3 lib/licensed/reporters/json_reporter.rb
licensed-4.0.2 lib/licensed/reporters/json_reporter.rb
licensed-4.0.1 lib/licensed/reporters/json_reporter.rb
licensed-4.0.0 lib/licensed/reporters/json_reporter.rb
licensed-3.9.1 lib/licensed/reporters/json_reporter.rb
licensed-3.9.0 lib/licensed/reporters/json_reporter.rb
licensed-3.8.0 lib/licensed/reporters/json_reporter.rb
licensed-3.7.5 lib/licensed/reporters/json_reporter.rb
licensed-3.7.4 lib/licensed/reporters/json_reporter.rb