Class: CC::Analyzer::Formatters::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/analyzer/formatters/formatter.rb

Direct Known Subclasses

HTMLFormatter, JSONFormatter, PlainTextFormatter

Constant Summary collapse

InvalidFormatterError =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(filesystem, output = $stdout) ⇒ Formatter

Returns a new instance of Formatter.



5
6
7
8
# File 'lib/cc/analyzer/formatters/formatter.rb', line 5

def initialize(filesystem, output = $stdout)
  @filesystem = filesystem
  @output = output
end

Instance Method Details

#closeObject



37
38
# File 'lib/cc/analyzer/formatters/formatter.rb', line 37

def close
end

#engine_running(engine) ⇒ Object



27
28
29
30
31
32
# File 'lib/cc/analyzer/formatters/formatter.rb', line 27

def engine_running(engine)
  @current_engine = engine
  yield
ensure
  @current_engine = nil
end

#failed(_output) ⇒ Object



40
41
# File 'lib/cc/analyzer/formatters/formatter.rb', line 40

def failed(_output)
end

#finishedObject



34
35
# File 'lib/cc/analyzer/formatters/formatter.rb', line 34

def finished
end

#startedObject



24
25
# File 'lib/cc/analyzer/formatters/formatter.rb', line 24

def started
end

#write(data) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cc/analyzer/formatters/formatter.rb', line 10

def write(data)
  json = JSON.parse(data)
  json["engine_name"] = current_engine.name

  case json["type"].downcase
  when "issue"
    issues << json
  when "warning"
    warnings << json
  else
    raise "Invalid type found: #{json["type"]}"
  end
end