lib/request_log_analyzer/controller.rb in request-log-analyzer-1.1.1 vs lib/request_log_analyzer/controller.rb in request-log-analyzer-1.1.2

- old
+ new

@@ -129,11 +129,11 @@ # <tt>message</tt> Current state (:started, :finished, :interupted or :progress). # <tt>value</tt> File or current line. def handle_progress(message, value = nil) case message when :started - @progress_bar = CommandLine::ProgressBar.new(File.basename(value), File.size(value)) + @progress_bar = CommandLine::ProgressBar.new(File.basename(value), File.size(value), STDOUT) when :finished @progress_bar.finish @progress_bar = nil when :interrupted if @progress_bar @@ -158,10 +158,22 @@ 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 + def filter_request(request) + @filters.each do |filter| + request = filter.filter(request) + return nil if request.nil? + end + return request + end + + def aggregate_request(request) + @aggregators.each { |agg| agg.aggregate(request) } + end + # Runs RequestLogAnalyzer # 1. Call prepare on every aggregator # 2. Generate requests from source object # 3. Filter out unwanted requests # 4. Call aggregate for remaning requests on every aggregator @@ -173,11 +185,11 @@ @filters.each { |filter| filter.prepare } @aggregators.each { |agg| agg.prepare } begin @source.each_request do |request| - @filters.each { |filter| request = filter.filter(request) } - @aggregators.each { |agg| agg.aggregate(request) } if request + request = filter_request(request) + aggregate_request(request) unless request.nil? end rescue Interrupt => e handle_progress(:interrupted) puts "Caught interrupt! Stopped parsing." end