Class: Straycall::Report::JSON

Inherits:
Object
  • Object
show all
Defined in:
lib/straycall/report/json.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ JSON

Returns a new instance of JSON.



9
10
11
# File 'lib/straycall/report/json.rb', line 9

def initialize(path)
  @path = path
end

Instance Method Details

#write(violations) ⇒ Object



13
14
15
16
# File 'lib/straycall/report/json.rb', line 13

def write(violations)
  FileUtils.mkdir_p(File.dirname(@path))
  File.write(@path, ::JSON.pretty_generate(version: 1, violations: violations.map(&:to_h)) << "\n")
end