fluent-plugin-multi-format-parser 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cddae10dd64bc3831e60a367068d0ed2e83d23db
4
- data.tar.gz: 79c4d6a4c3bee3d9b08b0c65ca898debb3856183
3
+ metadata.gz: e03e39eca4a755d270f2f4e5d6f7122b9a53143d
4
+ data.tar.gz: 56e44dbaf28967bd180a9e391fce9cb52745f29c
5
5
  SHA512:
6
- metadata.gz: f282279056e844ac486981990f32b2f048aaf44516bdcaa996693c62229572983a06f4747414ce08c9a7b86770b2079bd705365bfaefa544890cdffb77a0fd56
7
- data.tar.gz: ca96a092b89220ad3de24f204c97f7a3d2d715057ee32c5946b48dbf5bc5ad1e991e573ea9db10e7c9917674aa08597c4aebe7b51b458959bea44faad8515362
6
+ metadata.gz: e6aa259c436b56234a1071e080a022ae7704a766f04fe079168e9084409c2c5a4e6b3f67dea1c72c93e0517606f246ff1b739dec63d423218860ac6224812e04
7
+ data.tar.gz: fbcb92363e90e4af642e80572809eb4c2703abeda0c4465b2f6b8854cc3263aa900944ac84f37605e86f3d5390f5962569f8f45b52f737fdc48a05eb1acd58c8
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -2,52 +2,96 @@ require 'fluent/parser'
2
2
 
3
3
  module Fluent
4
4
  class TextParser
5
- class MultiFormatParser
6
- include Configurable
5
+ if defined?(::Fluent::Parser)
6
+ class MultiFormatParser < Parser
7
+ Plugin.register_parser('multi_format', self)
7
8
 
8
- def initialize
9
- super
9
+ def initialize
10
+ super
10
11
 
11
- @parsers = []
12
- end
12
+ @parsers = []
13
+ end
13
14
 
14
- def configure(conf)
15
- super
15
+ def configure(conf)
16
+ super
16
17
 
17
- conf.elements.each { |e|
18
- next unless ['pattern', 'format'].include?(e.name)
18
+ conf.elements.each { |e|
19
+ next unless ['pattern', 'format'].include?(e.name)
19
20
 
20
- parser = TextParser.new
21
- parser.configure(e)
22
- @parsers << parser.parser
23
- }
24
- end
21
+ parser = Plugin.new_parser(e['format'])
22
+ parser.configure(e)
23
+ @parsers << parser
24
+ }
25
+ end
25
26
 
26
- def call(text)
27
- @parsers.each { |parser|
28
- begin
29
- parser.call(text) { |time, record|
30
- if time && record
31
- if block_given?
27
+ def parse(text)
28
+ @parsers.each { |parser|
29
+ begin
30
+ parser.parse(text) { |time, record|
31
+ if time && record
32
32
  yield time, record
33
33
  return
34
- else
35
- return time, record
36
34
  end
37
- end
38
- }
39
- rescue # ignore parser error
40
- end
41
- }
35
+ }
36
+ rescue # ignore parser error
37
+ end
38
+ }
42
39
 
43
- if block_given?
44
40
  yield nil, nil
45
- else
46
- return nil, nil
47
41
  end
48
42
  end
49
- end
43
+ else # support old API. Will be removed.
44
+ class MultiFormatParser
45
+ include Configurable
46
+
47
+ def initialize
48
+ super
49
+
50
+ @parsers = []
51
+ end
52
+
53
+ def configure(conf)
54
+ super
55
+
56
+ conf.elements.each { |e|
57
+ next unless ['pattern', 'format'].include?(e.name)
50
58
 
51
- register_template('multi_format', Proc.new { MultiFormatParser.new })
59
+ parser = TextParser.new
60
+ parser.configure(e)
61
+ @parsers << parser.parser
62
+ }
63
+ end
64
+
65
+ def parse(text)
66
+ @parsers.each { |parser|
67
+ begin
68
+ parser.call(text) { |time, record|
69
+ if time && record
70
+ if block_given?
71
+ yield time, record
72
+ return
73
+ else
74
+ return time, record
75
+ end
76
+ end
77
+ }
78
+ rescue # ignore parser error
79
+ end
80
+ }
81
+
82
+ if block_given?
83
+ yield nil, nil
84
+ else
85
+ return nil, nil
86
+ end
87
+ end
88
+
89
+ def call(*a, &b)
90
+ parse(*a, &b)
91
+ end
92
+ end
93
+
94
+ register_template('multi_format', Proc.new { MultiFormatParser.new })
95
+ end
52
96
  end
53
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-multi-format-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Nakagawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-10 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd