dap 0.1.16 → 0.1.17
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 +24 -0
- data/lib/dap/version.rb +1 -1
- data/spec/dap/filter/simple_filter_spec.rb +54 -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: 2e146c070dd214aa21525479a886b4ec7e55acaf
|
4
|
+
data.tar.gz: 3a77f7551e728509cab65628c4bf4fc1a9cb6756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27cde6207fb2c159da33baea2ce76128461767cd560e1d75df2c0aae488bacbce7c7fbaf8da0f83ff5e0632c805159593162352d0c291f19bb45f9a81dabe788
|
7
|
+
data.tar.gz: e033ae7ed70d7b74ebba00979673ea4fa555fb6984710e673fa51d66735d58e4ee0daf45afbcd71ca4b47637df23f8bdfca57326ba433cf06252ba521f758d67
|
data/lib/dap/filter/simple.rb
CHANGED
@@ -107,6 +107,24 @@ class FilterMatchSelect
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
+
class FilterMatchSelectKey < FilterMatchSelect
|
111
|
+
end
|
112
|
+
|
113
|
+
class FilterMatchSelectValue
|
114
|
+
include Base
|
115
|
+
def process(doc)
|
116
|
+
ndoc = {}
|
117
|
+
self.opts.each_pair do |re,|
|
118
|
+
doc.each_key do |k|
|
119
|
+
if doc[k].match(re)
|
120
|
+
ndoc[k] = doc[k]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
(ndoc.keys.length == 0) ? [] : [ ndoc ]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
110
128
|
class FilterSelect
|
111
129
|
include Base
|
112
130
|
def process(doc)
|
@@ -237,6 +255,12 @@ class FilterTransform
|
|
237
255
|
doc[k] = doc[k].to_s.downcase
|
238
256
|
when 'upcase'
|
239
257
|
doc[k] = doc[k].to_s.upcase
|
258
|
+
when /^(lstrip|ltrim)$/
|
259
|
+
doc[k] = doc[k].to_s.lstrip
|
260
|
+
when /^(rstrip|rtrim)$/
|
261
|
+
doc[k] = doc[k].to_s.rstrip
|
262
|
+
when /^(strip|trim)$/
|
263
|
+
doc[k] = doc[k].to_s.strip
|
240
264
|
when 'ascii'
|
241
265
|
doc[k] = doc[k].to_s.gsub(/[\x00-\x1f\x7f-\xff]/n, '')
|
242
266
|
when 'json'
|
data/lib/dap/version.rb
CHANGED
@@ -124,6 +124,34 @@ describe Dap::Filter::FilterSelect do
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
describe Dap::Filter::FilterMatchSelectKey do
|
128
|
+
describe '.process' do
|
129
|
+
|
130
|
+
let(:filter) { described_class.new(["foo."]) }
|
131
|
+
|
132
|
+
context 'with similar keys' do
|
133
|
+
let(:process) { filter.process({"foo" => "bar", "foo.blah" => "blah", "foo.bar" => "baz"}) }
|
134
|
+
it 'selects the expected keys' do
|
135
|
+
expect(process).to eq([{"foo.blah" => "blah", "foo.bar" => "baz"}])
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe Dap::Filter::FilterMatchSelectValue do
|
142
|
+
describe '.process' do
|
143
|
+
|
144
|
+
let(:filter) { described_class.new(["ba"]) }
|
145
|
+
|
146
|
+
context 'with similar keys' do
|
147
|
+
let(:process) { filter.process({"foo" => "bar", "foo.blah" => "blah", "foo.bar" => "baz"}) }
|
148
|
+
it 'selects the expected keys' do
|
149
|
+
expect(process).to eq([{"foo" => "bar", "foo.bar" => "baz"}])
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
127
155
|
describe Dap::Filter::FilterTransform do
|
128
156
|
describe '.process' do
|
129
157
|
|
@@ -213,6 +241,32 @@ describe Dap::Filter::FilterTransform do
|
|
213
241
|
end
|
214
242
|
end
|
215
243
|
end
|
244
|
+
|
245
|
+
context 'stripping' do
|
246
|
+
context 'lstrip' do
|
247
|
+
let(:filter) { described_class.new(['foo=lstrip']) }
|
248
|
+
let(:process) { filter.process({'foo' => ' abc123 '}) }
|
249
|
+
it 'lstripped' do
|
250
|
+
expect(process).to eq(['foo' => 'abc123 '])
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
context 'rstrip' do
|
255
|
+
let(:filter) { described_class.new(['foo=rstrip']) }
|
256
|
+
let(:process) { filter.process({'foo' => ' abc123 '}) }
|
257
|
+
it 'rstripped' do
|
258
|
+
expect(process).to eq(['foo' => ' abc123'])
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
context 'strip' do
|
263
|
+
let(:filter) { described_class.new(['foo=strip']) }
|
264
|
+
let(:process) { filter.process({'foo' => ' abc123 '}) }
|
265
|
+
it 'stripped' do
|
266
|
+
expect(process).to eq(['foo' => 'abc123'])
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
216
270
|
end
|
217
271
|
end
|
218
272
|
|
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.17
|
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-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|