dap 0.1.7 → 0.1.8
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 +9 -0
- data/lib/dap/version.rb +1 -1
- data/spec/dap/filter/simple_filter_spec.rb +56 -9
- 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: 7a9880b87fe8e6e3eaee36512e13fcaf8640a855
|
4
|
+
data.tar.gz: 35ad6bf8576fd40ffd0f76c6abece7be2dc0c777
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 247f8fecff1dce17689365819ca0ed9b22bb6f7070add950a0a6489598088abebb97cd183a5acae6b95189346e13080cefa9dceb2432dc853813f90d3bd1f46d
|
7
|
+
data.tar.gz: 9e5fd1527d677c448c770bc88966880c2ab1e88ec670ac8e7dd9979ba7c2dfca2940d757e91480eae303f0826ba5194a663895495a2ce231266350419ac5cc1d
|
data/lib/dap/filter/simple.rb
CHANGED
@@ -221,6 +221,15 @@ class FilterTransform
|
|
221
221
|
self.opts.each_pair do |k,v|
|
222
222
|
if doc.has_key?(k)
|
223
223
|
case v
|
224
|
+
when /^int(?<base>\d+)?$/
|
225
|
+
base = $LAST_MATCH_INFO['base']
|
226
|
+
if base.nil?
|
227
|
+
doc[k] = doc[k].to_s.to_i
|
228
|
+
else
|
229
|
+
doc[k] = doc[k].to_s.to_i(base.to_i)
|
230
|
+
end
|
231
|
+
when 'float'
|
232
|
+
doc[k] = doc[k].to_f
|
224
233
|
when 'reverse'
|
225
234
|
doc[k] = doc[k].to_s.reverse
|
226
235
|
when 'downcase'
|
data/lib/dap/version.rb
CHANGED
@@ -127,19 +127,66 @@ end
|
|
127
127
|
describe Dap::Filter::FilterTransform do
|
128
128
|
describe '.process' do
|
129
129
|
|
130
|
-
|
130
|
+
context 'reverse' do
|
131
|
+
let(:filter) { described_class.new(['foo=reverse']) }
|
131
132
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
context 'ASCII' do
|
134
|
+
let(:process) { filter.process({'foo' => 'abc123'}) }
|
135
|
+
it 'is reversed' do
|
136
|
+
expect(process).to eq(['foo' => '321cba'])
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'UTF-8' do
|
141
|
+
let(:process) { filter.process({'foo' => '☹☠'}) }
|
142
|
+
it 'is reversed' do
|
143
|
+
expect(process).to eq(['foo' => '☠☹'])
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context 'int default' do
|
149
|
+
let(:filter) { described_class.new(['val=int']) }
|
150
|
+
|
151
|
+
context 'valid int' do
|
152
|
+
let(:process) { filter.process({'val' => '1'}) }
|
153
|
+
it 'is the correct int' do
|
154
|
+
expect(process).to eq(['val' => 1])
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'invalid int' do
|
159
|
+
let(:process) { filter.process({'val' => 'cats'}) }
|
160
|
+
it 'is the correct int' do
|
161
|
+
expect(process).to eq(['val' => 0])
|
162
|
+
end
|
136
163
|
end
|
137
164
|
end
|
138
165
|
|
139
|
-
context '
|
140
|
-
let(:
|
141
|
-
|
142
|
-
|
166
|
+
context 'int different base' do
|
167
|
+
let(:filter) { described_class.new(['val=int16']) }
|
168
|
+
let(:process) { filter.process({'val' => 'FF'}) }
|
169
|
+
|
170
|
+
it 'is the correct int' do
|
171
|
+
expect(process).to eq(['val' => 255])
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'float' do
|
176
|
+
let(:filter) { described_class.new(['val=float']) }
|
177
|
+
|
178
|
+
context 'valid float' do
|
179
|
+
let(:process) { filter.process({'val' => '1.0'}) }
|
180
|
+
it 'is the correct float' do
|
181
|
+
expect(process).to eq(['val' => 1.0])
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
context 'invalid float' do
|
186
|
+
let(:process) { filter.process({'val' => 'cats.0'}) }
|
187
|
+
it 'is the correct float' do
|
188
|
+
expect(process).to eq(['val' => 0.0])
|
189
|
+
end
|
143
190
|
end
|
144
191
|
end
|
145
192
|
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.8
|
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-
|
11
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|