Sha256: 19655de2278abf59dd68021a099b03dd037e86ba9c595dd66530402e1abb2c51

Contents?: true

Size: 813 Bytes

Versions: 27

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true
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
      end

      def report_app(app)
        super do |report|
          result = yield report
          report["sources"] = report.reports.map(&:to_h) if report.reports.any?
          result
        end
      end

      def report_source(source)
        super do |report|
          result = yield report
          report["dependencies"] = report.reports.map(&:to_h) if report.reports.any?
          result
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
licensed-2.9.0 lib/licensed/reporters/json_reporter.rb
licensed-2.8.0 lib/licensed/reporters/json_reporter.rb
licensed-2.7.0 lib/licensed/reporters/json_reporter.rb
licensed-2.6.2 lib/licensed/reporters/json_reporter.rb
licensed-2.6.1 lib/licensed/reporters/json_reporter.rb
licensed-2.6.0 lib/licensed/reporters/json_reporter.rb
licensed-2.5.0 lib/licensed/reporters/json_reporter.rb