Module: Fluent::Plugin::FilterUtil
- Included in:
- FilterFilter, FilterOutput
- Defined in:
- lib/fluent/plugin/filter_util.rb
Instance Method Summary collapse
Instance Method Details
#passRules(record) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fluent/plugin/filter_util.rb', line 19 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 |
#toMap(str, delim) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fluent/plugin/filter_util.rb', line 3 def toMap (str, delim) str.split(/\s*#{delim}\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 |