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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff9410dfc65b7f7aa6445a67ef23e153c185383f
4
- data.tar.gz: 7dbb33c223d9523223b1517940a7cfb961aafd76
3
+ metadata.gz: 7a9880b87fe8e6e3eaee36512e13fcaf8640a855
4
+ data.tar.gz: 35ad6bf8576fd40ffd0f76c6abece7be2dc0c777
5
5
  SHA512:
6
- metadata.gz: 3c9663e75f37a411208cc45daf18789aed596ef90ce314ac48c870ccce2aca0d81fe52afbdf2160df924565dfe0edf15b26bd0479b25c5cae664eebf17093d1d
7
- data.tar.gz: 81fe7e7456f13f1aa79261c88166dae6da32200c463992526f8d323e924cff941d09efc26c4f3941b05a7fc103d07f2547a5397713635e42ea77af0fa963a453
6
+ metadata.gz: 247f8fecff1dce17689365819ca0ed9b22bb6f7070add950a0a6489598088abebb97cd183a5acae6b95189346e13080cefa9dceb2432dc853813f90d3bd1f46d
7
+ data.tar.gz: 9e5fd1527d677c448c770bc88966880c2ab1e88ec670ac8e7dd9979ba7c2dfca2940d757e91480eae303f0826ba5194a663895495a2ce231266350419ac5cc1d
@@ -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'
@@ -1,3 +1,3 @@
1
1
  module Dap
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -127,19 +127,66 @@ end
127
127
  describe Dap::Filter::FilterTransform do
128
128
  describe '.process' do
129
129
 
130
- let(:filter) { described_class.new(['foo=reverse']) }
130
+ context 'reverse' do
131
+ let(:filter) { described_class.new(['foo=reverse']) }
131
132
 
132
- context 'ASCII' do
133
- let(:process) { filter.process({'foo' => 'abc123'}) }
134
- it 'is reversed' do
135
- expect(process).to eq(['foo' => '321cba'])
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 'UTF-8' do
140
- let(:process) { filter.process({'foo' => '☹☠'}) }
141
- it 'is reversed' do
142
- expect(process).to eq(['foo' => '☠☹'])
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.7
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-07-27 00:00:00.000000000 Z
11
+ date: 2017-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec