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

#initializeFileReporter

Returns a new instance of FileReporter.



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

def initialize
  super

  @file_path = '/tmp/tainted_love.json'
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



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

def add_warning(warning)
  super(warning)

  update_file
end

#update_fileObject



23
24
25
# File 'lib/tainted_love/reporter/file_reporter.rb', line 23

def update_file
  File.write(@file_path, @warnings.to_json)
end