Class: Fluent::Auditify::Plugin::V1DuplicatedId
- Defined in:
- lib/fluent/auditify/plugin/conf_v1dupid.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #parse(conf, options = {}) ⇒ Object
-
#supported_platform? ⇒ Boolean
The duplicated @id is detected by default, but treated as Fluent::ConfigError and does not show problematic location in configuration file.
Methods inherited from Conf
#artifact, #conf?, #disabled?, #file_get_contents, #file_readlines_each, #guilty, #initialize, #plugin_defs, #polish, #read_with_include_directive, #supported_file_extension?, #surround_text, #yaml?
Methods inherited from Base
Constructor Details
This class inherits a constructor from Fluent::Auditify::Plugin::Conf
Instance Method Details
#parse(conf, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fluent/auditify/plugin/conf_v1dupid.rb', line 21 def parse(conf, ={}) begin content = file_get_contents(conf) root = Fluent::Config::V1Parser.parse(content, conf) ids = [] root.elements.collect do |element| ids << element["@id"] end duplicated_ids = ids.uniq.select do |id| ids.count(id) > 1 end duplicated_ids.each do |id| file_readlines_each(conf) do |line, index| next unless line.split.size == 2 if line.split == ["@id", id] guilty(:error, "#{id} is duplicated", {path: conf, line: index + 1, content: line.chomp, category: :syntax, plugin: :v1dupid}) end end end rescue => e log.error("parse error: #{e.message}") end end |
#supported_platform? ⇒ Boolean
The duplicated @id is detected by default, but treated as Fluent::ConfigError and does not show problematic location in configuration file. This plugin demonstrate how to implement simple plugin
17 18 19 |
# File 'lib/fluent/auditify/plugin/conf_v1dupid.rb', line 17 def supported_platform? :any end |