Class: ApacheCrunch::CountBy

Inherits:
ProcedureRoutine show all
Defined in:
lib/procedure_dsl.rb

Overview

DSL routine that returns the count of entries with each found value of the given block

You might for instance run this with the block { status }, and you’d get back something like => 941, “301” => 41, “404” => 2, “500” => 0

Instance Method Summary collapse

Methods inherited from ProcedureRoutine

#finish, #initialize, #method_missing

Constructor Details

This class inherits a constructor from ApacheCrunch::ProcedureRoutine

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ApacheCrunch::ProcedureRoutine

Instance Method Details

#execute(&blk) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/procedure_dsl.rb', line 116

def execute(&blk)
    counts = {}
    while @_current_entry = @_log_parser.next_entry
        val = instance_eval(&blk)
        if counts.key?(val)
            counts[val] += 1
        else
            counts[val] = 1
        end
    end
    return counts
end