Class: Txray::Reporters::Json

Inherits:
Object
  • Object
show all
Defined in:
lib/txray/reporters/json.rb

Instance Method Summary collapse

Constructor Details

#initialize(io: $stdout) ⇒ Json

Returns a new instance of Json.



8
9
10
# File 'lib/txray/reporters/json.rb', line 8

def initialize(io: $stdout)
  @io = io
end

Instance Method Details

#report(result) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/txray/reporters/json.rb', line 12

def report(result)
  @io.puts JSON.pretty_generate(
    version: Txray::VERSION,
    summary: { files: result.files.size, offenses: result.offenses.size, severities: result.counts,
               skipped: result.skipped.to_a },
    offenses: result.offenses.map(&:to_h)
  )
end