sinatra-param 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +38 -26
- data/LICENSE +1 -1
- data/README.md +35 -22
- data/coverage/assets/0.10.2/application.css +799 -0
- data/coverage/assets/0.10.2/application.js +1707 -0
- data/coverage/assets/0.10.2/colorbox/border.png +0 -0
- data/coverage/assets/0.10.2/colorbox/controls.png +0 -0
- data/coverage/assets/0.10.2/colorbox/loading.gif +0 -0
- data/coverage/assets/0.10.2/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.10.2/favicon_green.png +0 -0
- data/coverage/assets/0.10.2/favicon_red.png +0 -0
- data/coverage/assets/0.10.2/favicon_yellow.png +0 -0
- data/coverage/assets/0.10.2/loading.gif +0 -0
- data/coverage/assets/0.10.2/magnify.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +208 -189
- data/example/Gemfile +4 -4
- data/example/Gemfile.lock +24 -17
- data/lib/sinatra/param.rb +6 -3
- data/lib/sinatra/param/version.rb +1 -1
- data/sinatra-param.gemspec +3 -3
- data/spec/dummy/app.rb +10 -0
- data/spec/parameter_raise_spec.rb +3 -3
- data/spec/parameter_type_coercion_spec.rb +16 -0
- data/spec/parameter_validations_spec.rb +22 -0
- metadata +95 -73
- data/sinatra-param-1.3.0.gem +0 -0
- data/sinatra-param-1.3.1.gem +0 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/coverage/index.html
CHANGED
@@ -3,18 +3,18 @@
|
|
3
3
|
<head>
|
4
4
|
<title>Code coverage for Sinatra-param</title>
|
5
5
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
6
|
-
<script src='./assets/0.
|
7
|
-
<link href='./assets/0.
|
8
|
-
<link rel="shortcut icon" type="image/png" href="./assets/0.
|
9
|
-
<link rel="icon" type="image/png" href="./assets/0.
|
6
|
+
<script src='./assets/0.10.2/application.js' type='text/javascript'></script>
|
7
|
+
<link href='./assets/0.10.2/application.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
|
8
|
+
<link rel="shortcut icon" type="image/png" href="./assets/0.10.2/favicon_green.png" />
|
9
|
+
<link rel="icon" type="image/png" href="./assets/0.10.2/favicon.png" />
|
10
10
|
</head>
|
11
11
|
|
12
12
|
<body>
|
13
13
|
<div id="loading">
|
14
|
-
<img src="./assets/0.
|
14
|
+
<img src="./assets/0.10.2/loading.gif" alt="loading"/>
|
15
15
|
</div>
|
16
16
|
<div id="wrapper" style="display:none;">
|
17
|
-
<div class="timestamp">Generated <abbr class="timeago" title="
|
17
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2018-03-20T09:45:02-07:00">2018-03-20T09:45:02-07:00</abbr></div>
|
18
18
|
<ul class="group_tabs"></ul>
|
19
19
|
|
20
20
|
<div id="content">
|
@@ -25,15 +25,15 @@
|
|
25
25
|
covered at
|
26
26
|
<span class="covered_strength">
|
27
27
|
<span class="green">
|
28
|
-
|
28
|
+
22.7
|
29
29
|
</span>
|
30
30
|
</span> hits/line)
|
31
31
|
</h2>
|
32
32
|
<a name="AllFiles"></a>
|
33
33
|
<div>
|
34
34
|
<b>1</b> files in total.
|
35
|
-
<b>
|
36
|
-
<span class="green"><b>
|
35
|
+
<b>98</b> relevant lines.
|
36
|
+
<span class="green"><b>98</b> lines covered</span> and
|
37
37
|
<span class="red"><b>0</b> lines missed </span>
|
38
38
|
</div>
|
39
39
|
<table class="file_list">
|
@@ -53,11 +53,11 @@
|
|
53
53
|
<tr>
|
54
54
|
<td class="strong"><a href="#0f7926ededdfd8418773c107837b6dc4182659b8" class="src_link" title="lib/sinatra/param.rb">lib/sinatra/param.rb</a></td>
|
55
55
|
<td class="green strong">100.0 %</td>
|
56
|
-
<td>
|
57
|
-
<td>
|
58
|
-
<td>
|
56
|
+
<td>167</td>
|
57
|
+
<td>98</td>
|
58
|
+
<td>98</td>
|
59
59
|
<td>0</td>
|
60
|
-
<td>
|
60
|
+
<td>22.7</td>
|
61
61
|
</tr>
|
62
62
|
|
63
63
|
</tbody>
|
@@ -69,8 +69,8 @@
|
|
69
69
|
</div>
|
70
70
|
|
71
71
|
<div id="footer">
|
72
|
-
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.
|
73
|
-
and simplecov-html v0.
|
72
|
+
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.16.1
|
73
|
+
and simplecov-html v0.10.2<br/>
|
74
74
|
using RSpec
|
75
75
|
</div>
|
76
76
|
|
@@ -81,8 +81,8 @@
|
|
81
81
|
<h3>lib/sinatra/param.rb</h3>
|
82
82
|
<h4><span class="green">100.0 %</span> covered</h4>
|
83
83
|
<div>
|
84
|
-
<b>
|
85
|
-
<span class="green"><b>
|
84
|
+
<b>98</b> relevant lines.
|
85
|
+
<span class="green"><b>98</b> lines covered</span> and
|
86
86
|
<span class="red"><b>0</b> lines missed.</span>
|
87
87
|
</div>
|
88
88
|
</div>
|
@@ -174,8 +174,8 @@
|
|
174
174
|
<code class="ruby"> def param(name, type, options = {})</code>
|
175
175
|
</li>
|
176
176
|
|
177
|
-
<li class="covered" data-hits="
|
178
|
-
<span class="hits">
|
177
|
+
<li class="covered" data-hits="152" data-linenumber="15">
|
178
|
+
<span class="hits">152</span>
|
179
179
|
|
180
180
|
<code class="ruby"> name = name.to_s</code>
|
181
181
|
</li>
|
@@ -186,10 +186,10 @@
|
|
186
186
|
<code class="ruby"></code>
|
187
187
|
</li>
|
188
188
|
|
189
|
-
<li class="covered" data-hits="
|
190
|
-
<span class="hits">
|
189
|
+
<li class="covered" data-hits="152" data-linenumber="17">
|
190
|
+
<span class="hits">152</span>
|
191
191
|
|
192
|
-
<code class="ruby"> return unless params.member?(name) or options
|
192
|
+
<code class="ruby"> return unless params.member?(name) or options.has_key?(:default) or options[:required]</code>
|
193
193
|
</li>
|
194
194
|
|
195
195
|
<li class="never" data-hits="" data-linenumber="18">
|
@@ -198,877 +198,895 @@
|
|
198
198
|
<code class="ruby"></code>
|
199
199
|
</li>
|
200
200
|
|
201
|
-
<li class="covered" data-hits="
|
202
|
-
<span class="hits">
|
201
|
+
<li class="covered" data-hits="107" data-linenumber="19">
|
202
|
+
<span class="hits">107</span>
|
203
203
|
|
204
204
|
<code class="ruby"> begin</code>
|
205
205
|
</li>
|
206
206
|
|
207
|
-
<li class="covered" data-hits="
|
208
|
-
<span class="hits">
|
207
|
+
<li class="covered" data-hits="107" data-linenumber="20">
|
208
|
+
<span class="hits">107</span>
|
209
209
|
|
210
210
|
<code class="ruby"> params[name] = coerce(params[name], type, options)</code>
|
211
211
|
</li>
|
212
212
|
|
213
|
-
<li class="covered" data-hits="
|
214
|
-
<span class="hits">
|
213
|
+
<li class="covered" data-hits="102" data-linenumber="21">
|
214
|
+
<span class="hits">102</span>
|
215
215
|
|
216
|
-
<code class="ruby"> params[name] = (options[:default].call if options[:default].respond_to?(:call)) || options[:default] if params[name].nil? and options
|
216
|
+
<code class="ruby"> params[name] = (options[:default].call if options[:default].respond_to?(:call)) || options[:default] if params[name].nil? and options.has_key?(:default)</code>
|
217
217
|
</li>
|
218
218
|
|
219
|
-
<li class="covered" data-hits="
|
220
|
-
<span class="hits">
|
219
|
+
<li class="covered" data-hits="102" data-linenumber="22">
|
220
|
+
<span class="hits">102</span>
|
221
221
|
|
222
222
|
<code class="ruby"> params[name] = options[:transform].to_proc.call(params[name]) if params[name] and options[:transform]</code>
|
223
223
|
</li>
|
224
224
|
|
225
|
-
<li class="covered" data-hits="
|
226
|
-
<span class="hits">
|
225
|
+
<li class="covered" data-hits="102" data-linenumber="23">
|
226
|
+
<span class="hits">102</span>
|
227
227
|
|
228
228
|
<code class="ruby"> validate!(params[name], options)</code>
|
229
229
|
</li>
|
230
230
|
|
231
|
-
<li class="covered" data-hits="
|
232
|
-
<span class="hits">
|
231
|
+
<li class="covered" data-hits="82" data-linenumber="24">
|
232
|
+
<span class="hits">82</span>
|
233
|
+
|
234
|
+
<code class="ruby"> params[name]</code>
|
235
|
+
</li>
|
236
|
+
|
237
|
+
<li class="covered" data-hits="25" data-linenumber="25">
|
238
|
+
<span class="hits">25</span>
|
233
239
|
|
234
240
|
<code class="ruby"> rescue InvalidParameterError => exception</code>
|
235
241
|
</li>
|
236
242
|
|
237
|
-
<li class="covered" data-hits="
|
238
|
-
<span class="hits">
|
243
|
+
<li class="covered" data-hits="25" data-linenumber="26">
|
244
|
+
<span class="hits">25</span>
|
239
245
|
|
240
246
|
<code class="ruby"> if options[:raise] or (settings.raise_sinatra_param_exceptions rescue false)</code>
|
241
247
|
</li>
|
242
248
|
|
243
|
-
<li class="covered" data-hits="1" data-linenumber="
|
249
|
+
<li class="covered" data-hits="1" data-linenumber="27">
|
244
250
|
<span class="hits">1</span>
|
245
251
|
|
246
252
|
<code class="ruby"> exception.param, exception.options = name, options</code>
|
247
253
|
</li>
|
248
254
|
|
249
|
-
<li class="covered" data-hits="1" data-linenumber="
|
255
|
+
<li class="covered" data-hits="1" data-linenumber="28">
|
250
256
|
<span class="hits">1</span>
|
251
257
|
|
252
258
|
<code class="ruby"> raise exception</code>
|
253
259
|
</li>
|
254
260
|
|
255
|
-
<li class="never" data-hits="" data-linenumber="
|
261
|
+
<li class="never" data-hits="" data-linenumber="29">
|
256
262
|
|
257
263
|
|
258
264
|
<code class="ruby"> end</code>
|
259
265
|
</li>
|
260
266
|
|
261
|
-
<li class="never" data-hits="" data-linenumber="
|
267
|
+
<li class="never" data-hits="" data-linenumber="30">
|
262
268
|
|
263
269
|
|
264
270
|
<code class="ruby"></code>
|
265
271
|
</li>
|
266
272
|
|
267
|
-
<li class="covered" data-hits="
|
268
|
-
<span class="hits">
|
273
|
+
<li class="covered" data-hits="24" data-linenumber="31">
|
274
|
+
<span class="hits">24</span>
|
269
275
|
|
270
|
-
<code class="ruby"> error = exception.to_s</code>
|
276
|
+
<code class="ruby"> error = options[:message] || exception.to_s</code>
|
271
277
|
</li>
|
272
278
|
|
273
|
-
<li class="never" data-hits="" data-linenumber="
|
279
|
+
<li class="never" data-hits="" data-linenumber="32">
|
274
280
|
|
275
281
|
|
276
282
|
<code class="ruby"></code>
|
277
283
|
</li>
|
278
284
|
|
279
|
-
<li class="covered" data-hits="
|
280
|
-
<span class="hits">
|
285
|
+
<li class="covered" data-hits="24" data-linenumber="33">
|
286
|
+
<span class="hits">24</span>
|
281
287
|
|
282
288
|
<code class="ruby"> if content_type and content_type.match(mime_type(:json))</code>
|
283
289
|
</li>
|
284
290
|
|
285
|
-
<li class="covered" data-hits="
|
286
|
-
<span class="hits">
|
291
|
+
<li class="covered" data-hits="23" data-linenumber="34">
|
292
|
+
<span class="hits">23</span>
|
287
293
|
|
288
294
|
<code class="ruby"> error = {message: error, errors: {name => exception.message}}.to_json</code>
|
289
295
|
</li>
|
290
296
|
|
291
|
-
<li class="never" data-hits="" data-linenumber="
|
297
|
+
<li class="never" data-hits="" data-linenumber="35">
|
298
|
+
|
299
|
+
|
300
|
+
<code class="ruby"> else</code>
|
301
|
+
</li>
|
302
|
+
|
303
|
+
<li class="covered" data-hits="1" data-linenumber="36">
|
304
|
+
<span class="hits">1</span>
|
305
|
+
|
306
|
+
<code class="ruby"> content_type 'text/plain'</code>
|
307
|
+
</li>
|
308
|
+
|
309
|
+
<li class="never" data-hits="" data-linenumber="37">
|
292
310
|
|
293
311
|
|
294
312
|
<code class="ruby"> end</code>
|
295
313
|
</li>
|
296
314
|
|
297
|
-
<li class="never" data-hits="" data-linenumber="
|
315
|
+
<li class="never" data-hits="" data-linenumber="38">
|
298
316
|
|
299
317
|
|
300
318
|
<code class="ruby"></code>
|
301
319
|
</li>
|
302
320
|
|
303
|
-
<li class="covered" data-hits="
|
304
|
-
<span class="hits">
|
321
|
+
<li class="covered" data-hits="24" data-linenumber="39">
|
322
|
+
<span class="hits">24</span>
|
305
323
|
|
306
324
|
<code class="ruby"> halt 400, error</code>
|
307
325
|
</li>
|
308
326
|
|
309
|
-
<li class="never" data-hits="" data-linenumber="
|
327
|
+
<li class="never" data-hits="" data-linenumber="40">
|
310
328
|
|
311
329
|
|
312
330
|
<code class="ruby"> end</code>
|
313
331
|
</li>
|
314
332
|
|
315
|
-
<li class="never" data-hits="" data-linenumber="
|
333
|
+
<li class="never" data-hits="" data-linenumber="41">
|
316
334
|
|
317
335
|
|
318
336
|
<code class="ruby"> end</code>
|
319
337
|
</li>
|
320
338
|
|
321
|
-
<li class="never" data-hits="" data-linenumber="
|
339
|
+
<li class="never" data-hits="" data-linenumber="42">
|
322
340
|
|
323
341
|
|
324
342
|
<code class="ruby"></code>
|
325
343
|
</li>
|
326
344
|
|
327
|
-
<li class="covered" data-hits="1" data-linenumber="
|
345
|
+
<li class="covered" data-hits="1" data-linenumber="43">
|
328
346
|
<span class="hits">1</span>
|
329
347
|
|
330
348
|
<code class="ruby"> def one_of(*args)</code>
|
331
349
|
</li>
|
332
350
|
|
333
|
-
<li class="covered" data-hits="17" data-linenumber="
|
351
|
+
<li class="covered" data-hits="17" data-linenumber="44">
|
334
352
|
<span class="hits">17</span>
|
335
353
|
|
336
354
|
<code class="ruby"> options = args.last.is_a?(Hash) ? args.pop : {}</code>
|
337
355
|
</li>
|
338
356
|
|
339
|
-
<li class="covered" data-hits="17" data-linenumber="
|
357
|
+
<li class="covered" data-hits="17" data-linenumber="45">
|
340
358
|
<span class="hits">17</span>
|
341
359
|
|
342
360
|
<code class="ruby"> names = args.collect(&:to_s)</code>
|
343
361
|
</li>
|
344
362
|
|
345
|
-
<li class="never" data-hits="" data-linenumber="
|
363
|
+
<li class="never" data-hits="" data-linenumber="46">
|
346
364
|
|
347
365
|
|
348
366
|
<code class="ruby"></code>
|
349
367
|
</li>
|
350
368
|
|
351
|
-
<li class="covered" data-hits="17" data-linenumber="
|
369
|
+
<li class="covered" data-hits="17" data-linenumber="47">
|
352
370
|
<span class="hits">17</span>
|
353
371
|
|
354
372
|
<code class="ruby"> return unless names.length >= 2</code>
|
355
373
|
</li>
|
356
374
|
|
357
|
-
<li class="never" data-hits="" data-linenumber="
|
375
|
+
<li class="never" data-hits="" data-linenumber="48">
|
358
376
|
|
359
377
|
|
360
378
|
<code class="ruby"></code>
|
361
379
|
</li>
|
362
380
|
|
363
|
-
<li class="covered" data-hits="13" data-linenumber="
|
381
|
+
<li class="covered" data-hits="13" data-linenumber="49">
|
364
382
|
<span class="hits">13</span>
|
365
383
|
|
366
384
|
<code class="ruby"> begin</code>
|
367
385
|
</li>
|
368
386
|
|
369
|
-
<li class="covered" data-hits="13" data-linenumber="
|
387
|
+
<li class="covered" data-hits="13" data-linenumber="50">
|
370
388
|
<span class="hits">13</span>
|
371
389
|
|
372
390
|
<code class="ruby"> validate_one_of!(params, names, options)</code>
|
373
391
|
</li>
|
374
392
|
|
375
|
-
<li class="covered" data-hits="5" data-linenumber="
|
393
|
+
<li class="covered" data-hits="5" data-linenumber="51">
|
376
394
|
<span class="hits">5</span>
|
377
395
|
|
378
396
|
<code class="ruby"> rescue InvalidParameterError => exception</code>
|
379
397
|
</li>
|
380
398
|
|
381
|
-
<li class="covered" data-hits="5" data-linenumber="
|
399
|
+
<li class="covered" data-hits="5" data-linenumber="52">
|
382
400
|
<span class="hits">5</span>
|
383
401
|
|
384
402
|
<code class="ruby"> if options[:raise] or (settings.raise_sinatra_param_exceptions rescue false)</code>
|
385
403
|
</li>
|
386
404
|
|
387
|
-
<li class="covered" data-hits="1" data-linenumber="
|
405
|
+
<li class="covered" data-hits="1" data-linenumber="53">
|
388
406
|
<span class="hits">1</span>
|
389
407
|
|
390
408
|
<code class="ruby"> exception.param, exception.options = names, options</code>
|
391
409
|
</li>
|
392
410
|
|
393
|
-
<li class="covered" data-hits="1" data-linenumber="
|
411
|
+
<li class="covered" data-hits="1" data-linenumber="54">
|
394
412
|
<span class="hits">1</span>
|
395
413
|
|
396
414
|
<code class="ruby"> raise exception</code>
|
397
415
|
</li>
|
398
416
|
|
399
|
-
<li class="never" data-hits="" data-linenumber="
|
417
|
+
<li class="never" data-hits="" data-linenumber="55">
|
400
418
|
|
401
419
|
|
402
420
|
<code class="ruby"> end</code>
|
403
421
|
</li>
|
404
422
|
|
405
|
-
<li class="never" data-hits="" data-linenumber="
|
423
|
+
<li class="never" data-hits="" data-linenumber="56">
|
406
424
|
|
407
425
|
|
408
426
|
<code class="ruby"></code>
|
409
427
|
</li>
|
410
428
|
|
411
|
-
<li class="covered" data-hits="4" data-linenumber="
|
429
|
+
<li class="covered" data-hits="4" data-linenumber="57">
|
412
430
|
<span class="hits">4</span>
|
413
431
|
|
414
432
|
<code class="ruby"> error = "Invalid parameters [#{names.join(', ')}]"</code>
|
415
433
|
</li>
|
416
434
|
|
417
|
-
<li class="covered" data-hits="4" data-linenumber="
|
435
|
+
<li class="covered" data-hits="4" data-linenumber="58">
|
418
436
|
<span class="hits">4</span>
|
419
437
|
|
420
438
|
<code class="ruby"> if content_type and content_type.match(mime_type(:json))</code>
|
421
439
|
</li>
|
422
440
|
|
423
|
-
<li class="covered" data-hits="4" data-linenumber="
|
441
|
+
<li class="covered" data-hits="4" data-linenumber="59">
|
424
442
|
<span class="hits">4</span>
|
425
443
|
|
426
444
|
<code class="ruby"> error = {message: error, errors: {names => exception.message}}.to_json</code>
|
427
445
|
</li>
|
428
446
|
|
429
|
-
<li class="never" data-hits="" data-linenumber="
|
447
|
+
<li class="never" data-hits="" data-linenumber="60">
|
430
448
|
|
431
449
|
|
432
450
|
<code class="ruby"> end</code>
|
433
451
|
</li>
|
434
452
|
|
435
|
-
<li class="never" data-hits="" data-linenumber="
|
453
|
+
<li class="never" data-hits="" data-linenumber="61">
|
436
454
|
|
437
455
|
|
438
456
|
<code class="ruby"></code>
|
439
457
|
</li>
|
440
458
|
|
441
|
-
<li class="covered" data-hits="4" data-linenumber="
|
459
|
+
<li class="covered" data-hits="4" data-linenumber="62">
|
442
460
|
<span class="hits">4</span>
|
443
461
|
|
444
462
|
<code class="ruby"> halt 400, error</code>
|
445
463
|
</li>
|
446
464
|
|
447
|
-
<li class="never" data-hits="" data-linenumber="
|
465
|
+
<li class="never" data-hits="" data-linenumber="63">
|
448
466
|
|
449
467
|
|
450
468
|
<code class="ruby"> end</code>
|
451
469
|
</li>
|
452
470
|
|
453
|
-
<li class="never" data-hits="" data-linenumber="
|
471
|
+
<li class="never" data-hits="" data-linenumber="64">
|
454
472
|
|
455
473
|
|
456
474
|
<code class="ruby"> end</code>
|
457
475
|
</li>
|
458
476
|
|
459
|
-
<li class="never" data-hits="" data-linenumber="
|
477
|
+
<li class="never" data-hits="" data-linenumber="65">
|
460
478
|
|
461
479
|
|
462
480
|
<code class="ruby"></code>
|
463
481
|
</li>
|
464
482
|
|
465
|
-
<li class="covered" data-hits="1" data-linenumber="
|
483
|
+
<li class="covered" data-hits="1" data-linenumber="66">
|
466
484
|
<span class="hits">1</span>
|
467
485
|
|
468
486
|
<code class="ruby"> def any_of(*args)</code>
|
469
487
|
</li>
|
470
488
|
|
471
|
-
<li class="covered" data-hits="8" data-linenumber="
|
489
|
+
<li class="covered" data-hits="8" data-linenumber="67">
|
472
490
|
<span class="hits">8</span>
|
473
491
|
|
474
492
|
<code class="ruby"> options = args.last.is_a?(Hash) ? args.pop : {}</code>
|
475
493
|
</li>
|
476
494
|
|
477
|
-
<li class="covered" data-hits="8" data-linenumber="
|
495
|
+
<li class="covered" data-hits="8" data-linenumber="68">
|
478
496
|
<span class="hits">8</span>
|
479
497
|
|
480
498
|
<code class="ruby"> names = args.collect(&:to_s)</code>
|
481
499
|
</li>
|
482
500
|
|
483
|
-
<li class="never" data-hits="" data-linenumber="
|
501
|
+
<li class="never" data-hits="" data-linenumber="69">
|
484
502
|
|
485
503
|
|
486
504
|
<code class="ruby"></code>
|
487
505
|
</li>
|
488
506
|
|
489
|
-
<li class="covered" data-hits="8" data-linenumber="
|
507
|
+
<li class="covered" data-hits="8" data-linenumber="70">
|
490
508
|
<span class="hits">8</span>
|
491
509
|
|
492
510
|
<code class="ruby"> return unless names.length >= 2</code>
|
493
511
|
</li>
|
494
512
|
|
495
|
-
<li class="never" data-hits="" data-linenumber="
|
513
|
+
<li class="never" data-hits="" data-linenumber="71">
|
496
514
|
|
497
515
|
|
498
516
|
<code class="ruby"></code>
|
499
517
|
</li>
|
500
518
|
|
501
|
-
<li class="covered" data-hits="8" data-linenumber="
|
519
|
+
<li class="covered" data-hits="8" data-linenumber="72">
|
502
520
|
<span class="hits">8</span>
|
503
521
|
|
504
522
|
<code class="ruby"> begin</code>
|
505
523
|
</li>
|
506
524
|
|
507
|
-
<li class="covered" data-hits="8" data-linenumber="
|
525
|
+
<li class="covered" data-hits="8" data-linenumber="73">
|
508
526
|
<span class="hits">8</span>
|
509
527
|
|
510
528
|
<code class="ruby"> validate_any_of!(params, names, options)</code>
|
511
529
|
</li>
|
512
530
|
|
513
|
-
<li class="covered" data-hits="2" data-linenumber="
|
531
|
+
<li class="covered" data-hits="2" data-linenumber="74">
|
514
532
|
<span class="hits">2</span>
|
515
533
|
|
516
534
|
<code class="ruby"> rescue InvalidParameterError => exception</code>
|
517
535
|
</li>
|
518
536
|
|
519
|
-
<li class="covered" data-hits="2" data-linenumber="
|
537
|
+
<li class="covered" data-hits="2" data-linenumber="75">
|
520
538
|
<span class="hits">2</span>
|
521
539
|
|
522
540
|
<code class="ruby"> if options[:raise] or (settings.raise_sinatra_param_exceptions rescue false)</code>
|
523
541
|
</li>
|
524
542
|
|
525
|
-
<li class="covered" data-hits="1" data-linenumber="
|
543
|
+
<li class="covered" data-hits="1" data-linenumber="76">
|
526
544
|
<span class="hits">1</span>
|
527
545
|
|
528
546
|
<code class="ruby"> exception.param, exception.options = names, options</code>
|
529
547
|
</li>
|
530
548
|
|
531
|
-
<li class="covered" data-hits="1" data-linenumber="
|
549
|
+
<li class="covered" data-hits="1" data-linenumber="77">
|
532
550
|
<span class="hits">1</span>
|
533
551
|
|
534
552
|
<code class="ruby"> raise exception</code>
|
535
553
|
</li>
|
536
554
|
|
537
|
-
<li class="never" data-hits="" data-linenumber="
|
555
|
+
<li class="never" data-hits="" data-linenumber="78">
|
538
556
|
|
539
557
|
|
540
558
|
<code class="ruby"> end</code>
|
541
559
|
</li>
|
542
560
|
|
543
|
-
<li class="never" data-hits="" data-linenumber="
|
561
|
+
<li class="never" data-hits="" data-linenumber="79">
|
544
562
|
|
545
563
|
|
546
564
|
<code class="ruby"></code>
|
547
565
|
</li>
|
548
566
|
|
549
|
-
<li class="covered" data-hits="1" data-linenumber="
|
567
|
+
<li class="covered" data-hits="1" data-linenumber="80">
|
550
568
|
<span class="hits">1</span>
|
551
569
|
|
552
570
|
<code class="ruby"> error = "Invalid parameters [#{names.join(', ')}]"</code>
|
553
571
|
</li>
|
554
572
|
|
555
|
-
<li class="covered" data-hits="1" data-linenumber="
|
573
|
+
<li class="covered" data-hits="1" data-linenumber="81">
|
556
574
|
<span class="hits">1</span>
|
557
575
|
|
558
576
|
<code class="ruby"> if content_type and content_type.match(mime_type(:json))</code>
|
559
577
|
</li>
|
560
578
|
|
561
|
-
<li class="covered" data-hits="1" data-linenumber="
|
579
|
+
<li class="covered" data-hits="1" data-linenumber="82">
|
562
580
|
<span class="hits">1</span>
|
563
581
|
|
564
582
|
<code class="ruby"> error = {message: error, errors: {names => exception.message}}.to_json</code>
|
565
583
|
</li>
|
566
584
|
|
567
|
-
<li class="never" data-hits="" data-linenumber="
|
585
|
+
<li class="never" data-hits="" data-linenumber="83">
|
568
586
|
|
569
587
|
|
570
588
|
<code class="ruby"> end</code>
|
571
589
|
</li>
|
572
590
|
|
573
|
-
<li class="never" data-hits="" data-linenumber="
|
591
|
+
<li class="never" data-hits="" data-linenumber="84">
|
574
592
|
|
575
593
|
|
576
594
|
<code class="ruby"></code>
|
577
595
|
</li>
|
578
596
|
|
579
|
-
<li class="covered" data-hits="1" data-linenumber="
|
597
|
+
<li class="covered" data-hits="1" data-linenumber="85">
|
580
598
|
<span class="hits">1</span>
|
581
599
|
|
582
600
|
<code class="ruby"> halt 400, error</code>
|
583
601
|
</li>
|
584
602
|
|
585
|
-
<li class="never" data-hits="" data-linenumber="
|
603
|
+
<li class="never" data-hits="" data-linenumber="86">
|
586
604
|
|
587
605
|
|
588
606
|
<code class="ruby"> end</code>
|
589
607
|
</li>
|
590
608
|
|
591
|
-
<li class="never" data-hits="" data-linenumber="
|
609
|
+
<li class="never" data-hits="" data-linenumber="87">
|
592
610
|
|
593
611
|
|
594
612
|
<code class="ruby"> end</code>
|
595
613
|
</li>
|
596
614
|
|
597
|
-
<li class="never" data-hits="" data-linenumber="
|
615
|
+
<li class="never" data-hits="" data-linenumber="88">
|
598
616
|
|
599
617
|
|
600
618
|
<code class="ruby"></code>
|
601
619
|
</li>
|
602
620
|
|
603
|
-
<li class="covered" data-hits="1" data-linenumber="
|
621
|
+
<li class="covered" data-hits="1" data-linenumber="89">
|
604
622
|
<span class="hits">1</span>
|
605
623
|
|
606
624
|
<code class="ruby"> private</code>
|
607
625
|
</li>
|
608
626
|
|
609
|
-
<li class="never" data-hits="" data-linenumber="
|
627
|
+
<li class="never" data-hits="" data-linenumber="90">
|
610
628
|
|
611
629
|
|
612
630
|
<code class="ruby"></code>
|
613
631
|
</li>
|
614
632
|
|
615
|
-
<li class="covered" data-hits="1" data-linenumber="
|
633
|
+
<li class="covered" data-hits="1" data-linenumber="91">
|
616
634
|
<span class="hits">1</span>
|
617
635
|
|
618
636
|
<code class="ruby"> def coerce(param, type, options = {})</code>
|
619
637
|
</li>
|
620
638
|
|
621
|
-
<li class="covered" data-hits="
|
622
|
-
<span class="hits">
|
639
|
+
<li class="covered" data-hits="107" data-linenumber="92">
|
640
|
+
<span class="hits">107</span>
|
623
641
|
|
624
642
|
<code class="ruby"> begin</code>
|
625
643
|
</li>
|
626
644
|
|
627
|
-
<li class="covered" data-hits="
|
628
|
-
<span class="hits">
|
645
|
+
<li class="covered" data-hits="107" data-linenumber="93">
|
646
|
+
<span class="hits">107</span>
|
629
647
|
|
630
648
|
<code class="ruby"> return nil if param.nil?</code>
|
631
649
|
</li>
|
632
650
|
|
633
|
-
<li class="covered" data-hits="
|
634
|
-
<span class="hits">
|
651
|
+
<li class="covered" data-hits="96" data-linenumber="94">
|
652
|
+
<span class="hits">96</span>
|
635
653
|
|
636
654
|
<code class="ruby"> return param if (param.is_a?(type) rescue false)</code>
|
637
655
|
</li>
|
638
656
|
|
639
|
-
<li class="covered" data-hits="46" data-linenumber="
|
657
|
+
<li class="covered" data-hits="46" data-linenumber="95">
|
640
658
|
<span class="hits">46</span>
|
641
659
|
|
642
660
|
<code class="ruby"> return Integer(param) if type == Integer</code>
|
643
661
|
</li>
|
644
662
|
|
645
|
-
<li class="covered" data-hits="35" data-linenumber="
|
663
|
+
<li class="covered" data-hits="35" data-linenumber="96">
|
646
664
|
<span class="hits">35</span>
|
647
665
|
|
648
666
|
<code class="ruby"> return Float(param) if type == Float</code>
|
649
667
|
</li>
|
650
668
|
|
651
|
-
<li class="covered" data-hits="33" data-linenumber="
|
669
|
+
<li class="covered" data-hits="33" data-linenumber="97">
|
652
670
|
<span class="hits">33</span>
|
653
671
|
|
654
672
|
<code class="ruby"> return String(param) if type == String</code>
|
655
673
|
</li>
|
656
674
|
|
657
|
-
<li class="covered" data-hits="32" data-linenumber="
|
675
|
+
<li class="covered" data-hits="32" data-linenumber="98">
|
658
676
|
<span class="hits">32</span>
|
659
677
|
|
660
678
|
<code class="ruby"> return Date.parse(param) if type == Date</code>
|
661
679
|
</li>
|
662
680
|
|
663
|
-
<li class="covered" data-hits="30" data-linenumber="
|
681
|
+
<li class="covered" data-hits="30" data-linenumber="99">
|
664
682
|
<span class="hits">30</span>
|
665
683
|
|
666
684
|
<code class="ruby"> return Time.parse(param) if type == Time</code>
|
667
685
|
</li>
|
668
686
|
|
669
|
-
<li class="covered" data-hits="28" data-linenumber="
|
687
|
+
<li class="covered" data-hits="28" data-linenumber="100">
|
670
688
|
<span class="hits">28</span>
|
671
689
|
|
672
690
|
<code class="ruby"> return DateTime.parse(param) if type == DateTime</code>
|
673
691
|
</li>
|
674
692
|
|
675
|
-
<li class="covered" data-hits="26" data-linenumber="
|
693
|
+
<li class="covered" data-hits="26" data-linenumber="101">
|
676
694
|
<span class="hits">26</span>
|
677
695
|
|
678
696
|
<code class="ruby"> return Array(param.split(options[:delimiter] || ",")) if type == Array</code>
|
679
697
|
</li>
|
680
698
|
|
681
|
-
<li class="covered" data-hits="25" data-linenumber="
|
699
|
+
<li class="covered" data-hits="25" data-linenumber="102">
|
682
700
|
<span class="hits">25</span>
|
683
701
|
|
684
702
|
<code class="ruby"> return Hash[param.split(options[:delimiter] || ",").map{|c| c.split(options[:separator] || ":")}] if type == Hash</code>
|
685
703
|
</li>
|
686
704
|
|
687
|
-
<li class="covered" data-hits="21" data-linenumber="
|
705
|
+
<li class="covered" data-hits="21" data-linenumber="103">
|
688
706
|
<span class="hits">21</span>
|
689
707
|
|
690
708
|
<code class="ruby"> return (/(false|f|no|n|0)$/i === param.to_s ? false : (/(true|t|yes|y|1)$/i === param.to_s ? true : nil)) if type == TrueClass || type == FalseClass || type == Boolean</code>
|
691
709
|
</li>
|
692
710
|
|
693
|
-
<li class="never" data-hits="" data-linenumber="
|
711
|
+
<li class="never" data-hits="" data-linenumber="104">
|
694
712
|
|
695
713
|
|
696
714
|
<code class="ruby"> return nil</code>
|
697
715
|
</li>
|
698
716
|
|
699
|
-
<li class="covered" data-hits="5" data-linenumber="
|
717
|
+
<li class="covered" data-hits="5" data-linenumber="105">
|
700
718
|
<span class="hits">5</span>
|
701
719
|
|
702
720
|
<code class="ruby"> rescue ArgumentError</code>
|
703
721
|
</li>
|
704
722
|
|
705
|
-
<li class="covered" data-hits="5" data-linenumber="
|
723
|
+
<li class="covered" data-hits="5" data-linenumber="106">
|
706
724
|
<span class="hits">5</span>
|
707
725
|
|
708
726
|
<code class="ruby"> raise InvalidParameterError, "'#{param}' is not a valid #{type}"</code>
|
709
727
|
</li>
|
710
728
|
|
711
|
-
<li class="never" data-hits="" data-linenumber="
|
729
|
+
<li class="never" data-hits="" data-linenumber="107">
|
712
730
|
|
713
731
|
|
714
732
|
<code class="ruby"> end</code>
|
715
733
|
</li>
|
716
734
|
|
717
|
-
<li class="never" data-hits="" data-linenumber="
|
735
|
+
<li class="never" data-hits="" data-linenumber="108">
|
718
736
|
|
719
737
|
|
720
738
|
<code class="ruby"> end</code>
|
721
739
|
</li>
|
722
740
|
|
723
|
-
<li class="never" data-hits="" data-linenumber="
|
741
|
+
<li class="never" data-hits="" data-linenumber="109">
|
724
742
|
|
725
743
|
|
726
744
|
<code class="ruby"></code>
|
727
745
|
</li>
|
728
746
|
|
729
|
-
<li class="covered" data-hits="1" data-linenumber="
|
747
|
+
<li class="covered" data-hits="1" data-linenumber="110">
|
730
748
|
<span class="hits">1</span>
|
731
749
|
|
732
750
|
<code class="ruby"> def validate!(param, options)</code>
|
733
751
|
</li>
|
734
752
|
|
735
|
-
<li class="covered" data-hits="
|
736
|
-
<span class="hits">
|
753
|
+
<li class="covered" data-hits="102" data-linenumber="111">
|
754
|
+
<span class="hits">102</span>
|
737
755
|
|
738
756
|
<code class="ruby"> options.each do |key, value|</code>
|
739
757
|
</li>
|
740
758
|
|
741
|
-
<li class="covered" data-hits="
|
742
|
-
<span class="hits">
|
759
|
+
<li class="covered" data-hits="52" data-linenumber="112">
|
760
|
+
<span class="hits">52</span>
|
743
761
|
|
744
762
|
<code class="ruby"> case key</code>
|
745
763
|
</li>
|
746
764
|
|
747
|
-
<li class="never" data-hits="" data-linenumber="
|
765
|
+
<li class="never" data-hits="" data-linenumber="113">
|
748
766
|
|
749
767
|
|
750
768
|
<code class="ruby"> when :required</code>
|
751
769
|
</li>
|
752
770
|
|
753
|
-
<li class="covered" data-hits="
|
754
|
-
<span class="hits">
|
771
|
+
<li class="covered" data-hits="7" data-linenumber="114">
|
772
|
+
<span class="hits">7</span>
|
755
773
|
|
756
774
|
<code class="ruby"> raise InvalidParameterError, "Parameter is required" if value && param.nil?</code>
|
757
775
|
</li>
|
758
776
|
|
759
|
-
<li class="never" data-hits="" data-linenumber="
|
777
|
+
<li class="never" data-hits="" data-linenumber="115">
|
760
778
|
|
761
779
|
|
762
780
|
<code class="ruby"> when :blank</code>
|
763
781
|
</li>
|
764
782
|
|
765
|
-
<li class="never" data-hits="" data-linenumber="
|
783
|
+
<li class="never" data-hits="" data-linenumber="116">
|
766
784
|
|
767
785
|
|
768
786
|
<code class="ruby"> raise InvalidParameterError, "Parameter cannot be blank" if !value && case param</code>
|
769
787
|
</li>
|
770
788
|
|
771
|
-
<li class="never" data-hits="" data-linenumber="
|
789
|
+
<li class="never" data-hits="" data-linenumber="117">
|
772
790
|
|
773
791
|
|
774
792
|
<code class="ruby"> when String</code>
|
775
793
|
</li>
|
776
794
|
|
777
|
-
<li class="covered" data-hits="1" data-linenumber="
|
795
|
+
<li class="covered" data-hits="1" data-linenumber="118">
|
778
796
|
<span class="hits">1</span>
|
779
797
|
|
780
798
|
<code class="ruby"> !(/\S/ === param)</code>
|
781
799
|
</li>
|
782
800
|
|
783
|
-
<li class="never" data-hits="" data-linenumber="
|
801
|
+
<li class="never" data-hits="" data-linenumber="119">
|
784
802
|
|
785
803
|
|
786
804
|
<code class="ruby"> when Array, Hash</code>
|
787
805
|
</li>
|
788
806
|
|
789
|
-
<li class="covered" data-hits="2" data-linenumber="
|
807
|
+
<li class="covered" data-hits="2" data-linenumber="120">
|
790
808
|
<span class="hits">2</span>
|
791
809
|
|
792
810
|
<code class="ruby"> param.empty?</code>
|
793
811
|
</li>
|
794
812
|
|
795
|
-
<li class="never" data-hits="" data-linenumber="
|
813
|
+
<li class="never" data-hits="" data-linenumber="121">
|
796
814
|
|
797
815
|
|
798
816
|
<code class="ruby"> else</code>
|
799
817
|
</li>
|
800
818
|
|
801
|
-
<li class="covered" data-hits="1" data-linenumber="
|
819
|
+
<li class="covered" data-hits="1" data-linenumber="122">
|
802
820
|
<span class="hits">1</span>
|
803
821
|
|
804
822
|
<code class="ruby"> param.nil?</code>
|
805
823
|
</li>
|
806
824
|
|
807
|
-
<li class="covered" data-hits="5" data-linenumber="
|
825
|
+
<li class="covered" data-hits="5" data-linenumber="123">
|
808
826
|
<span class="hits">5</span>
|
809
827
|
|
810
828
|
<code class="ruby"> end</code>
|
811
829
|
</li>
|
812
830
|
|
813
|
-
<li class="never" data-hits="" data-linenumber="
|
831
|
+
<li class="never" data-hits="" data-linenumber="124">
|
814
832
|
|
815
833
|
|
816
834
|
<code class="ruby"> when :format</code>
|
817
835
|
</li>
|
818
836
|
|
819
|
-
<li class="covered" data-hits="3" data-linenumber="
|
837
|
+
<li class="covered" data-hits="3" data-linenumber="125">
|
820
838
|
<span class="hits">3</span>
|
821
839
|
|
822
840
|
<code class="ruby"> raise InvalidParameterError, "Parameter must be a string if using the format validation" unless param.kind_of?(String)</code>
|
823
841
|
</li>
|
824
842
|
|
825
|
-
<li class="covered" data-hits="2" data-linenumber="
|
843
|
+
<li class="covered" data-hits="2" data-linenumber="126">
|
826
844
|
<span class="hits">2</span>
|
827
845
|
|
828
846
|
<code class="ruby"> raise InvalidParameterError, "Parameter must match format #{value}" unless param =~ value</code>
|
829
847
|
</li>
|
830
848
|
|
831
|
-
<li class="never" data-hits="" data-linenumber="
|
849
|
+
<li class="never" data-hits="" data-linenumber="127">
|
832
850
|
|
833
851
|
|
834
852
|
<code class="ruby"> when :is</code>
|
835
853
|
</li>
|
836
854
|
|
837
|
-
<li class="covered" data-hits="2" data-linenumber="
|
855
|
+
<li class="covered" data-hits="2" data-linenumber="128">
|
838
856
|
<span class="hits">2</span>
|
839
857
|
|
840
858
|
<code class="ruby"> raise InvalidParameterError, "Parameter must be #{value}" unless param === value</code>
|
841
859
|
</li>
|
842
860
|
|
843
|
-
<li class="never" data-hits="" data-linenumber="
|
861
|
+
<li class="never" data-hits="" data-linenumber="129">
|
844
862
|
|
845
863
|
|
846
864
|
<code class="ruby"> when :in, :within, :range</code>
|
847
865
|
</li>
|
848
866
|
|
849
|
-
<li class="never" data-hits="" data-linenumber="
|
867
|
+
<li class="never" data-hits="" data-linenumber="130">
|
850
868
|
|
851
869
|
|
852
870
|
<code class="ruby"> raise InvalidParameterError, "Parameter must be within #{value}" unless param.nil? || case value</code>
|
853
871
|
</li>
|
854
872
|
|
855
|
-
<li class="never" data-hits="" data-linenumber="
|
873
|
+
<li class="never" data-hits="" data-linenumber="131">
|
856
874
|
|
857
875
|
|
858
876
|
<code class="ruby"> when Range</code>
|
859
877
|
</li>
|
860
878
|
|
861
|
-
<li class="covered" data-hits="4" data-linenumber="
|
879
|
+
<li class="covered" data-hits="4" data-linenumber="132">
|
862
880
|
<span class="hits">4</span>
|
863
881
|
|
864
882
|
<code class="ruby"> value.include?(param)</code>
|
865
883
|
</li>
|
866
884
|
|
867
|
-
<li class="never" data-hits="" data-linenumber="
|
885
|
+
<li class="never" data-hits="" data-linenumber="133">
|
868
886
|
|
869
887
|
|
870
888
|
<code class="ruby"> else</code>
|
871
889
|
</li>
|
872
890
|
|
873
|
-
<li class="covered" data-hits="2" data-linenumber="
|
891
|
+
<li class="covered" data-hits="2" data-linenumber="134">
|
874
892
|
<span class="hits">2</span>
|
875
893
|
|
876
894
|
<code class="ruby"> Array(value).include?(param)</code>
|
877
895
|
</li>
|
878
896
|
|
879
|
-
<li class="covered" data-hits="
|
880
|
-
<span class="hits">
|
897
|
+
<li class="covered" data-hits="8" data-linenumber="135">
|
898
|
+
<span class="hits">8</span>
|
881
899
|
|
882
900
|
<code class="ruby"> end</code>
|
883
901
|
</li>
|
884
902
|
|
885
|
-
<li class="never" data-hits="" data-linenumber="
|
903
|
+
<li class="never" data-hits="" data-linenumber="136">
|
886
904
|
|
887
905
|
|
888
906
|
<code class="ruby"> when :min</code>
|
889
907
|
</li>
|
890
908
|
|
891
|
-
<li class="covered" data-hits="2" data-linenumber="
|
909
|
+
<li class="covered" data-hits="2" data-linenumber="137">
|
892
910
|
<span class="hits">2</span>
|
893
911
|
|
894
912
|
<code class="ruby"> raise InvalidParameterError, "Parameter cannot be less than #{value}" unless param.nil? || value <= param</code>
|
895
913
|
</li>
|
896
914
|
|
897
|
-
<li class="never" data-hits="" data-linenumber="
|
915
|
+
<li class="never" data-hits="" data-linenumber="138">
|
898
916
|
|
899
917
|
|
900
918
|
<code class="ruby"> when :max</code>
|
901
919
|
</li>
|
902
920
|
|
903
|
-
<li class="covered" data-hits="2" data-linenumber="
|
921
|
+
<li class="covered" data-hits="2" data-linenumber="139">
|
904
922
|
<span class="hits">2</span>
|
905
923
|
|
906
924
|
<code class="ruby"> raise InvalidParameterError, "Parameter cannot be greater than #{value}" unless param.nil? || value >= param</code>
|
907
925
|
</li>
|
908
926
|
|
909
|
-
<li class="never" data-hits="" data-linenumber="
|
927
|
+
<li class="never" data-hits="" data-linenumber="140">
|
910
928
|
|
911
929
|
|
912
930
|
<code class="ruby"> when :min_length</code>
|
913
931
|
</li>
|
914
932
|
|
915
|
-
<li class="covered" data-hits="1" data-linenumber="
|
933
|
+
<li class="covered" data-hits="1" data-linenumber="141">
|
916
934
|
<span class="hits">1</span>
|
917
935
|
|
918
936
|
<code class="ruby"> raise InvalidParameterError, "Parameter cannot have length less than #{value}" unless param.nil? || value <= param.length</code>
|
919
937
|
</li>
|
920
938
|
|
921
|
-
<li class="never" data-hits="" data-linenumber="
|
939
|
+
<li class="never" data-hits="" data-linenumber="142">
|
922
940
|
|
923
941
|
|
924
942
|
<code class="ruby"> when :max_length</code>
|
925
943
|
</li>
|
926
944
|
|
927
|
-
<li class="covered" data-hits="
|
928
|
-
<span class="hits">
|
945
|
+
<li class="covered" data-hits="4" data-linenumber="143">
|
946
|
+
<span class="hits">4</span>
|
929
947
|
|
930
948
|
<code class="ruby"> raise InvalidParameterError, "Parameter cannot have length greater than #{value}" unless param.nil? || value >= param.length</code>
|
931
949
|
</li>
|
932
950
|
|
933
|
-
<li class="never" data-hits="" data-linenumber="
|
951
|
+
<li class="never" data-hits="" data-linenumber="144">
|
934
952
|
|
935
953
|
|
936
954
|
<code class="ruby"> end</code>
|
937
955
|
</li>
|
938
956
|
|
939
|
-
<li class="never" data-hits="" data-linenumber="
|
957
|
+
<li class="never" data-hits="" data-linenumber="145">
|
940
958
|
|
941
959
|
|
942
960
|
<code class="ruby"> end</code>
|
943
961
|
</li>
|
944
962
|
|
945
|
-
<li class="never" data-hits="" data-linenumber="
|
963
|
+
<li class="never" data-hits="" data-linenumber="146">
|
946
964
|
|
947
965
|
|
948
966
|
<code class="ruby"> end</code>
|
949
967
|
</li>
|
950
968
|
|
951
|
-
<li class="never" data-hits="" data-linenumber="
|
969
|
+
<li class="never" data-hits="" data-linenumber="147">
|
952
970
|
|
953
971
|
|
954
972
|
<code class="ruby"></code>
|
955
973
|
</li>
|
956
974
|
|
957
|
-
<li class="covered" data-hits="1" data-linenumber="
|
975
|
+
<li class="covered" data-hits="1" data-linenumber="148">
|
958
976
|
<span class="hits">1</span>
|
959
977
|
|
960
978
|
<code class="ruby"> def validate_one_of!(params, names, options)</code>
|
961
979
|
</li>
|
962
980
|
|
963
|
-
<li class="covered" data-hits="47" data-linenumber="
|
981
|
+
<li class="covered" data-hits="47" data-linenumber="149">
|
964
982
|
<span class="hits">47</span>
|
965
983
|
|
966
984
|
<code class="ruby"> raise InvalidParameterError, "Only one of [#{names.join(', ')}] is allowed" if names.count{|name| present?(params[name])} > 1</code>
|
967
985
|
</li>
|
968
986
|
|
969
|
-
<li class="never" data-hits="" data-linenumber="
|
987
|
+
<li class="never" data-hits="" data-linenumber="150">
|
970
988
|
|
971
989
|
|
972
990
|
<code class="ruby"> end</code>
|
973
991
|
</li>
|
974
992
|
|
975
|
-
<li class="never" data-hits="" data-linenumber="
|
993
|
+
<li class="never" data-hits="" data-linenumber="151">
|
976
994
|
|
977
995
|
|
978
996
|
<code class="ruby"></code>
|
979
997
|
</li>
|
980
998
|
|
981
|
-
<li class="covered" data-hits="1" data-linenumber="
|
999
|
+
<li class="covered" data-hits="1" data-linenumber="152">
|
982
1000
|
<span class="hits">1</span>
|
983
1001
|
|
984
1002
|
<code class="ruby"> def validate_any_of!(params, names, options)</code>
|
985
1003
|
</li>
|
986
1004
|
|
987
|
-
<li class="covered" data-hits="32" data-linenumber="
|
1005
|
+
<li class="covered" data-hits="32" data-linenumber="153">
|
988
1006
|
<span class="hits">32</span>
|
989
1007
|
|
990
1008
|
<code class="ruby"> raise InvalidParameterError, "One of parameters [#{names.join(', ')}] is required" if names.count{|name| present?(params[name])} < 1</code>
|
991
1009
|
</li>
|
992
1010
|
|
993
|
-
<li class="never" data-hits="" data-linenumber="
|
1011
|
+
<li class="never" data-hits="" data-linenumber="154">
|
994
1012
|
|
995
1013
|
|
996
1014
|
<code class="ruby"> end</code>
|
997
1015
|
</li>
|
998
1016
|
|
999
|
-
<li class="never" data-hits="" data-linenumber="
|
1017
|
+
<li class="never" data-hits="" data-linenumber="155">
|
1000
1018
|
|
1001
1019
|
|
1002
1020
|
<code class="ruby"></code>
|
1003
1021
|
</li>
|
1004
1022
|
|
1005
|
-
<li class="never" data-hits="" data-linenumber="
|
1023
|
+
<li class="never" data-hits="" data-linenumber="156">
|
1006
1024
|
|
1007
1025
|
|
1008
1026
|
<code class="ruby"> # ActiveSupport #present? and #blank? without patching Object</code>
|
1009
1027
|
</li>
|
1010
1028
|
|
1011
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1029
|
+
<li class="covered" data-hits="1" data-linenumber="157">
|
1012
1030
|
<span class="hits">1</span>
|
1013
1031
|
|
1014
1032
|
<code class="ruby"> def present?(object)</code>
|
1015
1033
|
</li>
|
1016
1034
|
|
1017
|
-
<li class="covered" data-hits="58" data-linenumber="
|
1035
|
+
<li class="covered" data-hits="58" data-linenumber="158">
|
1018
1036
|
<span class="hits">58</span>
|
1019
1037
|
|
1020
1038
|
<code class="ruby"> !blank?(object)</code>
|
1021
1039
|
</li>
|
1022
1040
|
|
1023
|
-
<li class="never" data-hits="" data-linenumber="
|
1041
|
+
<li class="never" data-hits="" data-linenumber="159">
|
1024
1042
|
|
1025
1043
|
|
1026
1044
|
<code class="ruby"> end</code>
|
1027
1045
|
</li>
|
1028
1046
|
|
1029
|
-
<li class="never" data-hits="" data-linenumber="
|
1047
|
+
<li class="never" data-hits="" data-linenumber="160">
|
1030
1048
|
|
1031
1049
|
|
1032
1050
|
<code class="ruby"></code>
|
1033
1051
|
</li>
|
1034
1052
|
|
1035
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1053
|
+
<li class="covered" data-hits="1" data-linenumber="161">
|
1036
1054
|
<span class="hits">1</span>
|
1037
1055
|
|
1038
1056
|
<code class="ruby"> def blank?(object)</code>
|
1039
1057
|
</li>
|
1040
1058
|
|
1041
|
-
<li class="covered" data-hits="58" data-linenumber="
|
1059
|
+
<li class="covered" data-hits="58" data-linenumber="162">
|
1042
1060
|
<span class="hits">58</span>
|
1043
1061
|
|
1044
1062
|
<code class="ruby"> object.respond_to?(:empty?) ? object.empty? : !object</code>
|
1045
1063
|
</li>
|
1046
1064
|
|
1047
|
-
<li class="never" data-hits="" data-linenumber="
|
1065
|
+
<li class="never" data-hits="" data-linenumber="163">
|
1048
1066
|
|
1049
1067
|
|
1050
1068
|
<code class="ruby"> end</code>
|
1051
1069
|
</li>
|
1052
1070
|
|
1053
|
-
<li class="never" data-hits="" data-linenumber="
|
1071
|
+
<li class="never" data-hits="" data-linenumber="164">
|
1054
1072
|
|
1055
1073
|
|
1056
1074
|
<code class="ruby"> end</code>
|
1057
1075
|
</li>
|
1058
1076
|
|
1059
|
-
<li class="never" data-hits="" data-linenumber="
|
1077
|
+
<li class="never" data-hits="" data-linenumber="165">
|
1060
1078
|
|
1061
1079
|
|
1062
1080
|
<code class="ruby"></code>
|
1063
1081
|
</li>
|
1064
1082
|
|
1065
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1083
|
+
<li class="covered" data-hits="1" data-linenumber="166">
|
1066
1084
|
<span class="hits">1</span>
|
1067
1085
|
|
1068
1086
|
<code class="ruby"> helpers Param</code>
|
1069
1087
|
</li>
|
1070
1088
|
|
1071
|
-
<li class="never" data-hits="" data-linenumber="
|
1089
|
+
<li class="never" data-hits="" data-linenumber="167">
|
1072
1090
|
|
1073
1091
|
|
1074
1092
|
<code class="ruby">end</code>
|
@@ -1077,6 +1095,7 @@
|
|
1077
1095
|
</ol>
|
1078
1096
|
</pre>
|
1079
1097
|
</div>
|
1098
|
+
|
1080
1099
|
|
1081
1100
|
</div>
|
1082
1101
|
</div>
|