Class: RequestLogAnalyzer::Aggregator::Echo

Inherits:
Base
  • Object
show all
Defined in:
lib/request_log_analyzer/aggregator/echo.rb

Overview

Echo Aggregator. Writes everything to the screen when it is passed to this aggregator

Instance Attribute Summary collapse

Attributes inherited from Base

#options, #source

Instance Method Summary collapse

Methods inherited from Base

#finalize, #initialize, #source_change

Constructor Details

This class inherits a constructor from RequestLogAnalyzer::Aggregator::Base

Instance Attribute Details

#warningsObject

Returns the value of attribute warnings.



4
5
6
# File 'lib/request_log_analyzer/aggregator/echo.rb', line 4

def warnings
  @warnings
end

Instance Method Details

#aggregate(request) ⇒ Object

Display every parsed line immediately to the terminal



11
12
13
14
15
# File 'lib/request_log_analyzer/aggregator/echo.rb', line 11

def aggregate(request)
  puts "\nRequest: \n" + request.lines.map do |l|
    "\t#{l[:lineno]}:#{l[:line_type]}: #{l.reject { |(k, _)| [:lineno, :line_type].include?(k) }.inspect}"
  end.join("\n")
end

#prepareObject



6
7
8
# File 'lib/request_log_analyzer/aggregator/echo.rb', line 6

def prepare
  @warnings = []
end

#report(output) ⇒ Object

Display every warning in the report when finished parsing



23
24
25
26
# File 'lib/request_log_analyzer/aggregator/echo.rb', line 23

def report(output)
  output.title('Warnings during parsing')
  @warnings.each { |w| output.puts(w) }
end

#warning(type, message, lineno) ⇒ Object

Capture all warnings during parsing



18
19
20
# File 'lib/request_log_analyzer/aggregator/echo.rb', line 18

def warning(type, message, lineno)
  @warnings << "WARNING #{type.inspect} on line #{lineno}: #{message}"
end