Sha256: 08adad547d3b354a97a8fff3a542ac12d086676e1bb4257604c4513638adf3b7
Contents?: true
Size: 1.06 KB
Versions: 7
Compression:
Stored size: 1.06 KB
Contents
# { # "gsub": { # "field": "", # "match": "", # "replace": "" # } # } module Anschel class Filter def gsub conf, stats, log field = conf.delete :field match = conf.delete :match replace = conf.delete :replace raise 'Missing required "field" for "gsub" filter' if field.nil? raise 'Missing required "match" for "gsub" filter' if match.nil? raise 'Missing required "replace" for "gsub" filter' if replace.nil? field = field.to_sym match = match.is_a?(Array) ? match : [ match ] match = match.map { |m| Regexp.new m } stats.create 'filter-gsub' stats.create 'filter-gsub-skipped' log.info event: 'filter-compiled', kind: 'gsub', \ field: field, match: match, replace: replace lambda do |event| unless event[field] stats.inc 'filter-gsub-skipped' return event end match.each do |m| event[field].gsub! m, replace end stats.inc 'filter-gsub' filtered event, conf end end end end
Version data entries
7 entries across 7 versions & 1 rubygems