fluent-plugin-extract_query_params 0.0.4 → 0.0.5

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: 172e07237ab226e9898f9027becf4e2a11bc0ec6
4
- data.tar.gz: 7b262ace7e04bb2b01475bccbeffe4da4fbfcebe
3
+ metadata.gz: 4428fe126f8c2bcdfdc73937b0b140c5740ecabf
4
+ data.tar.gz: 2304f1fb5c8da4aae857089d03bed3890fad7c2d
5
5
  SHA512:
6
- metadata.gz: adfcafa57eccff147dfff505af4966223e32e1c2debc9705c1f5c556c507280247ba9b83261cc15268f08f894fb67ca444a77dc356afd18da5225236f331d937
7
- data.tar.gz: 9bf7c62140559f4d6a233e0e785bf64835863ff132a7dc00dd69e8af7272d68f1cdde621b7f741a856602fd8ab8a3ecad4ba3ced35d0ded3bc11eed56c5bbaf5
6
+ metadata.gz: 98901ac91a3dba4f4a92c6511da1761a78c769c98f70cef957d0d701c5e1a217504904ff21a3f6645c78801d4b2daa03777ac91dec3d0a33743294724e2331c9
7
+ data.tar.gz: bf128ba87028b8141fb6c8ce66c79df22729c6d372ea27fb1afc7483d86f389fbf224fba21c4ad7ae6cb4ecd18179437f5ee1232cae47a4313b10ad70c7b1ec9
@@ -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.4'
3
+ gem.version = '0.0.5'
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'
@@ -11,6 +11,7 @@ module Fluent
11
11
  config_param :except, :string, :default => nil
12
12
  config_param :discard_key, :bool, :default => false
13
13
  config_param :add_field_prefix, :string, :default => nil
14
+ config_param :permit_blank_key, :bool, :default => false
14
15
 
15
16
  def configure(conf)
16
17
  super
@@ -51,6 +52,9 @@ module Fluent
51
52
  unless url.query.nil?
52
53
  url.query.split('&').each do |pair|
53
54
  key, value = pair.split('=').map { |i| URI.unescape(i) }
55
+ next if (key.nil? || key.empty?) && (!@permit_blank_key || value.nil? || value.empty?)
56
+ key ||= ''
57
+ value ||= ''
54
58
 
55
59
  key = @add_field_prefix + key if @add_field_prefix
56
60
  if only
@@ -191,4 +191,111 @@ class ExtractQueryParamsOutputTest < Test::Unit::TestCase
191
191
  assert_equal 'extracted.test', emits[0][0]
192
192
  assert_equal 'invalid url', emits[0][2]['url']
193
193
  end
194
+
195
+ DIRTY_PATH_BLANK_1 = '/dummy?&baz=qux'
196
+ DIRTY_PATH_BLANK_2 = '/dummy?foo=bar&'
197
+ DIRTY_PATH_BLANK_3 = '/dummy?foo=bar&&baz=qux'
198
+ DIRTY_PATH_BLANK_4 = '/dummy?=&baz=qux'
199
+ DIRTY_PATH_KEY_ONLY_1 = '/dummy?foo=&baz=qux'
200
+ DIRTY_PATH_KEY_ONLY_2 = '/dummy?foo&baz=qux'
201
+ DIRTY_PATH_KEY_ONLY_3 = '/dummy?baz=qux&foo'
202
+ DIRTY_PATH_VALUE_ONLY_1 = '/dummy?=bar&baz=qux'
203
+ DIRTY_PATH_VALUE_ONLY_2 = '/dummy?baz=qux&=bar'
204
+
205
+ def test_emit_with_dirty_paths
206
+ d = create_driver(%[
207
+ key path
208
+ add_tag_prefix a.
209
+ ])
210
+ d.run {
211
+ d.emit({ 'path' => DIRTY_PATH_BLANK_1 })
212
+ d.emit({ 'path' => DIRTY_PATH_BLANK_2 })
213
+ d.emit({ 'path' => DIRTY_PATH_BLANK_3 })
214
+ d.emit({ 'path' => DIRTY_PATH_BLANK_4 })
215
+ d.emit({ 'path' => DIRTY_PATH_KEY_ONLY_1 })
216
+ d.emit({ 'path' => DIRTY_PATH_KEY_ONLY_2 })
217
+ d.emit({ 'path' => DIRTY_PATH_KEY_ONLY_3 })
218
+ d.emit({ 'path' => DIRTY_PATH_VALUE_ONLY_1 })
219
+ d.emit({ 'path' => DIRTY_PATH_VALUE_ONLY_2 })
220
+ }
221
+ emits = d.emits
222
+
223
+ assert_equal 9, emits.count
224
+
225
+ r = emits.shift[2]
226
+ assert_equal 2, r.size
227
+ assert_equal DIRTY_PATH_BLANK_1, r['path']
228
+ assert_equal 'qux', r['baz']
229
+
230
+ r = emits.shift[2]
231
+ assert_equal 2, r.size
232
+ assert_equal DIRTY_PATH_BLANK_2, r['path']
233
+ assert_equal 'bar', r['foo']
234
+
235
+ r = emits.shift[2]
236
+ assert_equal 3, r.size
237
+ assert_equal DIRTY_PATH_BLANK_3, r['path']
238
+ assert_equal 'bar', r['foo']
239
+ assert_equal 'qux', r['baz']
240
+
241
+ r = emits.shift[2]
242
+ assert_equal 2, r.size
243
+ assert_equal DIRTY_PATH_BLANK_4, r['path']
244
+ assert_equal 'qux', r['baz']
245
+
246
+ r = emits.shift[2]
247
+ assert_equal 3, r.size
248
+ assert_equal DIRTY_PATH_KEY_ONLY_1, r['path']
249
+ assert_equal '', r['foo']
250
+ assert_equal 'qux', r['baz']
251
+
252
+ r = emits.shift[2]
253
+ assert_equal 3, r.size
254
+ assert_equal DIRTY_PATH_KEY_ONLY_2, r['path']
255
+ assert_equal '', r['foo']
256
+ assert_equal 'qux', r['baz']
257
+
258
+ r = emits.shift[2]
259
+ assert_equal 3, r.size
260
+ assert_equal DIRTY_PATH_KEY_ONLY_3, r['path']
261
+ assert_equal '', r['foo']
262
+ assert_equal 'qux', r['baz']
263
+
264
+ r = emits.shift[2]
265
+ assert_equal 2, r.size
266
+ assert_equal DIRTY_PATH_VALUE_ONLY_1, r['path']
267
+ assert_equal 'qux', r['baz']
268
+
269
+ r = emits.shift[2]
270
+ assert_equal 2, r.size
271
+ assert_equal DIRTY_PATH_VALUE_ONLY_2, r['path']
272
+ assert_equal 'qux', r['baz']
273
+ end
274
+
275
+ def test_emit_with_permit_blank_key
276
+ d = create_driver(%[
277
+ key path
278
+ add_tag_prefix a.
279
+ permit_blank_key yes
280
+ ])
281
+ d.run {
282
+ d.emit({ 'path' => DIRTY_PATH_VALUE_ONLY_1 })
283
+ d.emit({ 'path' => DIRTY_PATH_VALUE_ONLY_2 })
284
+ }
285
+ emits = d.emits
286
+
287
+ assert_equal 2, emits.count
288
+
289
+ r = emits.shift[2]
290
+ assert_equal 3, r.size
291
+ assert_equal DIRTY_PATH_VALUE_ONLY_1, r['path']
292
+ assert_equal 'bar', r['']
293
+ assert_equal 'qux', r['baz']
294
+
295
+ r = emits.shift[2]
296
+ assert_equal 3, r.size
297
+ assert_equal DIRTY_PATH_VALUE_ONLY_2, r['path']
298
+ assert_equal 'bar', r['']
299
+ assert_equal 'qux', r['baz']
300
+ end
194
301
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Kuribayashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-27 00:00:00.000000000 Z
11
+ date: 2013-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake