fluent-mixin-plaintextformatter 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-mixin-plaintextformatter"
|
4
|
-
gem.version = "0.2.
|
4
|
+
gem.version = "0.2.2"
|
5
5
|
gem.authors = ["TAGOMORI Satoshi"]
|
6
6
|
gem.email = ["tagomoris@gmail.com"]
|
7
7
|
gem.description = %q{included to format values into json, tsv or csv}
|
@@ -13,8 +13,6 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.require_paths = ["lib"]
|
15
15
|
|
16
|
-
gem.add_development_dependency "fluentd"
|
17
|
-
gem.add_development_dependency "ltsv"
|
18
16
|
gem.add_runtime_dependency "fluentd"
|
19
17
|
gem.add_runtime_dependency "ltsv"
|
20
18
|
end
|
@@ -61,7 +61,7 @@ module Fluent
|
|
61
61
|
elsif @output_data_type == 'ltsv'
|
62
62
|
nil
|
63
63
|
elsif @output_data_type =~ /^attr:(.+)$/
|
64
|
-
$1.split(',')
|
64
|
+
$1.split(',').map(&:strip).reject(&:empty?)
|
65
65
|
else
|
66
66
|
raise Fluent::ConfigError, "invalid output_data_type:'#{@output_data_type}'"
|
67
67
|
end
|
@@ -33,7 +33,7 @@ class PlainTextFormatterTest < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_field_separator_newline_json
|
36
|
-
p = create_plugin_instance(Fluent::TestBOutput, "type testb\
|
36
|
+
p = create_plugin_instance(Fluent::TestBOutput, "type testb\nutc\n")
|
37
37
|
r = {'foo' => 'foo foo baz', 'bar' => 10000}
|
38
38
|
# stringify
|
39
39
|
assert_equal r, JSON.parse(p.stringify_record(r))
|
@@ -42,7 +42,7 @@ class PlainTextFormatterTest < Test::Unit::TestCase
|
|
42
42
|
# add_newline false
|
43
43
|
assert_equal line[0..-1], line.chomp
|
44
44
|
# output_include_time true, output_include_tag true, localtime, separator COMMA
|
45
|
-
assert_equal ['2012-07-
|
45
|
+
assert_equal ['2012-07-13T07:05:05Z', 'test.b'], line.chomp.split(/,/, 3)[0..1]
|
46
46
|
# output_data_type json
|
47
47
|
assert_equal r, JSON.parse(line.chomp.split(/,/, 3)[2])
|
48
48
|
end
|
@@ -50,7 +50,7 @@ class PlainTextFormatterTest < Test::Unit::TestCase
|
|
50
50
|
def test_time_format
|
51
51
|
p = create_plugin_instance(Fluent::TestBOutput, %[
|
52
52
|
type testb
|
53
|
-
|
53
|
+
utc
|
54
54
|
time_format %Y/%m/%d %H:%M:%S
|
55
55
|
])
|
56
56
|
r = {'foo' => 'foo foo baz', 'bar' => 10000}
|
@@ -61,14 +61,14 @@ time_format %Y/%m/%d %H:%M:%S
|
|
61
61
|
# add_newline false
|
62
62
|
assert_equal line[0..-1], line.chomp
|
63
63
|
# output_include_time true, output_include_tag true, localtime, separator COMMA
|
64
|
-
assert_equal ['2012/07/13
|
64
|
+
assert_equal ['2012/07/13 07:05:05', 'test.b'], line.chomp.split(/,/, 3)[0..1]
|
65
65
|
# output_data_type json
|
66
66
|
assert_equal r, JSON.parse(line.chomp.split(/,/, 3)[2])
|
67
67
|
end
|
68
68
|
def test_separator_space_remove_prefix
|
69
69
|
p = create_plugin_instance(Fluent::TestBOutput, %[
|
70
70
|
type testb
|
71
|
-
|
71
|
+
utc
|
72
72
|
time_format %Y/%m/%d:%H:%M:%S
|
73
73
|
field_separator space
|
74
74
|
remove_prefix test
|
@@ -81,14 +81,14 @@ remove_prefix test
|
|
81
81
|
# add_newline false
|
82
82
|
assert_equal line[0..-1], line.chomp
|
83
83
|
# output_include_time true, output_include_tag true, localtime, separator COMMA
|
84
|
-
assert_equal ['2012/07/13:
|
84
|
+
assert_equal ['2012/07/13:07:05:05', 'b'], line.chomp.split(/ /, 3)[0..1]
|
85
85
|
# output_data_type json
|
86
86
|
assert_equal r, JSON.parse(line.chomp.split(/ /, 3)[2])
|
87
87
|
end
|
88
88
|
def test_separator_soh_remove_prefix
|
89
89
|
p = create_plugin_instance(Fluent::TestBOutput, %[
|
90
90
|
type testb
|
91
|
-
|
91
|
+
utc
|
92
92
|
time_format %Y/%m/%d:%H:%M:%S
|
93
93
|
field_separator soh
|
94
94
|
remove_prefix test
|
@@ -101,7 +101,7 @@ remove_prefix test
|
|
101
101
|
# add_newline false
|
102
102
|
assert_equal line[0..-1], line.chomp
|
103
103
|
# output_include_time true, output_include_tag true, localtime, separator SOH
|
104
|
-
assert_equal ['2012/07/13:
|
104
|
+
assert_equal ['2012/07/13:07:05:05', 'b'], line.chomp.split(/\001/, 3)[0..1]
|
105
105
|
# output_data_type json
|
106
106
|
assert_equal r, JSON.parse(line.chomp.split(/\001/, 3)[2])
|
107
107
|
end
|
@@ -175,16 +175,28 @@ field_separator comma
|
|
175
175
|
end
|
176
176
|
|
177
177
|
def test_field_separator_newline_ltsv
|
178
|
-
p = create_plugin_instance(Fluent::TestDOutput, "type testd\
|
178
|
+
p = create_plugin_instance(Fluent::TestDOutput, "type testd\nutc\n")
|
179
179
|
r = {'foo' => 'foo foo baz', 'bar' => 10000}
|
180
180
|
rs = {:foo => 'foo foo baz', :bar => "10000"}
|
181
181
|
# stringify
|
182
|
-
|
182
|
+
obj_from_ltsv = LTSV.parse(p.stringify_record(r))
|
183
|
+
if obj_from_ltsv.is_a?(Array)
|
184
|
+
# LTSV breaks compatibility for LTSV.parse
|
185
|
+
# Results of LTSV.parse(string_of_single_object) returns Array instance after v0.0.2
|
186
|
+
obj_from_ltsv = obj_from_ltsv.first
|
187
|
+
end
|
188
|
+
assert_equal rs, obj_from_ltsv
|
183
189
|
|
184
190
|
line = p.format('test.d', 1342163105, r)
|
185
191
|
# output_include_time true, output_include_tag true, localtime, separator COMMA
|
186
|
-
assert_equal ['2012-07-
|
192
|
+
assert_equal ['2012-07-13T07:05:05Z', 'test.d'], line.chomp.split(/\t/, 3)[0..1]
|
187
193
|
# output_data_type json
|
188
|
-
|
194
|
+
obj_from_ltsv = LTSV.parse(line.chomp.split(/\t/, 3)[2])
|
195
|
+
if obj_from_ltsv.is_a?(Array)
|
196
|
+
# LTSV breaks compatibility for LTSV.parse
|
197
|
+
# Results of LTSV.parse(string_of_single_object) returns Array instance after v0.0.2
|
198
|
+
obj_from_ltsv = obj_from_ltsv.first
|
199
|
+
end
|
200
|
+
assert_equal rs, obj_from_ltsv
|
189
201
|
end
|
190
202
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-mixin-plaintextformatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,40 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: fluentd
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: ltsv
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
14
|
- !ruby/object:Gem::Dependency
|
47
15
|
name: fluentd
|
48
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
80
|
version: '0'
|
113
81
|
requirements: []
|
114
82
|
rubyforge_project:
|
115
|
-
rubygems_version: 1.8.
|
83
|
+
rubygems_version: 1.8.23
|
116
84
|
signing_key:
|
117
85
|
specification_version: 3
|
118
86
|
summary: Text formatter mixin module to create fluentd plugin
|