dap 0.0.18 → 0.0.19
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 +17 -0
- data/lib/dap/version.rb +1 -1
- data/spec/dap/filter/simple_filter_spec.rb +28 -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: 41ed75c82a789ae7a55632cce6685d6626203fa9
|
4
|
+
data.tar.gz: 6199c55b1a7b644266bcd86158c77185428b48fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86e601032009d945c9acc73e6593461f1b546afd87c0ddd95120206ee1372973256e4b89cbaf949c3468dae50cf88883206556d1549248cf0643d9a4534c6661
|
7
|
+
data.tar.gz: 5f5d1e653b51bf84cd30df7db24e81955d6a80226920807bddd7b858abdebdf2b810476055aec6f3724e7aff4484967d98aceda7fe499be119808182c72d627b
|
data/lib/dap/filter/simple.rb
CHANGED
@@ -197,6 +197,23 @@ class FilterFlatten
|
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
|
+
class FilterExpand
|
201
|
+
include Base
|
202
|
+
def process(doc)
|
203
|
+
new_doc = doc.clone
|
204
|
+
self.opts.each_pair do |k,|
|
205
|
+
k_re = /^#{k}\.(?<sub_key>.+)$/
|
206
|
+
doc.each do |fk,fv|
|
207
|
+
if md = k_re.match(fk)
|
208
|
+
new_doc[k] ||= {}
|
209
|
+
new_doc[k][md[:sub_key]] = fv
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
[ new_doc ]
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
200
217
|
class FilterTruncate
|
201
218
|
include Base
|
202
219
|
def process(doc)
|
data/lib/dap/version.rb
CHANGED
@@ -19,6 +19,34 @@ describe Dap::Filter::FilterFlatten do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
describe Dap::Filter::FilterExpand do
|
23
|
+
describe '.process' do
|
24
|
+
|
25
|
+
let(:filter) { described_class.new(["foo"]) }
|
26
|
+
|
27
|
+
context 'expand unnested json' do
|
28
|
+
let(:process) { filter.process({"foo.bar" => "baz"}) }
|
29
|
+
it 'has new expanded keys' do
|
30
|
+
expect(process).to eq([{"foo" => {"bar" => "baz"}, "foo.bar" => "baz"}])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'ignore all but specified unnested json' do
|
35
|
+
let(:process) { filter.process({"foo.bar" => "baz", "baf.blah" => "baz" }) }
|
36
|
+
it 'has new expanded keys' do
|
37
|
+
expect(process).to eq([{"foo" => {"bar" => "baz"}, "foo.bar" => "baz", "baf.blah" => "baz"}])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'ignore nested json' do
|
42
|
+
let(:process) { filter.process({"foo" => "bar"}) }
|
43
|
+
it 'is the same as the original document' do
|
44
|
+
expect(process).to eq([{"foo" => "bar"}])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
22
50
|
describe Dap::Filter::FilterTransform do
|
23
51
|
describe '.process' do
|
24
52
|
|
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.0.
|
4
|
+
version: 0.0.19
|
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-
|
11
|
+
date: 2017-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|