Post processors are run after all test are finished and the results are written to the output file. A post processor can either be a block of code, or an existing post processor module. To setup a post processor simply do this:
post_process do # Some code that is executed after the tests, like a database update, twitter post, email etc. end
Or use one of the predefined post processor or write one yourself:
post_process :statistics post_process BigBench::PostProcessor::Statistics post_process "statistics"
All the upper lines include the same post processor. Symbols and strings are camelized and constantized as the module name.
Every post processor block or module supports the following methods and has full ActionView::Helper support.
A method that iterates through every collected tracking. It automatically returns a hash with a single tracking of the following form:
{ :elapsed => 2.502132, :start => 1333986292.1755981, :stop => 1333986293.618884, :duration => 1443, :benchmark => "index page", :url => "http://www.google.de/", :path => "/", :method => "get", :status => 200 }
It can be used like this:
post_process do total_trackings, total_errors = 0, 0 each_tracking do |tracking| total_trackings += 1 total_errors += 1 unless tracking[:status] == 200 end Twitter.post "Just run BigBench with #{total_trackings} trackings and #{total_errors} errors." end
Adds a new processor
# File lib/bigbench/post_processor.rb, line 96 def self.add(processor = nil, &block) @processors << Processor.new(processor, &block) end
Returns all initialized processors
# File lib/bigbench/post_processor.rb, line 101 def self.all @processors end
Resets all post processors
# File lib/bigbench/post_processor.rb, line 106 def self.reset! @processors = [] end
Runs all post processors in the order they were defined
# File lib/bigbench/post_processor.rb, line 57 def self.run! all.each{ |processor| processor.run! } end