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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 867e514a4d19ea3b3b9b70125fcd2f901fc9f006
4
- data.tar.gz: e26bee2e6c949d7cd844c66944f637b557ac5ae1
3
+ metadata.gz: 41ed75c82a789ae7a55632cce6685d6626203fa9
4
+ data.tar.gz: 6199c55b1a7b644266bcd86158c77185428b48fc
5
5
  SHA512:
6
- metadata.gz: 258052902d6c6d25e37657f29a9b1a235ea138e59ed11577c0ffdb11f5f0b74bf33e3a9d74908cf0514802f6495143e9ab058c5311e650b1eda7e1ff13cdb7fd
7
- data.tar.gz: f92c2afc884c726d2100bced1ecc63e8a749d5def35a4727012ecba147be13ce31fdababe597e1bd746285475e71df9376f77b0403130ab808b6c078e41619cb
6
+ metadata.gz: 86e601032009d945c9acc73e6593461f1b546afd87c0ddd95120206ee1372973256e4b89cbaf949c3468dae50cf88883206556d1549248cf0643d9a4534c6661
7
+ data.tar.gz: 5f5d1e653b51bf84cd30df7db24e81955d6a80226920807bddd7b858abdebdf2b810476055aec6f3724e7aff4484967d98aceda7fe499be119808182c72d627b
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Dap
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
@@ -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.18
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-07 00:00:00.000000000 Z
11
+ date: 2017-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec