Class: TaintedLove::Reporter::FileReporter

Inherits:
Base
  • Object
show all
Defined in:
lib/tainted_love/reporter/file_reporter.rb

Overview

Reporter that outputs warnings into a JSON file

Instance Attribute Summary collapse

Attributes inherited from Base

#warnings

Instance Method Summary collapse

Methods inherited from Base

#store_warning

Constructor Details

#initialize(file_path = '/tmp/tainted_love.json') ⇒ FileReporter

Returns a new instance of FileReporter.



11
12
13
14
# File 'lib/tainted_love/reporter/file_reporter.rb', line 11

def initialize(file_path = '/tmp/tainted_love.json')
  super()
  @file_path = file_path
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



9
10
11
# File 'lib/tainted_love/reporter/file_reporter.rb', line 9

def file_path
  @file_path
end

Instance Method Details

#add_warning(warning) ⇒ Object



16
17
18
19
20
# File 'lib/tainted_love/reporter/file_reporter.rb', line 16

def add_warning(warning)
  super(warning)

  update_file
end

#update_fileObject



22
23
24
25
26
27
28
29
# File 'lib/tainted_love/reporter/file_reporter.rb', line 22

def update_file
  report = {
    'warnings': @warnings,
    'application_path': Dir.pwd,
  }

  File.write(@file_path, report.to_json)
end