fluent-plugin-split-array 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5dab092bbda0d51379b1f6904eacc5b57c401815
4
- data.tar.gz: 1c7d3b332207192f753131fe9874ae09b3af3b33
3
+ metadata.gz: 1f5c3413444637178f42ba549aca2c6ce8d71b27
4
+ data.tar.gz: 2ef6be4bc65f6efa60a05970c9900ff7b5f57571
5
5
  SHA512:
6
- metadata.gz: fe87ceb5e1d88bdadc7f76093d1a22f26d0b8b62da54076a08ec4efe44af9d588305573617ff55b3e6a2e5aa9aec7031cc3411a54f8d12d023c9c41903989c59
7
- data.tar.gz: 0d286ea60ebff851788dc2b5ae7426b3d8b7e157380a86ef5001b7064a01a12f1b88ea9b3ae3142b94cdedb5674342c7e852f2f1a98d34259bd8c6a023281c19
6
+ metadata.gz: 50f285001bae38504aa6c1d7f2e4887d3913cd14f22dde9667784bf234c4b2d3bf361f4edf25d08ee5679f3bd2d69088bce062f156bedf393f56e9e47ed54cb1
7
+ data.tar.gz: 7cee5378a189ecd79d75bff95e01c878328f3f305be0a483ee7e1d625051360301aa3f4058cbc73d80e690036643dbce12fad11cb841a88c0178b96f12ecc1c7
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.2.2"
4
+ - "2.1.6"
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Fluent filter plugin to split array
4
4
 
5
+ [![Build Status](https://travis-ci.org/SNakano/fluent-plugin-split-array.svg)](https://travis-ci.org/SNakano/fluent-plugin-split-array)
6
+ [![Gem](https://img.shields.io/gem/dt/fluent-plugin-split-array.svg)](https://rubygems.org/gems/fluent-plugin-split-array)
7
+
8
+
5
9
  ## install
6
10
 
7
11
  ```
@@ -53,4 +57,3 @@ Monitoring RabbitMQ all queues status
53
57
  type stdout
54
58
  </match>
55
59
  ```
56
-
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "fluent-plugin-split-array"
3
- s.version = "0.0.1"
3
+ s.version = "0.0.2"
4
4
  s.licenses = ["MIT"]
5
5
  s.summary = "Fluentd filter plugin to split array"
6
6
  s.description = s.summary
@@ -1,9 +1,16 @@
1
1
  module Fluent
2
2
  class SplitArrayFilter < Filter
3
3
  Fluent::Plugin.register_filter('split_array', self)
4
+
5
+ desc "Key name to split"
6
+ config_param :split_key, :string, default: nil
7
+
4
8
  def filter_stream(tag, es)
5
9
  new_es = MultiEventStream.new
6
- es.each {|time, record| split(time, record, new_es) }
10
+ es.each {|time, record|
11
+ target_record = @split_key.nil? ? record : record[@split_key] || {}
12
+ split(time, target_record, new_es)
13
+ }
7
14
  new_es
8
15
  end
9
16
 
@@ -1,3 +1,4 @@
1
+ require 'bundler/setup'
1
2
  require 'test/unit'
2
3
  require 'fluent/log'
3
4
  require 'fluent/test'
@@ -10,8 +11,8 @@ class RubyFilterTest < Test::Unit::TestCase
10
11
  Fluent::Test.setup
11
12
  end
12
13
 
13
- def emit(msg)
14
- d = Test::FilterTestDriver.new(SplitArrayFilter).configure('', true)
14
+ def emit(msg, conf='')
15
+ d = Test::FilterTestDriver.new(SplitArrayFilter).configure(conf, true)
15
16
  d.run {
16
17
  d.emit(msg, Fluent::Engine.now)
17
18
  }.filtered
@@ -27,9 +28,22 @@ class RubyFilterTest < Test::Unit::TestCase
27
28
  end
28
29
  end
29
30
  test 'execute to hash' do
30
- msg = {'a' => 'b', 'c' => 'd'}
31
+ msg = {'a' => 'b', 'c' => 'd'}
31
32
  es = emit(msg)
32
33
  assert_equal(msg, es.first[1])
33
34
  end
35
+ test 'execute to array with split_key' do
36
+ msg = {'key1' => [{'a' => 'b'}, {'a' => 'c'}]}
37
+ es = emit(msg, conf='split_key key1')
38
+ assert_equal(msg['key1'].count, es.count)
39
+ es.each_with_index do |e, i|
40
+ assert_equal(msg['key1'][i], e[1])
41
+ end
42
+ end
43
+ test 'execute to hash with split_key' do
44
+ msg = {'key1' => {'a' => 'b', 'c' => 'd'}}
45
+ es = emit(msg, conf='split_key key1')
46
+ assert_equal(msg['key1'], es.first[1])
47
+ end
34
48
  end
35
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-split-array
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
  - SNakano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-28 00:00:00.000000000 Z
11
+ date: 2017-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -59,6 +59,7 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".travis.yml"
62
63
  - Gemfile
63
64
  - LICENSE
64
65
  - README.md
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  version: '0'
87
88
  requirements: []
88
89
  rubyforge_project:
89
- rubygems_version: 2.4.5.1
90
+ rubygems_version: 2.6.11
90
91
  signing_key:
91
92
  specification_version: 4
92
93
  summary: Fluentd filter plugin to split array