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-3.1.0 lib/licensed/reporters/json_reporter.rb
licensed-3.0.1 lib/licensed/reporters/json_reporter.rb
licensed-3.0.0 lib/licensed/reporters/json_reporter.rb
licensed-2.15.2 lib/licensed/reporters/json_reporter.rb
licensed-2.15.1 lib/licensed/reporters/json_reporter.rb
licensed-2.15.0 lib/licensed/reporters/json_reporter.rb
licensed-2.14.4 lib/licensed/reporters/json_reporter.rb
licensed-2.14.3 lib/licensed/reporters/json_reporter.rb
licensed-2.14.2 lib/licensed/reporters/json_reporter.rb
licensed-2.14.1 lib/licensed/reporters/json_reporter.rb
licensed-2.14.0 lib/licensed/reporters/json_reporter.rb
licensed-2.13.0 lib/licensed/reporters/json_reporter.rb
licensed-2.12.2 lib/licensed/reporters/json_reporter.rb
licensed-2.12.1 lib/licensed/reporters/json_reporter.rb
licensed-2.12.0 lib/licensed/reporters/json_reporter.rb
licensed-2.11.1 lib/licensed/reporters/json_reporter.rb
licensed-2.11.0 lib/licensed/reporters/json_reporter.rb
licensed-2.10.0 lib/licensed/reporters/json_reporter.rb
licensed-2.9.2 lib/licensed/reporters/json_reporter.rb
licensed-2.9.1 lib/licensed/reporters/json_reporter.rb