Class: Licensure::Formatters::Json
- Defined in:
- lib/licensure/formatters/json.rb
Overview
Renders JSON output for list/check results.
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Licensure::Formatters::Base
Instance Method Details
#render(gem_license_infos) ⇒ String
12 13 14 15 16 17 18 19 |
# File 'lib/licensure/formatters/json.rb', line 12 def render(gem_license_infos) payload = { generated_at: Time.now.iso8601, gems: gem_license_infos.map { |info| gem_payload(info) } } write_output(JSON.pretty_generate(payload)) end |
#render_check_result(check_result) ⇒ String
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/licensure/formatters/json.rb', line 23 def render_check_result(check_result) payload = { generated_at: Time.now.iso8601, summary: { total: check_result.passed.size + check_result.violations.size + check_result.warnings.size, passed: check_result.passed.size, violations: check_result.violations.size, warnings: check_result.warnings.size }, violations: check_result.violations.map { |violation| violation_payload(violation) }, warnings: check_result.warnings.map { |warning| violation_payload(warning) }, passed: check_result.passed.map { |info| gem_payload(info) } } write_output(JSON.pretty_generate(payload)) end |