Class: Fluent::Auditify::Parser::V1ConfigParser
- Inherits:
-
V1ConfigBaseParser
- Object
- Parslet::Parser
- V1ConfigBaseParser
- Fluent::Auditify::Parser::V1ConfigParser
- Defined in:
- lib/fluent/auditify/parser/v1config.rb
Instance Method Summary collapse
-
#eval(object, options = {}) ⇒ Object
expand @include directive.
- #find_nth_element(object, nth: 1, elements: []) ⇒ Object
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, ={}) base_dir = [:base_dir] || '' path = [:path] || '' modified = [] object.each do |directive| directive[:__BASE__] = base_dir directive[:__PATH__] = path unless directive[:include] if directive[:body] modified << eval_body(directive, ) else modified << directive end next end # top-level @include eval_include(directive, ).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 |