fluent-plugin-extract_query_params 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -34,7 +34,7 @@ Then you'll get re-emmited tag/record-s below:
34
34
  "extracted.test" => {
35
35
  "url" => "http://example.com/?foo=bar&baz=qux&hoge=fuga"
36
36
  "foo" => "bar",
37
- "baz" => "quex"
37
+ "baz" => "qux"
38
38
  }
39
39
  ```
40
40
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'fluent-plugin-extract_query_params'
3
- gem.version = '0.0.1'
3
+ gem.version = '0.0.2'
4
4
  gem.authors = ['Kentaro Kuribayashi']
5
5
  gem.email = ['kentarok@gmail.com']
6
6
  gem.homepage = 'http://github.com/kentaro/fluent-plugin-extract_query_params'
@@ -34,8 +34,9 @@ module Fluent
34
34
 
35
35
  def emit(tag, es, chain)
36
36
  es.each do |time, record|
37
- filter_record(tag, time, record)
38
- Engine.emit(tag, time, record)
37
+ t = tag.dup
38
+ filter_record(t, time, record)
39
+ Engine.emit(t, time, record)
39
40
  end
40
41
 
41
42
  chain.next
@@ -45,15 +46,17 @@ module Fluent
45
46
  if record[key]
46
47
  begin
47
48
  url = URI.parse(record[key])
48
- url.query.split('&').each do |pair|
49
- key, value = pair.split('=').map { |i| URI.unescape(i) }
49
+ unless url.query.nil?
50
+ url.query.split('&').each do |pair|
51
+ key, value = pair.split('=').map { |i| URI.unescape(i) }
50
52
 
51
- if only
52
- record[key] = value if @include_keys.has_key?(key)
53
- elsif except
54
- record[key] = value if !@exclude_keys.has_key?(key)
55
- else
56
- record[key] = value
53
+ if only
54
+ record[key] = value if @include_keys.has_key?(key)
55
+ elsif except
56
+ record[key] = value if !@exclude_keys.has_key?(key)
57
+ else
58
+ record[key] = value
59
+ end
57
60
  end
58
61
  end
59
62
  rescue URI::InvalidURIError => error
@@ -102,6 +102,29 @@ class ExtractQueryParamsOutputTest < Test::Unit::TestCase
102
102
  assert_equal 'qux', emits[0][2]['baz']
103
103
  end
104
104
 
105
+ def test_emit_multi
106
+ d = create_driver(%[
107
+ key url
108
+ add_tag_prefix extracted.
109
+ only foo, baz
110
+ ])
111
+ d.run do
112
+ d.emit('url' => URL)
113
+ d.emit('url' => URL)
114
+ d.emit('url' => URL)
115
+ end
116
+ emits = d.emits
117
+
118
+ assert_equal 3, emits.count
119
+
120
+ emits.each do |e|
121
+ assert_equal 'extracted.test', e[0]
122
+ assert_equal URL, e[2]['url']
123
+ assert_equal 'bar', e[2]['foo']
124
+ assert_equal 'qux', e[2]['baz']
125
+ end
126
+ end
127
+
105
128
  def test_emit_without_match_key
106
129
  d = create_driver(%[
107
130
  key no_such_key
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-extract_query_params
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-06 00:00:00.000000000 Z
12
+ date: 2013-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake