class RequestLogAnalyzer::Source::Base
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.
Attributes
The current Request
object that is being parsed
The FileFormat
instance that describes the format of this source.
A hash of options
The total number of parsed lines
The total number of parsed requests.
The number of skipped lines because of warnings
The total number of skipped requests because of filters.
Public Class Methods
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
# File lib/request_log_analyzer/source.rb 39 def initialize(format, options = {}) 40 @options = options 41 @file_format = format 42 end
Public Instance Methods
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.
# File lib/request_log_analyzer/source.rb 53 def each_request(_options = {}, &_block) # :yields: request 54 true 55 end
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.
# File lib/request_log_analyzer/source.rb 59 def finalize 60 end
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.
# File lib/request_log_analyzer/source.rb 47 def prepare 48 end