Class: Kamal::Lint::Formatters::Json
- Inherits:
-
Object
- Object
- Kamal::Lint::Formatters::Json
- Defined in:
- lib/kamal/lint/formatters/json.rb
Instance Method Summary collapse
-
#initialize(io: $stdout) ⇒ Json
constructor
A new instance of Json.
- #render(result) ⇒ Object
- #render_fix_summary(result) ⇒ Object
Constructor Details
#initialize(io: $stdout) ⇒ Json
Returns a new instance of Json.
9 10 11 |
# File 'lib/kamal/lint/formatters/json.rb', line 9 def initialize(io: $stdout) @io = io end |
Instance Method Details
#render(result) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kamal/lint/formatters/json.rb', line 13 def render(result) payload = { kamal_lint_version: Kamal::Lint::VERSION, kamal_version: result.context.kamal_version, file: result.context.file_for_finding, destination: result.context.destination, findings: result.findings.map(&:to_h), summary: { errors: result.errors.size, warnings: result.warnings.size, infos: result.infos.size, autofixable: result.findings.count(&:autofixable?) } } @io.puts JSON.pretty_generate(payload) end |
#render_fix_summary(result) ⇒ Object
30 31 32 33 34 |
# File 'lib/kamal/lint/formatters/json.rb', line 30 def render_fix_summary(result) return if result.fixed.empty? @io.puts JSON.pretty_generate(fixed: result.fixed.map(&:to_h)) end |