Module: Moult::Formatters::Json
- Defined in:
- lib/moult/formatters/json.rb
Overview
Emits the typed JSON output contract (schema/hotspots.schema.json). Renders straight from Report#to_h; only presentation concerns (limiting) live here, so the serialized shape can never drift from the result model.
Class Method Summary collapse
-
.render(report, limit: nil) ⇒ String
Pretty-printed JSON.
Class Method Details
.render(report, limit: nil) ⇒ String
Returns pretty-printed JSON.
16 17 18 19 20 |
# File 'lib/moult/formatters/json.rb', line 16 def render(report, limit: nil) data = report.to_h data[:hotspots] = data[:hotspots].first(limit) if limit JSON.pretty_generate(data) end |