Sha256: 5dfb196a927ebb576293f38047d6cafe912e4d820e7188bd5e5cc0d7eb452dd8

Contents?: true

Size: 865 Bytes

Versions: 2

Compression:

Stored size: 865 Bytes

Contents

module RequestLogAnalyzer::Aggregator
  # Echo Aggregator. Writes everything to the screen when it is passed to this aggregator
  class Echo < Base
    attr_accessor :warnings

    def prepare
      @warnings = []
    end

    # Display every parsed line immediately to the terminal
    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

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

    # Display every warning in the report when finished parsing
    def report(output)
      output.title('Warnings during parsing')
      @warnings.each { |w| output.puts(w) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
request-log-analyzer-1.13.4 lib/request_log_analyzer/aggregator/echo.rb
request-log-analyzer-1.13.3 lib/request_log_analyzer/aggregator/echo.rb