Class: CC::Analyzer::Formatters::JSONFormatter
- Inherits:
-
Formatter
- Object
- Formatter
- CC::Analyzer::Formatters::JSONFormatter
show all
- Defined in:
- lib/cc/analyzer/formatters/json_formatter.rb
Constant Summary
Constants inherited
from Formatter
Formatter::InvalidFormatterError
Instance Method Summary
collapse
Methods inherited from Formatter
#close, #engine_running
Constructor Details
Returns a new instance of JSONFormatter.
5
6
7
8
|
# File 'lib/cc/analyzer/formatters/json_formatter.rb', line 5
def initialize(filesystem)
@filesystem = filesystem
@has_begun = false
end
|
Instance Method Details
#failed(output) ⇒ Object
30
31
32
33
34
|
# File 'lib/cc/analyzer/formatters/json_formatter.rb', line 30
def failed(output)
$stderr.puts "\nAnalysis failed with the following output:"
$stderr.puts output
exit 1
end
|
#finished ⇒ Object
14
15
16
|
# File 'lib/cc/analyzer/formatters/json_formatter.rb', line 14
def finished
print "]\n"
end
|
#started ⇒ Object
10
11
12
|
# File 'lib/cc/analyzer/formatters/json_formatter.rb', line 10
def started
print "["
end
|
#write(data) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/cc/analyzer/formatters/json_formatter.rb', line 18
def write(data)
document = JSON.parse(data)
document["engine_name"] = current_engine.name
if @has_begun
print ",\n"
end
print document.to_json
@has_begun = true
end
|