dap 0.1.5 → 0.1.6

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: e61f8a06c9943ff97add1aea2ba408fa821d5a79
4
- data.tar.gz: 307b216fcf7d20ffed3e744bbe30256acfe97296
3
+ metadata.gz: 8cd019aba689251f56e3ec08abb75533f3fe8eac
4
+ data.tar.gz: 75ce91184b5c8e1320acb557c009607530c6be17
5
5
  SHA512:
6
- metadata.gz: 1a17a8311b1d22742203dc4013c95141366f94db7304297cbaf68b29c61e6d5403271075846f3d10392df9a37cd4b947e5d1bb8726a01bc8a3d5286b79cc19a1
7
- data.tar.gz: f2bc20c97078b307bf2a469beb1f2652d5a640f1d9e542ec3a1dd040f9bc4049f54379b691b4d16ab510b43721547580dd27b7f3e1c8cb09a40a087e2c6b35f0
6
+ metadata.gz: 3a1f4d012a8b452f0671c0a262aa06b0f0f5787d9aba133e79f5389ad9bf5fb9e8c8c16df51201e0014410e711d29f5984f0599407944ccfbabc27b79a7bd27c
7
+ data.tar.gz: 996ff5f0efae982df396c29d1bad7c1b3a9a69cb97f451bbb65c09ec6589a7dc7f7bfca018ff971d7c9060b60211c9a0f1a6c7a000ba548ab6dd35681e5896eb
@@ -369,15 +369,15 @@ class FilterSplitArray
369
369
  end
370
370
  end
371
371
 
372
- class FilterFieldSplitLine
372
+ class FilterFieldSplit
373
373
  include Base
374
374
  def process(doc)
375
375
  self.opts.each_pair do |k,v|
376
376
  if doc.has_key?(k)
377
- lcount = 1
378
- doc[k].to_s.split(/\n/).each do |line|
379
- doc.merge!({ "#{k}.f#{lcount}" => line })
380
- lcount += 1
377
+ count = 1
378
+ doc[k].to_s.split(Regexp.new(v)).each do |thing|
379
+ doc.merge!({ "#{k}.f#{count}" => thing })
380
+ count += 1
381
381
  end
382
382
  end
383
383
  end
@@ -385,51 +385,33 @@ class FilterFieldSplitLine
385
385
  end
386
386
  end
387
387
 
388
- class FilterFieldSplitWord
389
- include Base
390
- def process(doc)
391
- self.opts.each_pair do |k,v|
392
- if doc.has_key?(k)
393
- wcount = 1
394
- doc[k].to_s.split(/\W/).each do |word|
395
- doc.merge!({ "#{k}.f#{wcount}" => word })
396
- wcount += 1
397
- end
398
- end
399
- end
400
- [ doc ]
388
+ class FilterFieldSplitLine < FilterFieldSplit
389
+ def initialize(args)
390
+ super(args.map { |arg| "#{arg}=\\n" } )
401
391
  end
402
392
  end
403
393
 
404
- class FilterFieldSplitTab
405
- include Base
406
- def process(doc)
407
- self.opts.each_pair do |k,v|
408
- if doc.has_key?(k)
409
- wcount = 1
410
- doc[k].to_s.split(/\t/).each do |word|
411
- doc.merge!({ "#{k}.f#{wcount}" => word })
412
- wcount += 1
413
- end
414
- end
415
- end
416
- [ doc ]
394
+ class FilterFieldSplitWord < FilterFieldSplit
395
+ def initialize(args)
396
+ super(args.map { |arg| "#{arg}=\\W" } )
417
397
  end
418
398
  end
419
399
 
420
- class FilterFieldSplitComma
421
- include Base
422
- def process(doc)
423
- self.opts.each_pair do |k,v|
424
- if doc.has_key?(k)
425
- wcount = 1
426
- doc[k].to_s.split(/,/).each do |word|
427
- doc.merge!({ "#{k}.f#{wcount}" => word })
428
- wcount += 1
429
- end
430
- end
431
- end
432
- [ doc ]
400
+ class FilterFieldSplitTab < FilterFieldSplit
401
+ def initialize(args)
402
+ super(args.map { |arg| "#{arg}=\\t" } )
403
+ end
404
+ end
405
+
406
+ class FilterFieldSplitComma < FilterFieldSplit
407
+ def initialize(args)
408
+ super(args.map { |arg| "#{arg}=," } )
409
+ end
410
+ end
411
+
412
+ class FilterFieldSplitPeriod < FilterFieldSplit
413
+ def initialize(args)
414
+ super(args.map { |arg| "#{arg}=\\." } )
433
415
  end
434
416
  end
435
417
 
data/lib/dap/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dap
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -144,3 +144,45 @@ describe Dap::Filter::FilterTransform do
144
144
  end
145
145
  end
146
146
  end
147
+
148
+ describe Dap::Filter::FilterFieldSplit do
149
+ describe '.process' do
150
+
151
+ let(:filter) { described_class.new(["value=\\."]) }
152
+
153
+ context 'splitting on regex boundary' do
154
+ let(:process) { filter.process({"value" => "foo.bar.baf"}) }
155
+ it 'splits correctly' do
156
+ expect(process).to eq([{"value" => "foo.bar.baf", "value.f1" => "foo", "value.f2" => "bar", "value.f3" => "baf"}])
157
+ end
158
+ end
159
+ end
160
+ end
161
+
162
+ describe Dap::Filter::FilterFieldSplitPeriod do
163
+ describe '.process' do
164
+
165
+ let(:filter) { described_class.new(["value"]) }
166
+
167
+ context 'splitting on period boundary' do
168
+ let(:process) { filter.process({"value" => "foo.bar.baf"}) }
169
+ it 'splits correctly' do
170
+ expect(process).to eq([{"value" => "foo.bar.baf", "value.f1" => "foo", "value.f2" => "bar", "value.f3" => "baf"}])
171
+ end
172
+ end
173
+ end
174
+ end
175
+
176
+ describe Dap::Filter::FilterFieldSplitLine do
177
+ describe '.process' do
178
+
179
+ let(:filter) { described_class.new(["value"]) }
180
+
181
+ context 'splitting on newline boundary' do
182
+ let(:process) { filter.process({"value" => "foo\nbar\nbaf"}) }
183
+ it 'splits correctly' do
184
+ expect(process).to eq([{"value" => "foo\nbar\nbaf", "value.f1" => "foo", "value.f2" => "bar", "value.f3" => "baf"}])
185
+ end
186
+ end
187
+ end
188
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rapid7 Research
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-31 00:00:00.000000000 Z
11
+ date: 2017-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec