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 +4 -4
- data/lib/dap/filter/simple.rb +26 -44
- data/lib/dap/version.rb +1 -1
- data/spec/dap/filter/simple_filter_spec.rb +42 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cd019aba689251f56e3ec08abb75533f3fe8eac
|
4
|
+
data.tar.gz: 75ce91184b5c8e1320acb557c009607530c6be17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a1f4d012a8b452f0671c0a262aa06b0f0f5787d9aba133e79f5389ad9bf5fb9e8c8c16df51201e0014410e711d29f5984f0599407944ccfbabc27b79a7bd27c
|
7
|
+
data.tar.gz: 996ff5f0efae982df396c29d1bad7c1b3a9a69cb97f451bbb65c09ec6589a7dc7f7bfca018ff971d7c9060b60211c9a0f1a6c7a000ba548ab6dd35681e5896eb
|
data/lib/dap/filter/simple.rb
CHANGED
@@ -369,15 +369,15 @@ class FilterSplitArray
|
|
369
369
|
end
|
370
370
|
end
|
371
371
|
|
372
|
-
class
|
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
|
-
|
378
|
-
doc[k].to_s.split(
|
379
|
-
doc.merge!({ "#{k}.f#{
|
380
|
-
|
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
|
389
|
-
|
390
|
-
|
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
|
405
|
-
|
406
|
-
|
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
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
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
@@ -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.
|
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-
|
11
|
+
date: 2017-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|