Class: Fluent::Auditify::Plugin::YamlConf
Instance Method Summary
collapse
#detect_wrong_at_directive_syntax
#detect_broken_config_param_indent_fallback, #detect_wrong_config_element_fallback
#detect_no_match, #detect_no_source, #detect_wrong_directive
Constructor Details
Returns a new instance of YamlConf.
27
28
29
|
# File 'lib/fluent/auditify/plugin/conf_yaml.rb', line 27
def initialize
super
end
|
Instance Method Details
#fallback_detector?(method) ⇒ Boolean
68
69
70
71
|
# File 'lib/fluent/auditify/plugin/conf_yaml.rb', line 68
def fallback_detector?(method)
method.to_s.start_with?('detect_') and
method.to_s.end_with?('_fallback')
end
|
#parse(conf, options = {}) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/fluent/auditify/plugin/conf_yaml.rb', line 31
def parse(conf, options={})
begin
root = Fluent::Config::YamlParser.parse(conf)
self.methods.each do |method|
if standard_detector?(method)
log.debug { "#{self.class}\##{method}" }
send(method, root, conf)
end
end
rescue NoMethodError => e
log.debug { "failed to parse #{conf} with: #{e.message}" }
yaml = YAML.load(file_get_contents(conf))
self.methods.each do |method|
if fallback_detector?(method)
log.debug { "#{self.class}\##{method}" }
send(method, yaml, conf)
end
end
rescue Psych::SyntaxError => e
log.debug { "failed to parse #{conf} with: #{e.message}" }
self.methods.each do |method|
if syntax_detector?(method)
log.debug { "#{self.class}\##{method}" }
send(method, conf)
end
end
end
end
|
#standard_detector?(method) ⇒ Boolean
62
63
64
65
66
|
# File 'lib/fluent/auditify/plugin/conf_yaml.rb', line 62
def standard_detector?(method)
method.to_s.start_with?('detect_') and
not method.to_s.end_with?('_fallback') and
not method.to_s.end_with?('_syntax')
end
|
#supported_file_extension? ⇒ Boolean
23
24
25
|
# File 'lib/fluent/auditify/plugin/conf_yaml.rb', line 23
def supported_file_extension?
[:yaml, :yml]
end
|
19
20
21
|
# File 'lib/fluent/auditify/plugin/conf_yaml.rb', line 19
def supported_platform?
:any
end
|
#syntax_detector?(method) ⇒ Boolean
73
74
75
76
|
# File 'lib/fluent/auditify/plugin/conf_yaml.rb', line 73
def syntax_detector?(method)
method.to_s.start_with?('detect_') and
method.to_s.end_with?('_syntax')
end
|
#unknown_directive?(root) ⇒ Boolean
78
79
80
|
# File 'lib/fluent/auditify/plugin/conf_yaml.rb', line 78
def unknown_directive?(root)
root.elements.empty?
end
|