sinatra-param 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +23 -23
- data/coverage/index.html +156 -132
- data/example/Gemfile +1 -4
- data/example/Gemfile.lock +11 -14
- data/example/Procfile +1 -1
- data/lib/sinatra/param.rb +6 -2
- data/lib/sinatra/param/version.rb +1 -1
- data/spec/parameter_type_coercion_spec.rb +16 -2
- metadata +3 -44
- data/coverage/assets/0.7.1/application.css +0 -1110
- data/coverage/assets/0.7.1/application.js +0 -626
- data/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
- data/coverage/assets/0.7.1/favicon_green.png +0 -0
- data/coverage/assets/0.7.1/favicon_red.png +0 -0
- data/coverage/assets/0.7.1/favicon_yellow.png +0 -0
- data/coverage/assets/0.7.1/loading.gif +0 -0
- data/coverage/assets/0.7.1/magnify.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3af3685b1f1855e46f87a28523a0e754cb20c10ff250916ca68aca47597fa0be
|
4
|
+
data.tar.gz: 4ab5a98049fda855dadf4f3cf98d12fcb9207c3842464435710ae57c1bc8d69c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2afce8f10e13ff41d62f548a3ab59f2e67ef85e4ce6f87a3bc8dd8d867c4dc2a9b02ce2cff0ac142a5846e6e3a297d49cec602589bd4721df170961f86f694f3
|
7
|
+
data.tar.gz: 41d674d697e9fe487769a3f9b87e383d2359e74c1086a6a1aba2e4eac17d52c5eb3da6d8ae8e80db80e075a397ae64ffc015e374e6faa44694465c69181ab48e
|
data/Gemfile.lock
CHANGED
@@ -1,46 +1,46 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sinatra-param (1.
|
4
|
+
sinatra-param (1.6.0)
|
5
5
|
sinatra (>= 1.3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
diff-lcs (1.3)
|
11
|
-
docile (1.3.
|
12
|
-
json (2.
|
13
|
-
mustermann (1.0.
|
14
|
-
rack (2.0.
|
15
|
-
rack-protection (2.0.
|
11
|
+
docile (1.3.1)
|
12
|
+
json (2.2.0)
|
13
|
+
mustermann (1.0.3)
|
14
|
+
rack (2.0.6)
|
15
|
+
rack-protection (2.0.5)
|
16
16
|
rack
|
17
|
-
rack-test (
|
17
|
+
rack-test (1.1.0)
|
18
18
|
rack (>= 1.0, < 3)
|
19
|
-
rake (12.3.
|
20
|
-
rspec (3.
|
21
|
-
rspec-core (~> 3.
|
22
|
-
rspec-expectations (~> 3.
|
23
|
-
rspec-mocks (~> 3.
|
24
|
-
rspec-core (3.
|
25
|
-
rspec-support (~> 3.
|
26
|
-
rspec-expectations (3.
|
19
|
+
rake (12.3.2)
|
20
|
+
rspec (3.8.0)
|
21
|
+
rspec-core (~> 3.8.0)
|
22
|
+
rspec-expectations (~> 3.8.0)
|
23
|
+
rspec-mocks (~> 3.8.0)
|
24
|
+
rspec-core (3.8.0)
|
25
|
+
rspec-support (~> 3.8.0)
|
26
|
+
rspec-expectations (3.8.2)
|
27
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
-
rspec-support (~> 3.
|
29
|
-
rspec-mocks (3.
|
28
|
+
rspec-support (~> 3.8.0)
|
29
|
+
rspec-mocks (3.8.0)
|
30
30
|
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.
|
32
|
-
rspec-support (3.
|
31
|
+
rspec-support (~> 3.8.0)
|
32
|
+
rspec-support (3.8.0)
|
33
33
|
simplecov (0.16.1)
|
34
34
|
docile (~> 1.1)
|
35
35
|
json (>= 1.8, < 3)
|
36
36
|
simplecov-html (~> 0.10.0)
|
37
37
|
simplecov-html (0.10.2)
|
38
|
-
sinatra (2.0.
|
38
|
+
sinatra (2.0.5)
|
39
39
|
mustermann (~> 1.0)
|
40
40
|
rack (~> 2.0)
|
41
|
-
rack-protection (= 2.0.
|
41
|
+
rack-protection (= 2.0.5)
|
42
42
|
tilt (~> 2.0)
|
43
|
-
tilt (2.0.
|
43
|
+
tilt (2.0.9)
|
44
44
|
|
45
45
|
PLATFORMS
|
46
46
|
ruby
|
@@ -53,4 +53,4 @@ DEPENDENCIES
|
|
53
53
|
sinatra-param!
|
54
54
|
|
55
55
|
BUNDLED WITH
|
56
|
-
|
56
|
+
2.0.1
|
data/coverage/index.html
CHANGED
@@ -14,7 +14,7 @@
|
|
14
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="2019-03-15T15:07:53-07:00">2019-03-15T15:07:53-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
|
+
21.6
|
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>97</b> relevant lines.
|
36
|
+
<span class="green"><b>97</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">
|
@@ -51,13 +51,13 @@
|
|
51
51
|
<tbody>
|
52
52
|
|
53
53
|
<tr>
|
54
|
-
<td class="strong"><a href="#
|
54
|
+
<td class="strong"><a href="#5ab8a44675913f98c46680d991d2ce5426d11710" 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>171</td>
|
57
|
+
<td>97</td>
|
58
|
+
<td>97</td>
|
59
59
|
<td>0</td>
|
60
|
-
<td>
|
60
|
+
<td>21.6</td>
|
61
61
|
</tr>
|
62
62
|
|
63
63
|
</tbody>
|
@@ -76,13 +76,13 @@
|
|
76
76
|
|
77
77
|
<div class="source_files">
|
78
78
|
|
79
|
-
<div class="source_table" id="
|
79
|
+
<div class="source_table" id="5ab8a44675913f98c46680d991d2ce5426d11710">
|
80
80
|
<div class="header">
|
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>97</b> relevant lines.
|
85
|
+
<span class="green"><b>97</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="154" data-linenumber="15">
|
178
|
+
<span class="hits">154</span>
|
179
179
|
|
180
180
|
<code class="ruby"> name = name.to_s</code>
|
181
181
|
</li>
|
@@ -186,8 +186,8 @@
|
|
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="154" data-linenumber="17">
|
190
|
+
<span class="hits">154</span>
|
191
191
|
|
192
192
|
<code class="ruby"> return unless params.member?(name) or options.has_key?(:default) or options[:required]</code>
|
193
193
|
</li>
|
@@ -198,14 +198,14 @@
|
|
198
198
|
<code class="ruby"></code>
|
199
199
|
</li>
|
200
200
|
|
201
|
-
<li class="
|
202
|
-
|
201
|
+
<li class="never" data-hits="" data-linenumber="19">
|
202
|
+
|
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="109" data-linenumber="20">
|
208
|
+
<span class="hits">109</span>
|
209
209
|
|
210
210
|
<code class="ruby"> params[name] = coerce(params[name], type, options)</code>
|
211
211
|
</li>
|
@@ -234,14 +234,14 @@
|
|
234
234
|
<code class="ruby"> params[name]</code>
|
235
235
|
</li>
|
236
236
|
|
237
|
-
<li class="covered" data-hits="
|
238
|
-
<span class="hits">
|
237
|
+
<li class="covered" data-hits="27" data-linenumber="25">
|
238
|
+
<span class="hits">27</span>
|
239
239
|
|
240
240
|
<code class="ruby"> rescue InvalidParameterError => exception</code>
|
241
241
|
</li>
|
242
242
|
|
243
|
-
<li class="covered" data-hits="
|
244
|
-
<span class="hits">
|
243
|
+
<li class="covered" data-hits="27" data-linenumber="26">
|
244
|
+
<span class="hits">27</span>
|
245
245
|
|
246
246
|
<code class="ruby"> if options[:raise] or (settings.raise_sinatra_param_exceptions rescue false)</code>
|
247
247
|
</li>
|
@@ -270,8 +270,8 @@
|
|
270
270
|
<code class="ruby"></code>
|
271
271
|
</li>
|
272
272
|
|
273
|
-
<li class="covered" data-hits="
|
274
|
-
<span class="hits">
|
273
|
+
<li class="covered" data-hits="26" data-linenumber="31">
|
274
|
+
<span class="hits">26</span>
|
275
275
|
|
276
276
|
<code class="ruby"> error = options[:message] || exception.to_s</code>
|
277
277
|
</li>
|
@@ -282,14 +282,14 @@
|
|
282
282
|
<code class="ruby"></code>
|
283
283
|
</li>
|
284
284
|
|
285
|
-
<li class="covered" data-hits="
|
286
|
-
<span class="hits">
|
285
|
+
<li class="covered" data-hits="26" data-linenumber="33">
|
286
|
+
<span class="hits">26</span>
|
287
287
|
|
288
288
|
<code class="ruby"> if content_type and content_type.match(mime_type(:json))</code>
|
289
289
|
</li>
|
290
290
|
|
291
|
-
<li class="covered" data-hits="
|
292
|
-
<span class="hits">
|
291
|
+
<li class="covered" data-hits="25" data-linenumber="34">
|
292
|
+
<span class="hits">25</span>
|
293
293
|
|
294
294
|
<code class="ruby"> error = {message: error, errors: {name => exception.message}}.to_json</code>
|
295
295
|
</li>
|
@@ -318,8 +318,8 @@
|
|
318
318
|
<code class="ruby"></code>
|
319
319
|
</li>
|
320
320
|
|
321
|
-
<li class="covered" data-hits="
|
322
|
-
<span class="hits">
|
321
|
+
<li class="covered" data-hits="26" data-linenumber="39">
|
322
|
+
<span class="hits">26</span>
|
323
323
|
|
324
324
|
<code class="ruby"> halt 400, error</code>
|
325
325
|
</li>
|
@@ -378,8 +378,8 @@
|
|
378
378
|
<code class="ruby"></code>
|
379
379
|
</li>
|
380
380
|
|
381
|
-
<li class="
|
382
|
-
|
381
|
+
<li class="never" data-hits="" data-linenumber="49">
|
382
|
+
|
383
383
|
|
384
384
|
<code class="ruby"> begin</code>
|
385
385
|
</li>
|
@@ -516,8 +516,8 @@
|
|
516
516
|
<code class="ruby"></code>
|
517
517
|
</li>
|
518
518
|
|
519
|
-
<li class="
|
520
|
-
|
519
|
+
<li class="never" data-hits="" data-linenumber="72">
|
520
|
+
|
521
521
|
|
522
522
|
<code class="ruby"> begin</code>
|
523
523
|
</li>
|
@@ -636,457 +636,481 @@
|
|
636
636
|
<code class="ruby"> def coerce(param, type, options = {})</code>
|
637
637
|
</li>
|
638
638
|
|
639
|
-
<li class="
|
640
|
-
|
639
|
+
<li class="never" data-hits="" data-linenumber="92">
|
640
|
+
|
641
641
|
|
642
642
|
<code class="ruby"> begin</code>
|
643
643
|
</li>
|
644
644
|
|
645
|
-
<li class="covered" data-hits="
|
646
|
-
<span class="hits">
|
645
|
+
<li class="covered" data-hits="109" data-linenumber="93">
|
646
|
+
<span class="hits">109</span>
|
647
647
|
|
648
648
|
<code class="ruby"> return nil if param.nil?</code>
|
649
649
|
</li>
|
650
650
|
|
651
|
-
<li class="covered" data-hits="
|
652
|
-
<span class="hits">
|
651
|
+
<li class="covered" data-hits="98" data-linenumber="94">
|
652
|
+
<span class="hits">98</span>
|
653
653
|
|
654
654
|
<code class="ruby"> return param if (param.is_a?(type) rescue false)</code>
|
655
655
|
</li>
|
656
656
|
|
657
|
-
<li class="covered" data-hits="
|
658
|
-
<span class="hits">
|
657
|
+
<li class="covered" data-hits="48" data-linenumber="95">
|
658
|
+
<span class="hits">48</span>
|
659
659
|
|
660
|
-
<code class="ruby"> return Integer(param) if type == Integer</code>
|
660
|
+
<code class="ruby"> return Integer(param, 10) if type == Integer</code>
|
661
661
|
</li>
|
662
662
|
|
663
|
-
<li class="covered" data-hits="
|
664
|
-
<span class="hits">
|
663
|
+
<li class="covered" data-hits="37" data-linenumber="96">
|
664
|
+
<span class="hits">37</span>
|
665
665
|
|
666
666
|
<code class="ruby"> return Float(param) if type == Float</code>
|
667
667
|
</li>
|
668
668
|
|
669
|
-
<li class="covered" data-hits="
|
670
|
-
<span class="hits">
|
669
|
+
<li class="covered" data-hits="35" data-linenumber="97">
|
670
|
+
<span class="hits">35</span>
|
671
671
|
|
672
672
|
<code class="ruby"> return String(param) if type == String</code>
|
673
673
|
</li>
|
674
674
|
|
675
|
-
<li class="covered" data-hits="
|
676
|
-
<span class="hits">
|
675
|
+
<li class="covered" data-hits="34" data-linenumber="98">
|
676
|
+
<span class="hits">34</span>
|
677
677
|
|
678
678
|
<code class="ruby"> return Date.parse(param) if type == Date</code>
|
679
679
|
</li>
|
680
680
|
|
681
|
-
<li class="covered" data-hits="
|
682
|
-
<span class="hits">
|
681
|
+
<li class="covered" data-hits="32" data-linenumber="99">
|
682
|
+
<span class="hits">32</span>
|
683
683
|
|
684
684
|
<code class="ruby"> return Time.parse(param) if type == Time</code>
|
685
685
|
</li>
|
686
686
|
|
687
|
-
<li class="covered" data-hits="
|
688
|
-
<span class="hits">
|
687
|
+
<li class="covered" data-hits="30" data-linenumber="100">
|
688
|
+
<span class="hits">30</span>
|
689
689
|
|
690
690
|
<code class="ruby"> return DateTime.parse(param) if type == DateTime</code>
|
691
691
|
</li>
|
692
692
|
|
693
|
-
<li class="covered" data-hits="
|
694
|
-
<span class="hits">
|
693
|
+
<li class="covered" data-hits="28" data-linenumber="101">
|
694
|
+
<span class="hits">28</span>
|
695
695
|
|
696
696
|
<code class="ruby"> return Array(param.split(options[:delimiter] || ",")) if type == Array</code>
|
697
697
|
</li>
|
698
698
|
|
699
|
-
<li class="covered" data-hits="
|
700
|
-
<span class="hits">
|
699
|
+
<li class="covered" data-hits="27" data-linenumber="102">
|
700
|
+
<span class="hits">27</span>
|
701
701
|
|
702
702
|
<code class="ruby"> return Hash[param.split(options[:delimiter] || ",").map{|c| c.split(options[:separator] || ":")}] if type == Hash</code>
|
703
703
|
</li>
|
704
704
|
|
705
|
-
<li class="covered" data-hits="
|
706
|
-
<span class="hits">
|
705
|
+
<li class="covered" data-hits="23" data-linenumber="103">
|
706
|
+
<span class="hits">23</span>
|
707
707
|
|
708
|
-
<code class="ruby">
|
708
|
+
<code class="ruby"> if [TrueClass, FalseClass, Boolean].include? type</code>
|
709
709
|
</li>
|
710
710
|
|
711
|
-
<li class="
|
711
|
+
<li class="covered" data-hits="22" data-linenumber="104">
|
712
|
+
<span class="hits">22</span>
|
713
|
+
|
714
|
+
<code class="ruby"> coerced = /^(false|f|no|n|0)$/i === param.to_s ? false : /^(true|t|yes|y|1)$/i === param.to_s ? true : nil</code>
|
715
|
+
</li>
|
716
|
+
|
717
|
+
<li class="covered" data-hits="22" data-linenumber="105">
|
718
|
+
<span class="hits">22</span>
|
719
|
+
|
720
|
+
<code class="ruby"> raise ArgumentError if coerced.nil?</code>
|
721
|
+
</li>
|
722
|
+
|
723
|
+
<li class="covered" data-hits="20" data-linenumber="106">
|
724
|
+
<span class="hits">20</span>
|
725
|
+
|
726
|
+
<code class="ruby"> return coerced</code>
|
727
|
+
</li>
|
728
|
+
|
729
|
+
<li class="never" data-hits="" data-linenumber="107">
|
730
|
+
|
731
|
+
|
732
|
+
<code class="ruby"> end</code>
|
733
|
+
</li>
|
734
|
+
|
735
|
+
<li class="never" data-hits="" data-linenumber="108">
|
712
736
|
|
713
737
|
|
714
738
|
<code class="ruby"> return nil</code>
|
715
739
|
</li>
|
716
740
|
|
717
|
-
<li class="covered" data-hits="
|
718
|
-
<span class="hits">
|
741
|
+
<li class="covered" data-hits="7" data-linenumber="109">
|
742
|
+
<span class="hits">7</span>
|
719
743
|
|
720
744
|
<code class="ruby"> rescue ArgumentError</code>
|
721
745
|
</li>
|
722
746
|
|
723
|
-
<li class="covered" data-hits="
|
724
|
-
<span class="hits">
|
747
|
+
<li class="covered" data-hits="7" data-linenumber="110">
|
748
|
+
<span class="hits">7</span>
|
725
749
|
|
726
750
|
<code class="ruby"> raise InvalidParameterError, "'#{param}' is not a valid #{type}"</code>
|
727
751
|
</li>
|
728
752
|
|
729
|
-
<li class="never" data-hits="" data-linenumber="
|
753
|
+
<li class="never" data-hits="" data-linenumber="111">
|
730
754
|
|
731
755
|
|
732
756
|
<code class="ruby"> end</code>
|
733
757
|
</li>
|
734
758
|
|
735
|
-
<li class="never" data-hits="" data-linenumber="
|
759
|
+
<li class="never" data-hits="" data-linenumber="112">
|
736
760
|
|
737
761
|
|
738
762
|
<code class="ruby"> end</code>
|
739
763
|
</li>
|
740
764
|
|
741
|
-
<li class="never" data-hits="" data-linenumber="
|
765
|
+
<li class="never" data-hits="" data-linenumber="113">
|
742
766
|
|
743
767
|
|
744
768
|
<code class="ruby"></code>
|
745
769
|
</li>
|
746
770
|
|
747
|
-
<li class="covered" data-hits="1" data-linenumber="
|
771
|
+
<li class="covered" data-hits="1" data-linenumber="114">
|
748
772
|
<span class="hits">1</span>
|
749
773
|
|
750
774
|
<code class="ruby"> def validate!(param, options)</code>
|
751
775
|
</li>
|
752
776
|
|
753
|
-
<li class="covered" data-hits="102" data-linenumber="
|
777
|
+
<li class="covered" data-hits="102" data-linenumber="115">
|
754
778
|
<span class="hits">102</span>
|
755
779
|
|
756
780
|
<code class="ruby"> options.each do |key, value|</code>
|
757
781
|
</li>
|
758
782
|
|
759
|
-
<li class="covered" data-hits="52" data-linenumber="
|
783
|
+
<li class="covered" data-hits="52" data-linenumber="116">
|
760
784
|
<span class="hits">52</span>
|
761
785
|
|
762
786
|
<code class="ruby"> case key</code>
|
763
787
|
</li>
|
764
788
|
|
765
|
-
<li class="never" data-hits="" data-linenumber="
|
789
|
+
<li class="never" data-hits="" data-linenumber="117">
|
766
790
|
|
767
791
|
|
768
792
|
<code class="ruby"> when :required</code>
|
769
793
|
</li>
|
770
794
|
|
771
|
-
<li class="covered" data-hits="7" data-linenumber="
|
795
|
+
<li class="covered" data-hits="7" data-linenumber="118">
|
772
796
|
<span class="hits">7</span>
|
773
797
|
|
774
798
|
<code class="ruby"> raise InvalidParameterError, "Parameter is required" if value && param.nil?</code>
|
775
799
|
</li>
|
776
800
|
|
777
|
-
<li class="never" data-hits="" data-linenumber="
|
801
|
+
<li class="never" data-hits="" data-linenumber="119">
|
778
802
|
|
779
803
|
|
780
804
|
<code class="ruby"> when :blank</code>
|
781
805
|
</li>
|
782
806
|
|
783
|
-
<li class="
|
784
|
-
|
807
|
+
<li class="covered" data-hits="5" data-linenumber="120">
|
808
|
+
<span class="hits">5</span>
|
785
809
|
|
786
810
|
<code class="ruby"> raise InvalidParameterError, "Parameter cannot be blank" if !value && case param</code>
|
787
811
|
</li>
|
788
812
|
|
789
|
-
<li class="never" data-hits="" data-linenumber="
|
813
|
+
<li class="never" data-hits="" data-linenumber="121">
|
790
814
|
|
791
815
|
|
792
816
|
<code class="ruby"> when String</code>
|
793
817
|
</li>
|
794
818
|
|
795
|
-
<li class="covered" data-hits="1" data-linenumber="
|
819
|
+
<li class="covered" data-hits="1" data-linenumber="122">
|
796
820
|
<span class="hits">1</span>
|
797
821
|
|
798
822
|
<code class="ruby"> !(/\S/ === param)</code>
|
799
823
|
</li>
|
800
824
|
|
801
|
-
<li class="never" data-hits="" data-linenumber="
|
825
|
+
<li class="never" data-hits="" data-linenumber="123">
|
802
826
|
|
803
827
|
|
804
828
|
<code class="ruby"> when Array, Hash</code>
|
805
829
|
</li>
|
806
830
|
|
807
|
-
<li class="covered" data-hits="2" data-linenumber="
|
831
|
+
<li class="covered" data-hits="2" data-linenumber="124">
|
808
832
|
<span class="hits">2</span>
|
809
833
|
|
810
834
|
<code class="ruby"> param.empty?</code>
|
811
835
|
</li>
|
812
836
|
|
813
|
-
<li class="never" data-hits="" data-linenumber="
|
837
|
+
<li class="never" data-hits="" data-linenumber="125">
|
814
838
|
|
815
839
|
|
816
840
|
<code class="ruby"> else</code>
|
817
841
|
</li>
|
818
842
|
|
819
|
-
<li class="covered" data-hits="1" data-linenumber="
|
843
|
+
<li class="covered" data-hits="1" data-linenumber="126">
|
820
844
|
<span class="hits">1</span>
|
821
845
|
|
822
846
|
<code class="ruby"> param.nil?</code>
|
823
847
|
</li>
|
824
848
|
|
825
|
-
<li class="
|
826
|
-
|
849
|
+
<li class="never" data-hits="" data-linenumber="127">
|
850
|
+
|
827
851
|
|
828
852
|
<code class="ruby"> end</code>
|
829
853
|
</li>
|
830
854
|
|
831
|
-
<li class="never" data-hits="" data-linenumber="
|
855
|
+
<li class="never" data-hits="" data-linenumber="128">
|
832
856
|
|
833
857
|
|
834
858
|
<code class="ruby"> when :format</code>
|
835
859
|
</li>
|
836
860
|
|
837
|
-
<li class="covered" data-hits="3" data-linenumber="
|
861
|
+
<li class="covered" data-hits="3" data-linenumber="129">
|
838
862
|
<span class="hits">3</span>
|
839
863
|
|
840
864
|
<code class="ruby"> raise InvalidParameterError, "Parameter must be a string if using the format validation" unless param.kind_of?(String)</code>
|
841
865
|
</li>
|
842
866
|
|
843
|
-
<li class="covered" data-hits="2" data-linenumber="
|
867
|
+
<li class="covered" data-hits="2" data-linenumber="130">
|
844
868
|
<span class="hits">2</span>
|
845
869
|
|
846
870
|
<code class="ruby"> raise InvalidParameterError, "Parameter must match format #{value}" unless param =~ value</code>
|
847
871
|
</li>
|
848
872
|
|
849
|
-
<li class="never" data-hits="" data-linenumber="
|
873
|
+
<li class="never" data-hits="" data-linenumber="131">
|
850
874
|
|
851
875
|
|
852
876
|
<code class="ruby"> when :is</code>
|
853
877
|
</li>
|
854
878
|
|
855
|
-
<li class="covered" data-hits="2" data-linenumber="
|
879
|
+
<li class="covered" data-hits="2" data-linenumber="132">
|
856
880
|
<span class="hits">2</span>
|
857
881
|
|
858
882
|
<code class="ruby"> raise InvalidParameterError, "Parameter must be #{value}" unless param === value</code>
|
859
883
|
</li>
|
860
884
|
|
861
|
-
<li class="never" data-hits="" data-linenumber="
|
885
|
+
<li class="never" data-hits="" data-linenumber="133">
|
862
886
|
|
863
887
|
|
864
888
|
<code class="ruby"> when :in, :within, :range</code>
|
865
889
|
</li>
|
866
890
|
|
867
|
-
<li class="
|
868
|
-
|
891
|
+
<li class="covered" data-hits="8" data-linenumber="134">
|
892
|
+
<span class="hits">8</span>
|
869
893
|
|
870
894
|
<code class="ruby"> raise InvalidParameterError, "Parameter must be within #{value}" unless param.nil? || case value</code>
|
871
895
|
</li>
|
872
896
|
|
873
|
-
<li class="never" data-hits="" data-linenumber="
|
897
|
+
<li class="never" data-hits="" data-linenumber="135">
|
874
898
|
|
875
899
|
|
876
900
|
<code class="ruby"> when Range</code>
|
877
901
|
</li>
|
878
902
|
|
879
|
-
<li class="covered" data-hits="4" data-linenumber="
|
903
|
+
<li class="covered" data-hits="4" data-linenumber="136">
|
880
904
|
<span class="hits">4</span>
|
881
905
|
|
882
906
|
<code class="ruby"> value.include?(param)</code>
|
883
907
|
</li>
|
884
908
|
|
885
|
-
<li class="never" data-hits="" data-linenumber="
|
909
|
+
<li class="never" data-hits="" data-linenumber="137">
|
886
910
|
|
887
911
|
|
888
912
|
<code class="ruby"> else</code>
|
889
913
|
</li>
|
890
914
|
|
891
|
-
<li class="covered" data-hits="2" data-linenumber="
|
915
|
+
<li class="covered" data-hits="2" data-linenumber="138">
|
892
916
|
<span class="hits">2</span>
|
893
917
|
|
894
918
|
<code class="ruby"> Array(value).include?(param)</code>
|
895
919
|
</li>
|
896
920
|
|
897
|
-
<li class="
|
898
|
-
|
921
|
+
<li class="never" data-hits="" data-linenumber="139">
|
922
|
+
|
899
923
|
|
900
924
|
<code class="ruby"> end</code>
|
901
925
|
</li>
|
902
926
|
|
903
|
-
<li class="never" data-hits="" data-linenumber="
|
927
|
+
<li class="never" data-hits="" data-linenumber="140">
|
904
928
|
|
905
929
|
|
906
930
|
<code class="ruby"> when :min</code>
|
907
931
|
</li>
|
908
932
|
|
909
|
-
<li class="covered" data-hits="2" data-linenumber="
|
933
|
+
<li class="covered" data-hits="2" data-linenumber="141">
|
910
934
|
<span class="hits">2</span>
|
911
935
|
|
912
936
|
<code class="ruby"> raise InvalidParameterError, "Parameter cannot be less than #{value}" unless param.nil? || value <= param</code>
|
913
937
|
</li>
|
914
938
|
|
915
|
-
<li class="never" data-hits="" data-linenumber="
|
939
|
+
<li class="never" data-hits="" data-linenumber="142">
|
916
940
|
|
917
941
|
|
918
942
|
<code class="ruby"> when :max</code>
|
919
943
|
</li>
|
920
944
|
|
921
|
-
<li class="covered" data-hits="2" data-linenumber="
|
945
|
+
<li class="covered" data-hits="2" data-linenumber="143">
|
922
946
|
<span class="hits">2</span>
|
923
947
|
|
924
948
|
<code class="ruby"> raise InvalidParameterError, "Parameter cannot be greater than #{value}" unless param.nil? || value >= param</code>
|
925
949
|
</li>
|
926
950
|
|
927
|
-
<li class="never" data-hits="" data-linenumber="
|
951
|
+
<li class="never" data-hits="" data-linenumber="144">
|
928
952
|
|
929
953
|
|
930
954
|
<code class="ruby"> when :min_length</code>
|
931
955
|
</li>
|
932
956
|
|
933
|
-
<li class="covered" data-hits="1" data-linenumber="
|
957
|
+
<li class="covered" data-hits="1" data-linenumber="145">
|
934
958
|
<span class="hits">1</span>
|
935
959
|
|
936
960
|
<code class="ruby"> raise InvalidParameterError, "Parameter cannot have length less than #{value}" unless param.nil? || value <= param.length</code>
|
937
961
|
</li>
|
938
962
|
|
939
|
-
<li class="never" data-hits="" data-linenumber="
|
963
|
+
<li class="never" data-hits="" data-linenumber="146">
|
940
964
|
|
941
965
|
|
942
966
|
<code class="ruby"> when :max_length</code>
|
943
967
|
</li>
|
944
968
|
|
945
|
-
<li class="covered" data-hits="4" data-linenumber="
|
969
|
+
<li class="covered" data-hits="4" data-linenumber="147">
|
946
970
|
<span class="hits">4</span>
|
947
971
|
|
948
972
|
<code class="ruby"> raise InvalidParameterError, "Parameter cannot have length greater than #{value}" unless param.nil? || value >= param.length</code>
|
949
973
|
</li>
|
950
974
|
|
951
|
-
<li class="never" data-hits="" data-linenumber="
|
975
|
+
<li class="never" data-hits="" data-linenumber="148">
|
952
976
|
|
953
977
|
|
954
978
|
<code class="ruby"> end</code>
|
955
979
|
</li>
|
956
980
|
|
957
|
-
<li class="never" data-hits="" data-linenumber="
|
981
|
+
<li class="never" data-hits="" data-linenumber="149">
|
958
982
|
|
959
983
|
|
960
984
|
<code class="ruby"> end</code>
|
961
985
|
</li>
|
962
986
|
|
963
|
-
<li class="never" data-hits="" data-linenumber="
|
987
|
+
<li class="never" data-hits="" data-linenumber="150">
|
964
988
|
|
965
989
|
|
966
990
|
<code class="ruby"> end</code>
|
967
991
|
</li>
|
968
992
|
|
969
|
-
<li class="never" data-hits="" data-linenumber="
|
993
|
+
<li class="never" data-hits="" data-linenumber="151">
|
970
994
|
|
971
995
|
|
972
996
|
<code class="ruby"></code>
|
973
997
|
</li>
|
974
998
|
|
975
|
-
<li class="covered" data-hits="1" data-linenumber="
|
999
|
+
<li class="covered" data-hits="1" data-linenumber="152">
|
976
1000
|
<span class="hits">1</span>
|
977
1001
|
|
978
1002
|
<code class="ruby"> def validate_one_of!(params, names, options)</code>
|
979
1003
|
</li>
|
980
1004
|
|
981
|
-
<li class="covered" data-hits="47" data-linenumber="
|
1005
|
+
<li class="covered" data-hits="47" data-linenumber="153">
|
982
1006
|
<span class="hits">47</span>
|
983
1007
|
|
984
1008
|
<code class="ruby"> raise InvalidParameterError, "Only one of [#{names.join(', ')}] is allowed" if names.count{|name| present?(params[name])} > 1</code>
|
985
1009
|
</li>
|
986
1010
|
|
987
|
-
<li class="never" data-hits="" data-linenumber="
|
1011
|
+
<li class="never" data-hits="" data-linenumber="154">
|
988
1012
|
|
989
1013
|
|
990
1014
|
<code class="ruby"> end</code>
|
991
1015
|
</li>
|
992
1016
|
|
993
|
-
<li class="never" data-hits="" data-linenumber="
|
1017
|
+
<li class="never" data-hits="" data-linenumber="155">
|
994
1018
|
|
995
1019
|
|
996
1020
|
<code class="ruby"></code>
|
997
1021
|
</li>
|
998
1022
|
|
999
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1023
|
+
<li class="covered" data-hits="1" data-linenumber="156">
|
1000
1024
|
<span class="hits">1</span>
|
1001
1025
|
|
1002
1026
|
<code class="ruby"> def validate_any_of!(params, names, options)</code>
|
1003
1027
|
</li>
|
1004
1028
|
|
1005
|
-
<li class="covered" data-hits="32" data-linenumber="
|
1029
|
+
<li class="covered" data-hits="32" data-linenumber="157">
|
1006
1030
|
<span class="hits">32</span>
|
1007
1031
|
|
1008
1032
|
<code class="ruby"> raise InvalidParameterError, "One of parameters [#{names.join(', ')}] is required" if names.count{|name| present?(params[name])} < 1</code>
|
1009
1033
|
</li>
|
1010
1034
|
|
1011
|
-
<li class="never" data-hits="" data-linenumber="
|
1035
|
+
<li class="never" data-hits="" data-linenumber="158">
|
1012
1036
|
|
1013
1037
|
|
1014
1038
|
<code class="ruby"> end</code>
|
1015
1039
|
</li>
|
1016
1040
|
|
1017
|
-
<li class="never" data-hits="" data-linenumber="
|
1041
|
+
<li class="never" data-hits="" data-linenumber="159">
|
1018
1042
|
|
1019
1043
|
|
1020
1044
|
<code class="ruby"></code>
|
1021
1045
|
</li>
|
1022
1046
|
|
1023
|
-
<li class="never" data-hits="" data-linenumber="
|
1047
|
+
<li class="never" data-hits="" data-linenumber="160">
|
1024
1048
|
|
1025
1049
|
|
1026
1050
|
<code class="ruby"> # ActiveSupport #present? and #blank? without patching Object</code>
|
1027
1051
|
</li>
|
1028
1052
|
|
1029
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1053
|
+
<li class="covered" data-hits="1" data-linenumber="161">
|
1030
1054
|
<span class="hits">1</span>
|
1031
1055
|
|
1032
1056
|
<code class="ruby"> def present?(object)</code>
|
1033
1057
|
</li>
|
1034
1058
|
|
1035
|
-
<li class="covered" data-hits="58" data-linenumber="
|
1059
|
+
<li class="covered" data-hits="58" data-linenumber="162">
|
1036
1060
|
<span class="hits">58</span>
|
1037
1061
|
|
1038
1062
|
<code class="ruby"> !blank?(object)</code>
|
1039
1063
|
</li>
|
1040
1064
|
|
1041
|
-
<li class="never" data-hits="" data-linenumber="
|
1065
|
+
<li class="never" data-hits="" data-linenumber="163">
|
1042
1066
|
|
1043
1067
|
|
1044
1068
|
<code class="ruby"> end</code>
|
1045
1069
|
</li>
|
1046
1070
|
|
1047
|
-
<li class="never" data-hits="" data-linenumber="
|
1071
|
+
<li class="never" data-hits="" data-linenumber="164">
|
1048
1072
|
|
1049
1073
|
|
1050
1074
|
<code class="ruby"></code>
|
1051
1075
|
</li>
|
1052
1076
|
|
1053
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1077
|
+
<li class="covered" data-hits="1" data-linenumber="165">
|
1054
1078
|
<span class="hits">1</span>
|
1055
1079
|
|
1056
1080
|
<code class="ruby"> def blank?(object)</code>
|
1057
1081
|
</li>
|
1058
1082
|
|
1059
|
-
<li class="covered" data-hits="58" data-linenumber="
|
1083
|
+
<li class="covered" data-hits="58" data-linenumber="166">
|
1060
1084
|
<span class="hits">58</span>
|
1061
1085
|
|
1062
1086
|
<code class="ruby"> object.respond_to?(:empty?) ? object.empty? : !object</code>
|
1063
1087
|
</li>
|
1064
1088
|
|
1065
|
-
<li class="never" data-hits="" data-linenumber="
|
1089
|
+
<li class="never" data-hits="" data-linenumber="167">
|
1066
1090
|
|
1067
1091
|
|
1068
1092
|
<code class="ruby"> end</code>
|
1069
1093
|
</li>
|
1070
1094
|
|
1071
|
-
<li class="never" data-hits="" data-linenumber="
|
1095
|
+
<li class="never" data-hits="" data-linenumber="168">
|
1072
1096
|
|
1073
1097
|
|
1074
1098
|
<code class="ruby"> end</code>
|
1075
1099
|
</li>
|
1076
1100
|
|
1077
|
-
<li class="never" data-hits="" data-linenumber="
|
1101
|
+
<li class="never" data-hits="" data-linenumber="169">
|
1078
1102
|
|
1079
1103
|
|
1080
1104
|
<code class="ruby"></code>
|
1081
1105
|
</li>
|
1082
1106
|
|
1083
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1107
|
+
<li class="covered" data-hits="1" data-linenumber="170">
|
1084
1108
|
<span class="hits">1</span>
|
1085
1109
|
|
1086
1110
|
<code class="ruby"> helpers Param</code>
|
1087
1111
|
</li>
|
1088
1112
|
|
1089
|
-
<li class="never" data-hits="" data-linenumber="
|
1113
|
+
<li class="never" data-hits="" data-linenumber="171">
|
1090
1114
|
|
1091
1115
|
|
1092
1116
|
<code class="ruby">end</code>
|