Class: EagerEye::Reporters::Json

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

Instance Attribute Summary

Attributes inherited from Base

#issues

Instance Method Summary collapse

Constructor Details

#initialize(issues, pretty: false) ⇒ Json

Returns a new instance of Json.



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

def initialize(issues, pretty: false)
  super(issues)
  @pretty = pretty
end

Instance Method Details

#reportObject



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

def report
  result = {
    summary: summary_hash,
    issues: issues.map(&:to_h)
  }

  @pretty ? JSON.pretty_generate(result) : JSON.generate(result)
end