Class: Terracop::Formatters::Json

Inherits:
Object
  • Object
show all
Defined in:
lib/terracop/formatters/json.rb

Overview

Generates a JSON document listing all the offenses. Ideal to generate ouputs to be digested by other tools in a CI pipeline.

Instance Method Summary collapse

Instance Method Details

#generate(resources) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/terracop/formatters/json.rb', line 10

def generate(resources)
  {
    metadata: meta,
    resources: build_resources(resources),
    summary: {
      offense_count: resources.values.map(&:count).sum,
      resource_count: resources.count
    }
  }.to_json
end