Sha256: eaa312b41a3d1d82a676cc0283abd5be40abc5482834b677dabf652579277cb3
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.trace 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