This processor reports the number of entries processed.
Create a count-entries report.
Recognized options include:
:label
Label to use for the report. If provided, the report is returned as a string of the form “#{label}#{value}” If set to nil or absent, the report is returned as an integer.
:omit_unknown_data
If set to true, omits #unknown_data from the count. Default is false.
:omit_attributes
If set to true, omits attributes from the count. Default is false.
:omit_record_delimiters
If set to true, omits #begin_record and #end_record from the count. Default is false.
# File lib/sawmill/entry_processor/count_entries.rb, line 66 def initialize(opts_={}) @label = opts_[:label] @omit_unknown_data = opts_[:omit_unknown_data] @omit_attributes = opts_[:omit_attributes] @omit_record_delimiters = opts_[:omit_record_delimiters] @finished = false @count = 0 end
# File lib/sawmill/entry_processor/count_entries.rb, line 91 def attribute(entry_) @count += 1 unless @finished || @omit_attributes true end
# File lib/sawmill/entry_processor/count_entries.rb, line 76 def begin_record(entry_) @count += 1 unless @finished || @omit_record_delimiters true end
# File lib/sawmill/entry_processor/count_entries.rb, line 81 def end_record(entry_) @count += 1 unless @finished || @omit_record_delimiters true end
# File lib/sawmill/entry_processor/count_entries.rb, line 101 def finish @finished = true @label ? "#{@label}#{@count}" : @count end
# File lib/sawmill/entry_processor/count_entries.rb, line 86 def message(entry_) @count += 1 unless @finished true end
# File lib/sawmill/entry_processor/count_entries.rb, line 96 def unknown_data(entry_) @count += 1 unless @finished || @omit_unknown_data true end