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

DatabaseLoader, 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



48
49
50
51
# File 'lib/request_log_analyzer/source.rb', line 48

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

Instance Attribute Details

#current_requestObject (readonly)

The current Request object that is being parsed



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

def current_request
  @current_request
end

#file_formatObject (readonly)

The FileFormat instance that describes the format of this source.



43
44
45
# File 'lib/request_log_analyzer/source.rb', line 43

def file_format
  @file_format
end

#optionsObject (readonly)

A hash of options



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

def options
  @options
end

#parsed_linesObject (readonly)

The total number of parsed lines



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

def parsed_lines
  @parsed_lines
end

#parsed_requestsObject (readonly)

The total number of parsed requests.



37
38
39
# File 'lib/request_log_analyzer/source.rb', line 37

def parsed_requests
  @parsed_requests
end

#skipped_linesObject (readonly)

The number of skipped lines because of warnings



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

def skipped_lines
  @skipped_lines
end

#skipped_requestsObject (readonly)

The total number of skipped requests because of filters.



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

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.



62
63
64
# File 'lib/request_log_analyzer/source.rb', line 62

def each_request(options = {}, &block) # :yields: request
  return 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.



68
69
# File 'lib/request_log_analyzer/source.rb', line 68

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.



56
57
# File 'lib/request_log_analyzer/source.rb', line 56

def prepare
end