fluent-mixin-plaintextformatter 0.2.2 → 0.2.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d3f892bb7a90ccd8e91cae4e9581ac540b1365c4
4
+ data.tar.gz: 04b6d2744aa25081c5e8e6b7f629f0b4d60fa9de
5
+ SHA512:
6
+ metadata.gz: 6a5b50af5b252f1b30c292cab814b501ca84656f3dc802cb5eed660973ade3bf1351e44ddc457071b004470c21b5f0e0823be0e4cdb40d91a0625c9908fe3b19
7
+ data.tar.gz: e6c183f7a11465843e1aa4fc291f572ee03ef839bcae67e2240c011f080e989fc67b296261365289efa894ef121610b92b0e036bb293510e646e0aaff0d1096b
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
@@ -1,12 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = "fluent-mixin-plaintextformatter"
4
- gem.version = "0.2.2"
4
+ gem.version = "0.2.3"
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}
8
8
  gem.summary = %q{Text formatter mixin module to create fluentd plugin}
9
9
  gem.homepage = "https://github.com/tagomoris/fluent-mixin-plaintextformatter"
10
+ gem.license = "APLv2"
10
11
 
11
12
  gem.files = `git ls-files`.split($\)
12
13
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -15,4 +16,5 @@ Gem::Specification.new do |gem|
15
16
 
16
17
  gem.add_runtime_dependency "fluentd"
17
18
  gem.add_runtime_dependency "ltsv"
19
+ gem.add_development_dependency "rake"
18
20
  end
@@ -77,7 +77,7 @@ module Fluent
77
77
  end
78
78
  else
79
79
  @custom_attributes.map{|attr|
80
- (record[attr] || 'NULL').to_s
80
+ record[attr].nil? ? 'NULL' : record[attr].to_s
81
81
  }.join(@f_separator)
82
82
  end
83
83
  end
@@ -100,7 +100,18 @@ module Fluent
100
100
  else
101
101
  ''
102
102
  end
103
- time_str + tag_str + stringify_record(record) + (@add_newline ? "\n" : '')
103
+ begin
104
+ time_str + tag_str + stringify_record(record) + (@add_newline ? "\n" : '')
105
+ rescue JSON::GeneratorError => e
106
+ # partial character in source, but hit end
107
+ # source sequence is illegal/malformed utf-8
108
+ $log.error e.message + ", ignored", :error_class => e.class, :tag => tag, :record => record.inspect # quote explicitly
109
+ ''
110
+ rescue ArgumentError => e
111
+ raise unless e.message == 'invalid byte sequence in UTF-8'
112
+ $log.error e.message + ", ignored", :error_class => e.class, :tag => tag, :record => record.inspect # quote explicitly
113
+ ''
114
+ end
104
115
  end
105
116
  end
106
117
  end
@@ -105,7 +105,7 @@ remove_prefix test
105
105
  # output_data_type json
106
106
  assert_equal r, JSON.parse(line.chomp.split(/\001/, 3)[2])
107
107
  end
108
-
108
+
109
109
  def test_default_without_time_tag
110
110
  p = create_plugin_instance(Fluent::TestCOutput, "type testc\n")
111
111
  r = {'foo' => 'foo foo baz', 'bar' => 10000}
@@ -174,6 +174,31 @@ field_separator comma
174
174
  assert_equal "10000,foo foo baz\n", p.format('test.a', 1342163105, r)
175
175
  end
176
176
 
177
+ def test_format_invalid_utf8_sequence
178
+ invalid_str = [0xFA, 0xFB].pack('CC').force_encoding('utf-8')
179
+ valid_str = [0xFF, 0xE3].pack("U*")
180
+
181
+ p1 = create_plugin_instance(Fluent::TestAOutput, %[
182
+ type testa
183
+ output_include_time true
184
+ output_include_tag true
185
+ output_data_type json
186
+ ])
187
+ r1 = p1.format('tag', Fluent::Engine.now, {'foo' => valid_str, 'bar' => invalid_str + valid_str})
188
+ # #format should logs for this record (but we cannot test it...)
189
+ assert_equal '', r1
190
+
191
+ p2 = create_plugin_instance(Fluent::TestAOutput, %[
192
+ type testa
193
+ output_include_time true
194
+ output_include_tag true
195
+ output_data_type ltsv
196
+ ])
197
+ r2 = p2.format('tag', Fluent::Engine.now, {'foo' => valid_str, 'bar' => invalid_str + valid_str})
198
+ # #format should logs for this record (but we cannot test it...)
199
+ assert_equal '', r2
200
+ end
201
+
177
202
  def test_field_separator_newline_ltsv
178
203
  p = create_plugin_instance(Fluent::TestDOutput, "type testd\nutc\n")
179
204
  r = {'foo' => 'foo foo baz', 'bar' => 10000}
@@ -199,4 +224,18 @@ field_separator comma
199
224
  end
200
225
  assert_equal rs, obj_from_ltsv
201
226
  end
227
+
228
+ def test_format_boolean_attribute
229
+ p = create_plugin_instance(Fluent::TestAOutput, %[
230
+ type testa
231
+ output_include_time true
232
+ output_include_tag true
233
+ output_data_type attr:foo,bar
234
+ ])
235
+ r = {'foo' => true, 'bar' => false}
236
+ # stringify
237
+ assert_equal "true\tfalse", p.stringify_record(r)
238
+ # format
239
+ assert_equal "2012-07-13T07:05:05Z\ttest.a\ttrue\tfalse\n", p.format('test.a', 1342163105, r)
240
+ end
202
241
  end
metadata CHANGED
@@ -1,46 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-mixin-plaintextformatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
4
+ version: 0.2.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - TAGOMORI Satoshi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-08 00:00:00.000000000 Z
11
+ date: 2013-09-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fluentd
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: ltsv
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  description: included to format values into json, tsv or csv
@@ -51,6 +60,7 @@ extensions: []
51
60
  extra_rdoc_files: []
52
61
  files:
53
62
  - .gitignore
63
+ - .travis.yml
54
64
  - Gemfile
55
65
  - LICENSE.txt
56
66
  - README.md
@@ -61,30 +71,31 @@ files:
61
71
  - test/mixin/test_plaintextformatter.rb
62
72
  - test/output.rb
63
73
  homepage: https://github.com/tagomoris/fluent-mixin-plaintextformatter
64
- licenses: []
74
+ licenses:
75
+ - APLv2
76
+ metadata: {}
65
77
  post_install_message:
66
78
  rdoc_options: []
67
79
  require_paths:
68
80
  - lib
69
81
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
82
  requirements:
72
- - - ! '>='
83
+ - - '>='
73
84
  - !ruby/object:Gem::Version
74
85
  version: '0'
75
86
  required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
87
  requirements:
78
- - - ! '>='
88
+ - - '>='
79
89
  - !ruby/object:Gem::Version
80
90
  version: '0'
81
91
  requirements: []
82
92
  rubyforge_project:
83
- rubygems_version: 1.8.23
93
+ rubygems_version: 2.0.3
84
94
  signing_key:
85
- specification_version: 3
95
+ specification_version: 4
86
96
  summary: Text formatter mixin module to create fluentd plugin
87
97
  test_files:
88
98
  - test/helper.rb
89
99
  - test/mixin/test_plaintextformatter.rb
90
100
  - test/output.rb
101
+ has_rdoc: