Sha256: 61e98cf90cd7c3a97b14ee0fe01b4cf5dc991c05608f7b1f3cc820f510078591
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
module Fluent module FilterUtil def toMap (str) str.split(/\s*,\s*/).map do|pair| k, v = pair.split(/\s*:\s*/, 2) if v =~ /^\d+$/ v = v.to_i elsif v =~ /^[\d\.]+(e\d+)?$/ v = v.to_f elsif v =~ /^\/(\\\/|[^\/])+\/$/ v = Regexp.new(v.gsub(/^\/|\/$/, '')) else v = v.gsub(/^[\"\']|[\"\']$/, '') end [k, v] end end def passRules (record) if @all == 'allow' @denies.each do |deny| if (deny[1].is_a? Regexp and record.has_key?(deny[0]) and record[deny[0]].match(deny[1])) or record[deny[0]] == deny[1] @allows.each do |allow| if (allow[1].is_a? Regexp and record.has_key?(allow[0]) and record[allow[0]].match(allow[1])) or record[allow[0]] == allow[1] return true end end return false end end return true else @allows.each do |allow| if (allow[1].is_a? Regexp and record.has_key?(allow[0]) and record[allow[0]].match(allow[1])) or record[allow[0]] == allow[1] @denies.each do |deny| if (deny[1].is_a? Regexp and record.has_key?(deny[0]) and record[deny[0]].match(deny[1])) or record[deny[0]] == deny[1] return false end end return true end end return false end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-filter-0.0.4 | lib/fluent/plugin/filter_util.rb |