Class: RequestLogAnalyzer::Source::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/request_log_analyzer/source.rb

Overview

The base Source class. All other sources should inherit from this class.

A source implememtation should at least implement the each_request method, which should yield RequestLogAnalyzer::Request instances that will be fed through the pipleine.

Direct Known Subclasses

LogParser

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format, options = {}) ⇒ Base

Initializer, which will register the file format and save any options given as a hash.

format

The file format instance

options

A hash of options that can be used by a specific Source implementation



39
40
41
42
# File 'lib/request_log_analyzer/source.rb', line 39

def initialize(format, options = {})
  @options     = options
  @file_format = format
end

Instance Attribute Details

#current_requestObject (readonly)

The current Request object that is being parsed



19
20
21
# File 'lib/request_log_analyzer/source.rb', line 19

def current_request
  @current_request
end

#file_formatObject (readonly)

The FileFormat instance that describes the format of this source.



34
35
36
# File 'lib/request_log_analyzer/source.rb', line 34

def file_format
  @file_format
end

#optionsObject (readonly)

A hash of options



16
17
18
# File 'lib/request_log_analyzer/source.rb', line 16

def options
  @options
end

#parsed_linesObject (readonly)

The total number of parsed lines



22
23
24
# File 'lib/request_log_analyzer/source.rb', line 22

def parsed_lines
  @parsed_lines
end

#parsed_requestsObject (readonly)

The total number of parsed requests.



28
29
30
# File 'lib/request_log_analyzer/source.rb', line 28

def parsed_requests
  @parsed_requests
end

#skipped_linesObject (readonly)

The number of skipped lines because of warnings



25
26
27
# File 'lib/request_log_analyzer/source.rb', line 25

def skipped_lines
  @skipped_lines
end

#skipped_requestsObject (readonly)

The total number of skipped requests because of filters.



31
32
33
# File 'lib/request_log_analyzer/source.rb', line 31

def skipped_requests
  @skipped_requests
end

Instance Method Details

#each_request(_options = {}, &_block) ⇒ Object

This function is called to actually produce the requests that will be send into the pipeline. The implementation should yield instances of RequestLogAnalyzer::Request.

options

A Hash of options that can be used in the implementation.



53
54
55
# File 'lib/request_log_analyzer/source.rb', line 53

def each_request(_options = {}, &_block) # :yields: request
  true
end

#finalizeObject

This function is called after RequestLogAnalyzer::Source::Base#each_request finished. Any code to wrap up, free resources, etc. can be put in this method.



59
60
# File 'lib/request_log_analyzer/source.rb', line 59

def finalize
end

#prepareObject

The prepare method is called before the RequestLogAnalyzer::Source::Base#each_request method is called. Use this method to implement any initialization that should occur before this source can produce Request instances.



47
48
# File 'lib/request_log_analyzer/source.rb', line 47

def prepare
end