fluent-plugin-xml-simple-filter 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/fluent-plugin-xml-simple-filter.gemspec +2 -2
- data/lib/fluent/plugin/filter_xml_simple.rb +28 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c32107fa948e00e92889c682466802ec27f2c4d2
|
4
|
+
data.tar.gz: 49514123fdf57baecabda91fbe9cf5855e220c13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c932123d6bcf1a3a6f189299811ac44a32449a910c62a99c734f97d590cca597335697b33e9a8a9dcd3c6d65e4b04aa342f77d06026b7c91d950a0d5061f1bbe
|
7
|
+
data.tar.gz: bba3e2c033915283c5524ab6ca582fa603240a75af86f3643399e4f3ae5a6030964c2e596c609fdbd29be22cb56dcbdda54585ec3dfc37b177dbdca7d0007fd7
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: fluent-plugin-xml-simple-filter 0.0.
|
5
|
+
# stub: fluent-plugin-xml-simple-filter 0.0.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "fluent-plugin-xml-simple-filter".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
@@ -6,6 +6,9 @@ module Fluent
|
|
6
6
|
|
7
7
|
config_param :fields, :string
|
8
8
|
|
9
|
+
config_param :try_convert_times, :boolean, :default => true # try to convert values in hash to times
|
10
|
+
config_param :field_name_postfix, :string, :default => 'hash' # if set will create hash in new field with postfix (xml => xml_hash)
|
11
|
+
|
9
12
|
def configure(conf)
|
10
13
|
super
|
11
14
|
|
@@ -31,11 +34,35 @@ module Fluent
|
|
31
34
|
def filter(tag, time, record)
|
32
35
|
self.fields.each { |field|
|
33
36
|
if record.key?(field)
|
34
|
-
|
37
|
+
field_name = field
|
38
|
+
|
39
|
+
if self.field_name_postfix
|
40
|
+
field_name = [field, self.field_name_postfix].join '_'
|
41
|
+
end
|
42
|
+
|
43
|
+
hash = @parser.parse(record[field])
|
44
|
+
|
45
|
+
if try_convert_times
|
46
|
+
hash = convert_times(hash)
|
47
|
+
end
|
48
|
+
|
49
|
+
record[field_name] = hash
|
35
50
|
end
|
36
51
|
}
|
37
52
|
|
38
53
|
record
|
39
54
|
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def convert_times(hash)
|
59
|
+
hash.each { |key, value| value.class == Hash ? convert_times(value) : try_to_convert(value) { |x| Time.parse(x) } }
|
60
|
+
end
|
61
|
+
|
62
|
+
def try_to_convert(value, &block)
|
63
|
+
block.call(value)
|
64
|
+
rescue ArgumentError
|
65
|
+
value
|
66
|
+
end
|
40
67
|
end
|
41
68
|
end
|