fluent-plugin-xml-simple-filter 0.0.19 → 0.0.20
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 +19 -5
- 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: f40e60a3c87d21fdc4f35457788cdbd8eced1f70
|
4
|
+
data.tar.gz: d8a086c7c2f506b2edf9bb50f347cffeb866bdb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 830780c92d919e6a8697dba997b7144ad00647f006b358b10f78f574b1c2a6d05d20a7ed65ee471d59b720e32107af48ad441eda950d6ff33447ca35141167a1
|
7
|
+
data.tar.gz: db9596b1e8cd0c3598b8d12329a14da612f47a491117fa75a6e49ff5e7597cfd751fb448c3311b4b45bde7c718125a6fb87ebc7130952fa75a3e9e1e8fd8e316
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.20
|
@@ -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.20 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.20"
|
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,7 +6,7 @@ module Fluent
|
|
6
6
|
|
7
7
|
config_param :fields, :string
|
8
8
|
|
9
|
-
config_param :try_convert_times, :bool, :default =>
|
9
|
+
config_param :try_convert_times, :bool, :default => false # try to convert values in hash to timestamps
|
10
10
|
config_param :time_format, :string, :default => nil
|
11
11
|
config_param :field_name_postfix, :string, :default => 'hash' # if set will create hash in new field with postfix (xml => xml_hash)
|
12
12
|
|
@@ -55,16 +55,30 @@ module Fluent
|
|
55
55
|
|
56
56
|
private
|
57
57
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
58
|
+
def convert_to_time(value)
|
59
|
+
if value.class == Hash
|
60
|
+
convert_times(value)
|
61
|
+
elsif value.class == Array
|
62
|
+
convert_times_array(value)
|
63
|
+
else
|
64
|
+
try_to_convert(value) { |x|
|
61
65
|
(self.time_format ? Time.strptime(x, self.time_format) : Time.parse(x)).to_i
|
62
66
|
}
|
67
|
+
end
|
68
|
+
end
|
63
69
|
|
64
|
-
|
70
|
+
def convert_times(hash)
|
71
|
+
hash.map { |key, value|
|
72
|
+
[key, convert_to_time(value)]
|
65
73
|
}.to_h
|
66
74
|
end
|
67
75
|
|
76
|
+
def convert_times_array(array)
|
77
|
+
array.map { |value|
|
78
|
+
convert_to_time(value)
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
68
82
|
def try_to_convert(value, &block)
|
69
83
|
block.call(value)
|
70
84
|
rescue Exception => e
|