dap 0.1.17 → 0.1.18

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: 2e146c070dd214aa21525479a886b4ec7e55acaf
4
- data.tar.gz: 3a77f7551e728509cab65628c4bf4fc1a9cb6756
3
+ metadata.gz: 663523feb89fe2398a95fe119a2325a52400175b
4
+ data.tar.gz: 672a9e854a7f3a9e8d3ee477d0e3b6e077111c62
5
5
  SHA512:
6
- metadata.gz: 27cde6207fb2c159da33baea2ce76128461767cd560e1d75df2c0aae488bacbce7c7fbaf8da0f83ff5e0632c805159593162352d0c291f19bb45f9a81dabe788
7
- data.tar.gz: e033ae7ed70d7b74ebba00979673ea4fa555fb6984710e673fa51d66735d58e4ee0daf45afbcd71ca4b47637df23f8bdfca57326ba433cf06252ba521f758d67
6
+ metadata.gz: e8d53e2fe84af682bffe4474a8bf61e8d72adecdcd8c18dca0e76560d8467295cc85af2b1e0b9f0ce0e6d7f884d2d10de8741512d6a2a262706ebe5f97aa9e57
7
+ data.tar.gz: 547b613736c776d94dbcc87abb467e62df5c6e246a0896d475a07ab0e6d98f6a3374b51455c2d8e985acb60134ea0d712c0cdf00453051bc969f70e1bc7f4a81
@@ -41,6 +41,41 @@ class FilterRename
41
41
  end
42
42
  end
43
43
 
44
+ class FilterFieldReplace
45
+ include Base
46
+ attr_accessor :all
47
+
48
+ def initialize(args, all=false)
49
+ self.all = all
50
+ super(args)
51
+ missing_replace = self.opts.select { |k, v| v.nil? }.keys
52
+ unless missing_replace.empty?
53
+ fail "Missing search/replace for #{missing_replace.join(',')}"
54
+ end
55
+ end
56
+
57
+ def process(doc)
58
+ self.opts.each_pair do |k,v|
59
+ if doc.has_key?(k)
60
+ search, replace = v.split('=', 2)
61
+ search = Regexp.new(search)
62
+ if self.all
63
+ doc[k] = doc[k].gsub(search, replace)
64
+ else
65
+ doc[k] = doc[k].sub(search, replace)
66
+ end
67
+ end
68
+ end
69
+ [ doc ]
70
+ end
71
+ end
72
+
73
+ class FilterFieldReplaceAll < FilterFieldReplace
74
+ def initialize(args)
75
+ super(args, all=true)
76
+ end
77
+ end
78
+
44
79
  # Example below replaces periods with underscores in the names of all keys
45
80
  # one level below 'my_key'
46
81
  # rename_subkey_match my_key '.' '_'
data/lib/dap/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dap
2
- VERSION = "0.1.17"
2
+ VERSION = "0.1.18"
3
3
  end
@@ -270,16 +270,26 @@ describe Dap::Filter::FilterTransform do
270
270
  end
271
271
  end
272
272
 
273
- describe Dap::Filter::FilterFieldSplit do
273
+ describe Dap::Filter::FilterFieldReplace do
274
274
  describe '.process' do
275
275
 
276
- let(:filter) { described_class.new(["value=\\."]) }
276
+ let(:filter) { described_class.new(["value1=foo=bar"]) }
277
277
 
278
- context 'splitting on regex boundary' do
279
- let(:process) { filter.process({"value" => "foo.bar.baf"}) }
280
- it 'splits correctly' do
281
- expect(process).to eq([{"value" => "foo.bar.baf", "value.f1" => "foo", "value.f2" => "bar", "value.f3" => "baf"}])
282
- end
278
+ let(:process) { filter.process({"value1" => "foo.bar.foo", "value2" => "secret"}) }
279
+ it 'replaced correctly' do
280
+ expect(process).to eq([{"value1" => "bar.bar.foo", "value2" => "secret"}])
281
+ end
282
+ end
283
+ end
284
+
285
+ describe Dap::Filter::FilterFieldReplaceAll do
286
+ describe '.process' do
287
+
288
+ let(:filter) { described_class.new(["value1=foo=bar"]) }
289
+
290
+ let(:process) { filter.process({"value1" => "foo.bar.foo", "value2" => "secret"}) }
291
+ it 'replaced correctly' do
292
+ expect(process).to eq([{"value1" => "bar.bar.bar", "value2" => "secret"}])
283
293
  end
284
294
  end
285
295
  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.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rapid7 Research
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-29 00:00:00.000000000 Z
11
+ date: 2018-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  version: '0'
254
254
  requirements: []
255
255
  rubyforge_project:
256
- rubygems_version: 2.6.11
256
+ rubygems_version: 2.5.2
257
257
  signing_key:
258
258
  specification_version: 4
259
259
  summary: 'DAP: The Data Analysis Pipeline'