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 +4 -4
- data/lib/dap/filter/simple.rb +35 -0
- data/lib/dap/version.rb +1 -1
- data/spec/dap/filter/simple_filter_spec.rb +17 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 663523feb89fe2398a95fe119a2325a52400175b
|
4
|
+
data.tar.gz: 672a9e854a7f3a9e8d3ee477d0e3b6e077111c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8d53e2fe84af682bffe4474a8bf61e8d72adecdcd8c18dca0e76560d8467295cc85af2b1e0b9f0ce0e6d7f884d2d10de8741512d6a2a262706ebe5f97aa9e57
|
7
|
+
data.tar.gz: 547b613736c776d94dbcc87abb467e62df5c6e246a0896d475a07ab0e6d98f6a3374b51455c2d8e985acb60134ea0d712c0cdf00453051bc969f70e1bc7f4a81
|
data/lib/dap/filter/simple.rb
CHANGED
@@ -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
@@ -270,16 +270,26 @@ describe Dap::Filter::FilterTransform do
|
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
|
-
describe Dap::Filter::
|
273
|
+
describe Dap::Filter::FilterFieldReplace do
|
274
274
|
describe '.process' do
|
275
275
|
|
276
|
-
let(:filter) { described_class.new(["
|
276
|
+
let(:filter) { described_class.new(["value1=foo=bar"]) }
|
277
277
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
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.
|
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-
|
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.
|
256
|
+
rubygems_version: 2.5.2
|
257
257
|
signing_key:
|
258
258
|
specification_version: 4
|
259
259
|
summary: 'DAP: The Data Analysis Pipeline'
|