lib/request_log_analyzer/controller.rb in request-log-analyzer-1.1.2 vs lib/request_log_analyzer/controller.rb in request-log-analyzer-1.1.3
- old
+ new
@@ -62,11 +62,11 @@
options.store(:source_files, arguments.parameters)
end
controller = Controller.new(RequestLogAnalyzer::Source::LogParser.new(file_format, options), options)
- options[:assume_correct_order] = arguments[:assume_correct_order]
+ options[:parse_strategy] = arguments[:parse_strategy]
# register filters
if arguments[:after] || arguments[:before]
filter_options = {}
filter_options[:after] = DateTime.parse(arguments[:after])
@@ -158,19 +158,25 @@
def add_filter(filter, filter_options = {})
filter = RequestLogAnalyzer::Filter.const_get(RequestLogAnalyzer::to_camelcase(filter)) if filter.kind_of?(Symbol)
@filters << filter.new(file_format, @options.merge(filter_options))
end
+ # Push a request through the entire filterchain (@filters).
+ # <tt>request</tt> The request to filter.
+ # Returns the filtered request or nil.
def filter_request(request)
@filters.each do |filter|
request = filter.filter(request)
return nil if request.nil?
end
return request
end
+ # Push a request to all the aggregators (@aggregators).
+ # <tt>request</tt> The request to push to the aggregators.
def aggregate_request(request)
+ return unless request
@aggregators.each { |agg| agg.aggregate(request) }
end
# Runs RequestLogAnalyzer
# 1. Call prepare on every aggregator
@@ -180,16 +186,14 @@
# 4. Call finalize on every aggregator
# 5. Call report on every aggregator
# 6. Finalize Source
def run!
- @filters.each { |filter| filter.prepare }
@aggregators.each { |agg| agg.prepare }
begin
@source.each_request do |request|
- request = filter_request(request)
- aggregate_request(request) unless request.nil?
+ aggregate_request(filter_request(request))
end
rescue Interrupt => e
handle_progress(:interrupted)
puts "Caught interrupt! Stopped parsing."
end