Class: Fluent::Auditify::Parser::V1ConfigParser

Inherits:
V1ConfigBaseParser show all
Defined in:
lib/fluent/auditify/parser/v1config.rb

Instance Method Summary collapse

Instance Method Details

#eval(object, options = {}) ⇒ Object

expand @include directive



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/fluent/auditify/parser/v1config.rb', line 112

def eval(object, options={})
  base_dir = options[:base_dir] || ''
  path = options[:path] || ''
  modified = []
  object.each do |directive|
    directive[:__BASE__] = base_dir
    directive[:__PATH__] = path
    unless directive[:include]
      if directive[:body]
        modified << eval_body(directive, options)
      else
        modified << directive
      end
      next
    end
    # top-level @include
    eval_include(directive, options).each do |child|
      child[:__PARENT__] = path
      modified << child
    end
  end
  modified
end

#find_nth_element(object, nth: 1, elements: []) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/fluent/auditify/parser/v1config.rb', line 136

def find_nth_element(object, nth: 1, elements: [])
  count = 0
  elements.each do |element|
    if element[object.intern]
      count += 1
      if nth == count
        return element
      end
    end
  end
  nil
end