hash_params 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/coverage/assets/0.8.0/application.css +799 -0
- data/coverage/assets/0.8.0/application.js +1559 -0
- data/coverage/assets/0.8.0/colorbox/border.png +0 -0
- data/coverage/assets/0.8.0/colorbox/controls.png +0 -0
- data/coverage/assets/0.8.0/colorbox/loading.gif +0 -0
- data/coverage/assets/0.8.0/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.8.0/favicon_green.png +0 -0
- data/coverage/assets/0.8.0/favicon_red.png +0 -0
- data/coverage/assets/0.8.0/favicon_yellow.png +0 -0
- data/coverage/assets/0.8.0/loading.gif +0 -0
- data/coverage/assets/0.8.0/magnify.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/assets/0.9.0/application.css +799 -0
- data/coverage/assets/0.9.0/application.js +1707 -0
- data/coverage/assets/0.9.0/colorbox/border.png +0 -0
- data/coverage/assets/0.9.0/colorbox/controls.png +0 -0
- data/coverage/assets/0.9.0/colorbox/loading.gif +0 -0
- data/coverage/assets/0.9.0/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.9.0/favicon_green.png +0 -0
- data/coverage/assets/0.9.0/favicon_red.png +0 -0
- data/coverage/assets/0.9.0/favicon_yellow.png +0 -0
- data/coverage/assets/0.9.0/loading.gif +0 -0
- data/coverage/assets/0.9.0/magnify.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +2192 -0
- data/hash_params-2.0.1.gem +0 -0
- data/lib/hash_params/yaml_params.rb +3 -0
- data/lib/hash_params.rb +1 -1
- data/tmp/hash_params.rb +181 -0
- data/tmp/hash_params_spec.rb +102 -0
- data/tmp/module_spec.rb +27 -0
- data/tmp/var_spec.rb +9 -0
- data/tmp/yaml_params.rb +109 -0
- metadata +58 -3
data/coverage/index.html
ADDED
@@ -0,0 +1,2192 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title>Code coverage for Hash param</title>
|
5
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
6
|
+
<script src='./assets/0.9.0/application.js' type='text/javascript'></script>
|
7
|
+
<link href='./assets/0.9.0/application.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
|
8
|
+
<link rel="shortcut icon" type="image/png" href="./assets/0.9.0/favicon_red.png" />
|
9
|
+
<link rel="icon" type="image/png" href="./assets/0.9.0/favicon.png" />
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<div id="loading">
|
14
|
+
<img src="./assets/0.9.0/loading.gif" alt="loading"/>
|
15
|
+
</div>
|
16
|
+
<div id="wrapper" style="display:none;">
|
17
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2015-05-19T14:23:50+12:00">2015-05-19T14:23:50+12:00</abbr></div>
|
18
|
+
<ul class="group_tabs"></ul>
|
19
|
+
|
20
|
+
<div id="content">
|
21
|
+
<div class="file_list_container" id="AllFiles">
|
22
|
+
<h2>
|
23
|
+
<span class="group_name">All Files</span>
|
24
|
+
(<span class="covered_percent"><span class="red">75.16%</span></span>
|
25
|
+
covered at
|
26
|
+
<span class="covered_strength">
|
27
|
+
<span class="green">
|
28
|
+
4.61
|
29
|
+
</span>
|
30
|
+
</span> hits/line)
|
31
|
+
</h2>
|
32
|
+
<a name="AllFiles"></a>
|
33
|
+
<div>
|
34
|
+
<b>5</b> files in total.
|
35
|
+
<b>161</b> relevant lines.
|
36
|
+
<span class="green"><b>121</b> lines covered</span> and
|
37
|
+
<span class="red"><b>40</b> lines missed </span>
|
38
|
+
</div>
|
39
|
+
<table class="file_list">
|
40
|
+
<thead>
|
41
|
+
<tr>
|
42
|
+
<th>File</th>
|
43
|
+
<th>% covered</th>
|
44
|
+
<th>Lines</th>
|
45
|
+
<th>Relevant Lines</th>
|
46
|
+
<th>Lines covered</th>
|
47
|
+
<th>Lines missed</th>
|
48
|
+
<th>Avg. Hits / Line</th>
|
49
|
+
</tr>
|
50
|
+
</thead>
|
51
|
+
<tbody>
|
52
|
+
|
53
|
+
<tr>
|
54
|
+
<td class="strong"><a href="#32ada782cad1cca43940fc5c8a722f32fd765f14" class="src_link" title="lib/hash_params.rb">lib/hash_params.rb</a></td>
|
55
|
+
<td class="green strong">100.0 %</td>
|
56
|
+
<td>21</td>
|
57
|
+
<td>12</td>
|
58
|
+
<td>12</td>
|
59
|
+
<td>0</td>
|
60
|
+
<td>1.0</td>
|
61
|
+
</tr>
|
62
|
+
|
63
|
+
<tr>
|
64
|
+
<td class="strong"><a href="#b1c546b2a036367cd6714d1a3d80305afff21484" class="src_link" title="lib/hash_params/binding_validator.rb">lib/hash_params/binding_validator.rb</a></td>
|
65
|
+
<td class="green strong">92.86 %</td>
|
66
|
+
<td>26</td>
|
67
|
+
<td>14</td>
|
68
|
+
<td>13</td>
|
69
|
+
<td>1</td>
|
70
|
+
<td>1.9</td>
|
71
|
+
</tr>
|
72
|
+
|
73
|
+
<tr>
|
74
|
+
<td class="strong"><a href="#f3376cb3f02016b662bfae7b7507dfdf1e033e63" class="src_link" title="lib/hash_params/hash_validator.rb">lib/hash_params/hash_validator.rb</a></td>
|
75
|
+
<td class="green strong">97.37 %</td>
|
76
|
+
<td>71</td>
|
77
|
+
<td>38</td>
|
78
|
+
<td>37</td>
|
79
|
+
<td>1</td>
|
80
|
+
<td>2.8</td>
|
81
|
+
</tr>
|
82
|
+
|
83
|
+
<tr>
|
84
|
+
<td class="strong"><a href="#f39507e800e8d660c679f1092f4a3b699ac789cb" class="src_link" title="lib/hash_params/validator.rb">lib/hash_params/validator.rb</a></td>
|
85
|
+
<td class="green strong">94.74 %</td>
|
86
|
+
<td>119</td>
|
87
|
+
<td>57</td>
|
88
|
+
<td>54</td>
|
89
|
+
<td>3</td>
|
90
|
+
<td>10.4</td>
|
91
|
+
</tr>
|
92
|
+
|
93
|
+
<tr>
|
94
|
+
<td class="strong"><a href="#abb09c4ec783968d5f7a1a3adac854712f21ee1e" class="src_link" title="lib/hash_params/yaml_params.rb">lib/hash_params/yaml_params.rb</a></td>
|
95
|
+
<td class="red strong">12.5 %</td>
|
96
|
+
<td>93</td>
|
97
|
+
<td>40</td>
|
98
|
+
<td>5</td>
|
99
|
+
<td>35</td>
|
100
|
+
<td>0.1</td>
|
101
|
+
</tr>
|
102
|
+
|
103
|
+
</tbody>
|
104
|
+
</table>
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<div id="footer">
|
112
|
+
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.9.2
|
113
|
+
and simplecov-html v0.9.0<br/>
|
114
|
+
using RSpec
|
115
|
+
</div>
|
116
|
+
|
117
|
+
<div class="source_files">
|
118
|
+
|
119
|
+
<div class="source_table" id="32ada782cad1cca43940fc5c8a722f32fd765f14">
|
120
|
+
<div class="header">
|
121
|
+
<h3>lib/hash_params.rb</h3>
|
122
|
+
<h4><span class="green">100.0 %</span> covered</h4>
|
123
|
+
<div>
|
124
|
+
<b>12</b> relevant lines.
|
125
|
+
<span class="green"><b>12</b> lines covered</span> and
|
126
|
+
<span class="red"><b>0</b> lines missed.</span>
|
127
|
+
</div>
|
128
|
+
</div>
|
129
|
+
|
130
|
+
<pre>
|
131
|
+
<ol>
|
132
|
+
|
133
|
+
<li class="covered" data-hits="1" data-linenumber="1">
|
134
|
+
<span class="hits">1</span>
|
135
|
+
|
136
|
+
<code class="ruby">require 'yaml'</code>
|
137
|
+
</li>
|
138
|
+
|
139
|
+
<li class="covered" data-hits="1" data-linenumber="2">
|
140
|
+
<span class="hits">1</span>
|
141
|
+
|
142
|
+
<code class="ruby">require 'erb'</code>
|
143
|
+
</li>
|
144
|
+
|
145
|
+
<li class="covered" data-hits="1" data-linenumber="3">
|
146
|
+
<span class="hits">1</span>
|
147
|
+
|
148
|
+
<code class="ruby">require 'socket'</code>
|
149
|
+
</li>
|
150
|
+
|
151
|
+
<li class="never" data-hits="" data-linenumber="4">
|
152
|
+
|
153
|
+
|
154
|
+
<code class="ruby"></code>
|
155
|
+
</li>
|
156
|
+
|
157
|
+
<li class="never" data-hits="" data-linenumber="5">
|
158
|
+
|
159
|
+
|
160
|
+
<code class="ruby"></code>
|
161
|
+
</li>
|
162
|
+
|
163
|
+
<li class="covered" data-hits="1" data-linenumber="6">
|
164
|
+
<span class="hits">1</span>
|
165
|
+
|
166
|
+
<code class="ruby">require_relative 'hash_params/hash_validator'</code>
|
167
|
+
</li>
|
168
|
+
|
169
|
+
<li class="covered" data-hits="1" data-linenumber="7">
|
170
|
+
<span class="hits">1</span>
|
171
|
+
|
172
|
+
<code class="ruby">require_relative 'hash_params/validator'</code>
|
173
|
+
</li>
|
174
|
+
|
175
|
+
<li class="covered" data-hits="1" data-linenumber="8">
|
176
|
+
<span class="hits">1</span>
|
177
|
+
|
178
|
+
<code class="ruby">require_relative 'hash_params/binding_validator'</code>
|
179
|
+
</li>
|
180
|
+
|
181
|
+
<li class="covered" data-hits="1" data-linenumber="9">
|
182
|
+
<span class="hits">1</span>
|
183
|
+
|
184
|
+
<code class="ruby">module HashParams</code>
|
185
|
+
</li>
|
186
|
+
|
187
|
+
<li class="covered" data-hits="1" data-linenumber="10">
|
188
|
+
<span class="hits">1</span>
|
189
|
+
|
190
|
+
<code class="ruby"> ENVIRONMENT = ENV['HASH_PARAMS_ENV'] || (defined?(Rails) && Rails.env) || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'</code>
|
191
|
+
</li>
|
192
|
+
|
193
|
+
<li class="covered" data-hits="1" data-linenumber="11">
|
194
|
+
<span class="hits">1</span>
|
195
|
+
|
196
|
+
<code class="ruby"> VERSION = '2.0.0'</code>
|
197
|
+
</li>
|
198
|
+
|
199
|
+
<li class="covered" data-hits="1" data-linenumber="12">
|
200
|
+
<span class="hits">1</span>
|
201
|
+
|
202
|
+
<code class="ruby"> extend HashParams::Validator</code>
|
203
|
+
</li>
|
204
|
+
|
205
|
+
<li class="never" data-hits="" data-linenumber="13">
|
206
|
+
|
207
|
+
|
208
|
+
<code class="ruby">end</code>
|
209
|
+
</li>
|
210
|
+
|
211
|
+
<li class="never" data-hits="" data-linenumber="14">
|
212
|
+
|
213
|
+
|
214
|
+
<code class="ruby"></code>
|
215
|
+
</li>
|
216
|
+
|
217
|
+
<li class="covered" data-hits="1" data-linenumber="15">
|
218
|
+
<span class="hits">1</span>
|
219
|
+
|
220
|
+
<code class="ruby">require_relative 'hash_params/yaml_params'</code>
|
221
|
+
</li>
|
222
|
+
|
223
|
+
<li class="covered" data-hits="1" data-linenumber="16">
|
224
|
+
<span class="hits">1</span>
|
225
|
+
|
226
|
+
<code class="ruby">require 'pry' if HashParams::ENVIRONMENT == 'development'</code>
|
227
|
+
</li>
|
228
|
+
|
229
|
+
<li class="never" data-hits="" data-linenumber="17">
|
230
|
+
|
231
|
+
|
232
|
+
<code class="ruby"></code>
|
233
|
+
</li>
|
234
|
+
|
235
|
+
<li class="never" data-hits="" data-linenumber="18">
|
236
|
+
|
237
|
+
|
238
|
+
<code class="ruby"></code>
|
239
|
+
</li>
|
240
|
+
|
241
|
+
<li class="never" data-hits="" data-linenumber="19">
|
242
|
+
|
243
|
+
|
244
|
+
<code class="ruby"></code>
|
245
|
+
</li>
|
246
|
+
|
247
|
+
<li class="never" data-hits="" data-linenumber="20">
|
248
|
+
|
249
|
+
|
250
|
+
<code class="ruby"></code>
|
251
|
+
</li>
|
252
|
+
|
253
|
+
<li class="never" data-hits="" data-linenumber="21">
|
254
|
+
|
255
|
+
|
256
|
+
<code class="ruby"></code>
|
257
|
+
</li>
|
258
|
+
|
259
|
+
</ol>
|
260
|
+
</pre>
|
261
|
+
</div>
|
262
|
+
|
263
|
+
<div class="source_table" id="b1c546b2a036367cd6714d1a3d80305afff21484">
|
264
|
+
<div class="header">
|
265
|
+
<h3>lib/hash_params/binding_validator.rb</h3>
|
266
|
+
<h4><span class="green">92.86 %</span> covered</h4>
|
267
|
+
<div>
|
268
|
+
<b>14</b> relevant lines.
|
269
|
+
<span class="green"><b>13</b> lines covered</span> and
|
270
|
+
<span class="red"><b>1</b> lines missed.</span>
|
271
|
+
</div>
|
272
|
+
</div>
|
273
|
+
|
274
|
+
<pre>
|
275
|
+
<ol>
|
276
|
+
|
277
|
+
<li class="covered" data-hits="1" data-linenumber="1">
|
278
|
+
<span class="hits">1</span>
|
279
|
+
|
280
|
+
<code class="ruby">module HashParams</code>
|
281
|
+
</li>
|
282
|
+
|
283
|
+
<li class="covered" data-hits="1" data-linenumber="2">
|
284
|
+
<span class="hits">1</span>
|
285
|
+
|
286
|
+
<code class="ruby"> class BindingValidator</code>
|
287
|
+
</li>
|
288
|
+
|
289
|
+
<li class="never" data-hits="" data-linenumber="3">
|
290
|
+
|
291
|
+
|
292
|
+
<code class="ruby"></code>
|
293
|
+
</li>
|
294
|
+
|
295
|
+
<li class="covered" data-hits="1" data-linenumber="4">
|
296
|
+
<span class="hits">1</span>
|
297
|
+
|
298
|
+
<code class="ruby"> def with_binding (&code)</code>
|
299
|
+
</li>
|
300
|
+
|
301
|
+
<li class="covered" data-hits="1" data-linenumber="5">
|
302
|
+
<span class="hits">1</span>
|
303
|
+
|
304
|
+
<code class="ruby"> @binding = code.binding</code>
|
305
|
+
</li>
|
306
|
+
|
307
|
+
<li class="covered" data-hits="1" data-linenumber="6">
|
308
|
+
<span class="hits">1</span>
|
309
|
+
|
310
|
+
<code class="ruby"> instance_eval(&code)</code>
|
311
|
+
</li>
|
312
|
+
|
313
|
+
<li class="never" data-hits="" data-linenumber="7">
|
314
|
+
|
315
|
+
|
316
|
+
<code class="ruby"> end</code>
|
317
|
+
</li>
|
318
|
+
|
319
|
+
<li class="never" data-hits="" data-linenumber="8">
|
320
|
+
|
321
|
+
|
322
|
+
<code class="ruby"></code>
|
323
|
+
</li>
|
324
|
+
|
325
|
+
<li class="never" data-hits="" data-linenumber="9">
|
326
|
+
|
327
|
+
|
328
|
+
<code class="ruby"></code>
|
329
|
+
</li>
|
330
|
+
|
331
|
+
<li class="covered" data-hits="1" data-linenumber="10">
|
332
|
+
<span class="hits">1</span>
|
333
|
+
|
334
|
+
<code class="ruby"> def var(var_name, type, opts={})</code>
|
335
|
+
</li>
|
336
|
+
|
337
|
+
<li class="covered" data-hits="4" data-linenumber="11">
|
338
|
+
<span class="hits">4</span>
|
339
|
+
|
340
|
+
<code class="ruby"> raise 'Variable name must be a string or symbol' unless (var_name.is_a?(String) || var_name.is_a?(Symbol))</code>
|
341
|
+
</li>
|
342
|
+
|
343
|
+
<li class="covered" data-hits="4" data-linenumber="12">
|
344
|
+
<span class="hits">4</span>
|
345
|
+
|
346
|
+
<code class="ruby"> value = @binding.local_variable_get var_name</code>
|
347
|
+
</li>
|
348
|
+
|
349
|
+
<li class="covered" data-hits="4" data-linenumber="13">
|
350
|
+
<span class="hits">4</span>
|
351
|
+
|
352
|
+
<code class="ruby"> new_value = if value.is_a?(Hash)</code>
|
353
|
+
</li>
|
354
|
+
|
355
|
+
<li class="covered" data-hits="1" data-linenumber="14">
|
356
|
+
<span class="hits">1</span>
|
357
|
+
|
358
|
+
<code class="ruby"> if block_given?</code>
|
359
|
+
</li>
|
360
|
+
|
361
|
+
<li class="never" data-hits="" data-linenumber="15">
|
362
|
+
|
363
|
+
|
364
|
+
<code class="ruby"> #if the param is a hash then the validations are actually options</code>
|
365
|
+
</li>
|
366
|
+
|
367
|
+
<li class="covered" data-hits="1" data-linenumber="16">
|
368
|
+
<span class="hits">1</span>
|
369
|
+
|
370
|
+
<code class="ruby"> HashParams::HashValidator.new.validate_hash(value, opts, &Proc.new)</code>
|
371
|
+
</li>
|
372
|
+
|
373
|
+
<li class="never" data-hits="" data-linenumber="17">
|
374
|
+
|
375
|
+
|
376
|
+
<code class="ruby"> else</code>
|
377
|
+
</li>
|
378
|
+
|
379
|
+
<li class="missed" data-hits="0" data-linenumber="18">
|
380
|
+
|
381
|
+
|
382
|
+
<code class="ruby"> HashParams::HashValidator.new.validate_hash(value, opts)</code>
|
383
|
+
</li>
|
384
|
+
|
385
|
+
<li class="never" data-hits="" data-linenumber="19">
|
386
|
+
|
387
|
+
|
388
|
+
<code class="ruby"> end</code>
|
389
|
+
</li>
|
390
|
+
|
391
|
+
<li class="never" data-hits="" data-linenumber="20">
|
392
|
+
|
393
|
+
|
394
|
+
<code class="ruby"> else</code>
|
395
|
+
</li>
|
396
|
+
|
397
|
+
<li class="covered" data-hits="3" data-linenumber="21">
|
398
|
+
<span class="hits">3</span>
|
399
|
+
|
400
|
+
<code class="ruby"> HashParams.validate value, type, opts</code>
|
401
|
+
</li>
|
402
|
+
|
403
|
+
<li class="never" data-hits="" data-linenumber="22">
|
404
|
+
|
405
|
+
|
406
|
+
<code class="ruby"> end</code>
|
407
|
+
</li>
|
408
|
+
|
409
|
+
<li class="covered" data-hits="4" data-linenumber="23">
|
410
|
+
<span class="hits">4</span>
|
411
|
+
|
412
|
+
<code class="ruby"> @binding.local_variable_set var_name, new_value</code>
|
413
|
+
</li>
|
414
|
+
|
415
|
+
<li class="never" data-hits="" data-linenumber="24">
|
416
|
+
|
417
|
+
|
418
|
+
<code class="ruby"> end</code>
|
419
|
+
</li>
|
420
|
+
|
421
|
+
<li class="never" data-hits="" data-linenumber="25">
|
422
|
+
|
423
|
+
|
424
|
+
<code class="ruby"> end</code>
|
425
|
+
</li>
|
426
|
+
|
427
|
+
<li class="never" data-hits="" data-linenumber="26">
|
428
|
+
|
429
|
+
|
430
|
+
<code class="ruby">end</code>
|
431
|
+
</li>
|
432
|
+
|
433
|
+
</ol>
|
434
|
+
</pre>
|
435
|
+
</div>
|
436
|
+
|
437
|
+
<div class="source_table" id="f3376cb3f02016b662bfae7b7507dfdf1e033e63">
|
438
|
+
<div class="header">
|
439
|
+
<h3>lib/hash_params/hash_validator.rb</h3>
|
440
|
+
<h4><span class="green">97.37 %</span> covered</h4>
|
441
|
+
<div>
|
442
|
+
<b>38</b> relevant lines.
|
443
|
+
<span class="green"><b>37</b> lines covered</span> and
|
444
|
+
<span class="red"><b>1</b> lines missed.</span>
|
445
|
+
</div>
|
446
|
+
</div>
|
447
|
+
|
448
|
+
<pre>
|
449
|
+
<ol>
|
450
|
+
|
451
|
+
<li class="covered" data-hits="1" data-linenumber="1">
|
452
|
+
<span class="hits">1</span>
|
453
|
+
|
454
|
+
<code class="ruby">module HashParams</code>
|
455
|
+
</li>
|
456
|
+
|
457
|
+
<li class="never" data-hits="" data-linenumber="2">
|
458
|
+
|
459
|
+
|
460
|
+
<code class="ruby"></code>
|
461
|
+
</li>
|
462
|
+
|
463
|
+
<li class="never" data-hits="" data-linenumber="3">
|
464
|
+
|
465
|
+
|
466
|
+
<code class="ruby"></code>
|
467
|
+
</li>
|
468
|
+
|
469
|
+
<li class="covered" data-hits="1" data-linenumber="4">
|
470
|
+
<span class="hits">1</span>
|
471
|
+
|
472
|
+
<code class="ruby"> class HPHash < Hash</code>
|
473
|
+
</li>
|
474
|
+
|
475
|
+
<li class="covered" data-hits="1" data-linenumber="5">
|
476
|
+
<span class="hits">1</span>
|
477
|
+
|
478
|
+
<code class="ruby"> attr_accessor :validation_errors</code>
|
479
|
+
</li>
|
480
|
+
|
481
|
+
<li class="never" data-hits="" data-linenumber="6">
|
482
|
+
|
483
|
+
|
484
|
+
<code class="ruby"></code>
|
485
|
+
</li>
|
486
|
+
|
487
|
+
<li class="covered" data-hits="1" data-linenumber="7">
|
488
|
+
<span class="hits">1</span>
|
489
|
+
|
490
|
+
<code class="ruby"> def initialize(args=nil)</code>
|
491
|
+
</li>
|
492
|
+
|
493
|
+
<li class="covered" data-hits="4" data-linenumber="8">
|
494
|
+
<span class="hits">4</span>
|
495
|
+
|
496
|
+
<code class="ruby"> @validation_errors=[]</code>
|
497
|
+
</li>
|
498
|
+
|
499
|
+
<li class="covered" data-hits="4" data-linenumber="9">
|
500
|
+
<span class="hits">4</span>
|
501
|
+
|
502
|
+
<code class="ruby"> super(args)</code>
|
503
|
+
</li>
|
504
|
+
|
505
|
+
<li class="never" data-hits="" data-linenumber="10">
|
506
|
+
|
507
|
+
|
508
|
+
<code class="ruby"> end</code>
|
509
|
+
</li>
|
510
|
+
|
511
|
+
<li class="never" data-hits="" data-linenumber="11">
|
512
|
+
|
513
|
+
|
514
|
+
<code class="ruby"></code>
|
515
|
+
</li>
|
516
|
+
|
517
|
+
<li class="covered" data-hits="1" data-linenumber="12">
|
518
|
+
<span class="hits">1</span>
|
519
|
+
|
520
|
+
<code class="ruby"> def valid?</code>
|
521
|
+
</li>
|
522
|
+
|
523
|
+
<li class="covered" data-hits="1" data-linenumber="13">
|
524
|
+
<span class="hits">1</span>
|
525
|
+
|
526
|
+
<code class="ruby"> @validation_errors.empty?</code>
|
527
|
+
</li>
|
528
|
+
|
529
|
+
<li class="never" data-hits="" data-linenumber="14">
|
530
|
+
|
531
|
+
|
532
|
+
<code class="ruby"> end</code>
|
533
|
+
</li>
|
534
|
+
|
535
|
+
<li class="never" data-hits="" data-linenumber="15">
|
536
|
+
|
537
|
+
|
538
|
+
<code class="ruby"></code>
|
539
|
+
</li>
|
540
|
+
|
541
|
+
<li class="covered" data-hits="1" data-linenumber="16">
|
542
|
+
<span class="hits">1</span>
|
543
|
+
|
544
|
+
<code class="ruby"> def set_key_value(key, value, symbolize_key, make_method)</code>
|
545
|
+
</li>
|
546
|
+
|
547
|
+
<li class="covered" data-hits="6" data-linenumber="17">
|
548
|
+
<span class="hits">6</span>
|
549
|
+
|
550
|
+
<code class="ruby"> key = key.to_s.to_sym if symbolize_key</code>
|
551
|
+
</li>
|
552
|
+
|
553
|
+
<li class="covered" data-hits="6" data-linenumber="18">
|
554
|
+
<span class="hits">6</span>
|
555
|
+
|
556
|
+
<code class="ruby"> if make_method</code>
|
557
|
+
</li>
|
558
|
+
|
559
|
+
<li class="covered" data-hits="1" data-linenumber="19">
|
560
|
+
<span class="hits">1</span>
|
561
|
+
|
562
|
+
<code class="ruby"> singleton_class.module_eval do</code>
|
563
|
+
</li>
|
564
|
+
|
565
|
+
<li class="covered" data-hits="1" data-linenumber="20">
|
566
|
+
<span class="hits">1</span>
|
567
|
+
|
568
|
+
<code class="ruby"> define_method key.to_s.to_sym do</code>
|
569
|
+
</li>
|
570
|
+
|
571
|
+
<li class="covered" data-hits="1" data-linenumber="21">
|
572
|
+
<span class="hits">1</span>
|
573
|
+
|
574
|
+
<code class="ruby"> value</code>
|
575
|
+
</li>
|
576
|
+
|
577
|
+
<li class="never" data-hits="" data-linenumber="22">
|
578
|
+
|
579
|
+
|
580
|
+
<code class="ruby"> end</code>
|
581
|
+
</li>
|
582
|
+
|
583
|
+
<li class="never" data-hits="" data-linenumber="23">
|
584
|
+
|
585
|
+
|
586
|
+
<code class="ruby"> end</code>
|
587
|
+
</li>
|
588
|
+
|
589
|
+
<li class="never" data-hits="" data-linenumber="24">
|
590
|
+
|
591
|
+
|
592
|
+
<code class="ruby"> end</code>
|
593
|
+
</li>
|
594
|
+
|
595
|
+
<li class="covered" data-hits="6" data-linenumber="25">
|
596
|
+
<span class="hits">6</span>
|
597
|
+
|
598
|
+
<code class="ruby"> self[key]=value</code>
|
599
|
+
</li>
|
600
|
+
|
601
|
+
<li class="never" data-hits="" data-linenumber="26">
|
602
|
+
|
603
|
+
|
604
|
+
<code class="ruby"> end</code>
|
605
|
+
</li>
|
606
|
+
|
607
|
+
<li class="never" data-hits="" data-linenumber="27">
|
608
|
+
|
609
|
+
|
610
|
+
<code class="ruby"> end</code>
|
611
|
+
</li>
|
612
|
+
|
613
|
+
<li class="never" data-hits="" data-linenumber="28">
|
614
|
+
|
615
|
+
|
616
|
+
<code class="ruby"></code>
|
617
|
+
</li>
|
618
|
+
|
619
|
+
<li class="covered" data-hits="1" data-linenumber="29">
|
620
|
+
<span class="hits">1</span>
|
621
|
+
|
622
|
+
<code class="ruby"> class HashValidator</code>
|
623
|
+
</li>
|
624
|
+
|
625
|
+
<li class="never" data-hits="" data-linenumber="30">
|
626
|
+
|
627
|
+
|
628
|
+
<code class="ruby"></code>
|
629
|
+
</li>
|
630
|
+
|
631
|
+
<li class="covered" data-hits="1" data-linenumber="31">
|
632
|
+
<span class="hits">1</span>
|
633
|
+
|
634
|
+
<code class="ruby"> def validate_hash(h, options={})</code>
|
635
|
+
</li>
|
636
|
+
|
637
|
+
<li class="never" data-hits="" data-linenumber="32">
|
638
|
+
|
639
|
+
|
640
|
+
<code class="ruby"> #Hash Validation has to be stateful</code>
|
641
|
+
</li>
|
642
|
+
|
643
|
+
<li class="never" data-hits="" data-linenumber="33">
|
644
|
+
|
645
|
+
|
646
|
+
<code class="ruby"></code>
|
647
|
+
</li>
|
648
|
+
|
649
|
+
<li class="covered" data-hits="4" data-linenumber="34">
|
650
|
+
<span class="hits">4</span>
|
651
|
+
|
652
|
+
<code class="ruby"> @incoming = h</code>
|
653
|
+
</li>
|
654
|
+
|
655
|
+
<li class="covered" data-hits="4" data-linenumber="35">
|
656
|
+
<span class="hits">4</span>
|
657
|
+
|
658
|
+
<code class="ruby"> @outgoing = HPHash.new</code>
|
659
|
+
</li>
|
660
|
+
|
661
|
+
<li class="covered" data-hits="4" data-linenumber="36">
|
662
|
+
<span class="hits">4</span>
|
663
|
+
|
664
|
+
<code class="ruby"> @options = options</code>
|
665
|
+
</li>
|
666
|
+
|
667
|
+
<li class="never" data-hits="" data-linenumber="37">
|
668
|
+
|
669
|
+
|
670
|
+
<code class="ruby"></code>
|
671
|
+
</li>
|
672
|
+
|
673
|
+
<li class="covered" data-hits="4" data-linenumber="38">
|
674
|
+
<span class="hits">4</span>
|
675
|
+
|
676
|
+
<code class="ruby"> if block_given?</code>
|
677
|
+
</li>
|
678
|
+
|
679
|
+
<li class="covered" data-hits="3" data-linenumber="39">
|
680
|
+
<span class="hits">3</span>
|
681
|
+
|
682
|
+
<code class="ruby"> instance_eval(&Proc.new)</code>
|
683
|
+
</li>
|
684
|
+
|
685
|
+
<li class="never" data-hits="" data-linenumber="40">
|
686
|
+
|
687
|
+
|
688
|
+
<code class="ruby"> else</code>
|
689
|
+
</li>
|
690
|
+
|
691
|
+
<li class="never" data-hits="" data-linenumber="41">
|
692
|
+
|
693
|
+
|
694
|
+
<code class="ruby"> #no proc was given this means just pass the hash back as is</code>
|
695
|
+
</li>
|
696
|
+
|
697
|
+
<li class="covered" data-hits="1" data-linenumber="42">
|
698
|
+
<span class="hits">1</span>
|
699
|
+
|
700
|
+
<code class="ruby"> @outgoing = @incoming</code>
|
701
|
+
</li>
|
702
|
+
|
703
|
+
<li class="never" data-hits="" data-linenumber="43">
|
704
|
+
|
705
|
+
|
706
|
+
<code class="ruby"> end</code>
|
707
|
+
</li>
|
708
|
+
|
709
|
+
<li class="covered" data-hits="4" data-linenumber="44">
|
710
|
+
<span class="hits">4</span>
|
711
|
+
|
712
|
+
<code class="ruby"> @outgoing</code>
|
713
|
+
</li>
|
714
|
+
|
715
|
+
<li class="never" data-hits="" data-linenumber="45">
|
716
|
+
|
717
|
+
|
718
|
+
<code class="ruby"> end</code>
|
719
|
+
</li>
|
720
|
+
|
721
|
+
<li class="never" data-hits="" data-linenumber="46">
|
722
|
+
|
723
|
+
|
724
|
+
<code class="ruby"></code>
|
725
|
+
</li>
|
726
|
+
|
727
|
+
<li class="covered" data-hits="1" data-linenumber="47">
|
728
|
+
<span class="hits">1</span>
|
729
|
+
|
730
|
+
<code class="ruby"> def key(hash_key, type, opts={})</code>
|
731
|
+
</li>
|
732
|
+
|
733
|
+
<li class="covered" data-hits="7" data-linenumber="48">
|
734
|
+
<span class="hits">7</span>
|
735
|
+
|
736
|
+
<code class="ruby"> value = @incoming[hash_key] || @incoming[hash_key.to_s]</code>
|
737
|
+
</li>
|
738
|
+
|
739
|
+
<li class="never" data-hits="" data-linenumber="49">
|
740
|
+
|
741
|
+
|
742
|
+
<code class="ruby"> # if a block is given to the param then it's a recursive call</code>
|
743
|
+
</li>
|
744
|
+
|
745
|
+
<li class="never" data-hits="" data-linenumber="50">
|
746
|
+
|
747
|
+
|
748
|
+
<code class="ruby"> # recursive calls can only be done with a hash</code>
|
749
|
+
</li>
|
750
|
+
|
751
|
+
<li class="covered" data-hits="7" data-linenumber="51">
|
752
|
+
<span class="hits">7</span>
|
753
|
+
|
754
|
+
<code class="ruby"> new_value = if value.is_a?(Hash)</code>
|
755
|
+
</li>
|
756
|
+
|
757
|
+
<li class="covered" data-hits="1" data-linenumber="52">
|
758
|
+
<span class="hits">1</span>
|
759
|
+
|
760
|
+
<code class="ruby"> if block_given?</code>
|
761
|
+
</li>
|
762
|
+
|
763
|
+
<li class="never" data-hits="" data-linenumber="53">
|
764
|
+
|
765
|
+
|
766
|
+
<code class="ruby"> #if the param is a hash then the validations are actually options</code>
|
767
|
+
</li>
|
768
|
+
|
769
|
+
<li class="covered" data-hits="1" data-linenumber="54">
|
770
|
+
<span class="hits">1</span>
|
771
|
+
|
772
|
+
<code class="ruby"> HashParams::HashValidator.new.validate_hash(value, @options, &Proc.new)</code>
|
773
|
+
</li>
|
774
|
+
|
775
|
+
<li class="never" data-hits="" data-linenumber="55">
|
776
|
+
|
777
|
+
|
778
|
+
<code class="ruby"> else</code>
|
779
|
+
</li>
|
780
|
+
|
781
|
+
<li class="missed" data-hits="0" data-linenumber="56">
|
782
|
+
|
783
|
+
|
784
|
+
<code class="ruby"> HashParams::HashValidator.new.validate_hash(value, opts)</code>
|
785
|
+
</li>
|
786
|
+
|
787
|
+
<li class="never" data-hits="" data-linenumber="57">
|
788
|
+
|
789
|
+
|
790
|
+
<code class="ruby"> end</code>
|
791
|
+
</li>
|
792
|
+
|
793
|
+
<li class="never" data-hits="" data-linenumber="58">
|
794
|
+
|
795
|
+
|
796
|
+
<code class="ruby"> else</code>
|
797
|
+
</li>
|
798
|
+
|
799
|
+
<li class="covered" data-hits="6" data-linenumber="59">
|
800
|
+
<span class="hits">6</span>
|
801
|
+
|
802
|
+
<code class="ruby"> HashParams.validate value, type, opts</code>
|
803
|
+
</li>
|
804
|
+
|
805
|
+
<li class="never" data-hits="" data-linenumber="60">
|
806
|
+
|
807
|
+
|
808
|
+
<code class="ruby"> end</code>
|
809
|
+
</li>
|
810
|
+
|
811
|
+
<li class="covered" data-hits="6" data-linenumber="61">
|
812
|
+
<span class="hits">6</span>
|
813
|
+
|
814
|
+
<code class="ruby"> hash_key = opts[:as] if opts[:as]</code>
|
815
|
+
</li>
|
816
|
+
|
817
|
+
<li class="covered" data-hits="6" data-linenumber="62">
|
818
|
+
<span class="hits">6</span>
|
819
|
+
|
820
|
+
<code class="ruby"> @outgoing.set_key_value(hash_key, new_value, @options[:symbolize_keys], @options[:make_methods])</code>
|
821
|
+
</li>
|
822
|
+
|
823
|
+
<li class="covered" data-hits="6" data-linenumber="63">
|
824
|
+
<span class="hits">6</span>
|
825
|
+
|
826
|
+
<code class="ruby"> new_value</code>
|
827
|
+
</li>
|
828
|
+
|
829
|
+
<li class="never" data-hits="" data-linenumber="64">
|
830
|
+
|
831
|
+
|
832
|
+
<code class="ruby"> rescue => e</code>
|
833
|
+
</li>
|
834
|
+
|
835
|
+
<li class="covered" data-hits="1" data-linenumber="65">
|
836
|
+
<span class="hits">1</span>
|
837
|
+
|
838
|
+
<code class="ruby"> @outgoing.validation_errors << "Error processing key '#{hash_key}': #{e}" # [e.to_s, e.backtrace].join("\n")</code>
|
839
|
+
</li>
|
840
|
+
|
841
|
+
<li class="covered" data-hits="1" data-linenumber="66">
|
842
|
+
<span class="hits">1</span>
|
843
|
+
|
844
|
+
<code class="ruby"> raise e if @options[:raise_errors]</code>
|
845
|
+
</li>
|
846
|
+
|
847
|
+
<li class="covered" data-hits="1" data-linenumber="67">
|
848
|
+
<span class="hits">1</span>
|
849
|
+
|
850
|
+
<code class="ruby"> nil</code>
|
851
|
+
</li>
|
852
|
+
|
853
|
+
<li class="never" data-hits="" data-linenumber="68">
|
854
|
+
|
855
|
+
|
856
|
+
<code class="ruby"> end</code>
|
857
|
+
</li>
|
858
|
+
|
859
|
+
<li class="covered" data-hits="1" data-linenumber="69">
|
860
|
+
<span class="hits">1</span>
|
861
|
+
|
862
|
+
<code class="ruby"> alias_method :param, :key</code>
|
863
|
+
</li>
|
864
|
+
|
865
|
+
<li class="never" data-hits="" data-linenumber="70">
|
866
|
+
|
867
|
+
|
868
|
+
<code class="ruby"> end</code>
|
869
|
+
</li>
|
870
|
+
|
871
|
+
<li class="never" data-hits="" data-linenumber="71">
|
872
|
+
|
873
|
+
|
874
|
+
<code class="ruby">end</code>
|
875
|
+
</li>
|
876
|
+
|
877
|
+
</ol>
|
878
|
+
</pre>
|
879
|
+
</div>
|
880
|
+
|
881
|
+
<div class="source_table" id="f39507e800e8d660c679f1092f4a3b699ac789cb">
|
882
|
+
<div class="header">
|
883
|
+
<h3>lib/hash_params/validator.rb</h3>
|
884
|
+
<h4><span class="green">94.74 %</span> covered</h4>
|
885
|
+
<div>
|
886
|
+
<b>57</b> relevant lines.
|
887
|
+
<span class="green"><b>54</b> lines covered</span> and
|
888
|
+
<span class="red"><b>3</b> lines missed.</span>
|
889
|
+
</div>
|
890
|
+
</div>
|
891
|
+
|
892
|
+
<pre>
|
893
|
+
<ol>
|
894
|
+
|
895
|
+
<li class="covered" data-hits="1" data-linenumber="1">
|
896
|
+
<span class="hits">1</span>
|
897
|
+
|
898
|
+
<code class="ruby">module HashParams</code>
|
899
|
+
</li>
|
900
|
+
|
901
|
+
<li class="covered" data-hits="1" data-linenumber="2">
|
902
|
+
<span class="hits">1</span>
|
903
|
+
|
904
|
+
<code class="ruby"> module Validator</code>
|
905
|
+
</li>
|
906
|
+
|
907
|
+
<li class="never" data-hits="" data-linenumber="3">
|
908
|
+
|
909
|
+
|
910
|
+
<code class="ruby"></code>
|
911
|
+
</li>
|
912
|
+
|
913
|
+
<li class="covered" data-hits="1" data-linenumber="4">
|
914
|
+
<span class="hits">1</span>
|
915
|
+
|
916
|
+
<code class="ruby"> class ValidationError < StandardError</code>
|
917
|
+
</li>
|
918
|
+
|
919
|
+
<li class="never" data-hits="" data-linenumber="5">
|
920
|
+
|
921
|
+
|
922
|
+
<code class="ruby"> end</code>
|
923
|
+
</li>
|
924
|
+
|
925
|
+
<li class="never" data-hits="" data-linenumber="6">
|
926
|
+
|
927
|
+
|
928
|
+
<code class="ruby"></code>
|
929
|
+
</li>
|
930
|
+
|
931
|
+
<li class="covered" data-hits="1" data-linenumber="7">
|
932
|
+
<span class="hits">1</span>
|
933
|
+
|
934
|
+
<code class="ruby"> class CoercionError < StandardError</code>
|
935
|
+
</li>
|
936
|
+
|
937
|
+
<li class="never" data-hits="" data-linenumber="8">
|
938
|
+
|
939
|
+
|
940
|
+
<code class="ruby"> end</code>
|
941
|
+
</li>
|
942
|
+
|
943
|
+
<li class="never" data-hits="" data-linenumber="9">
|
944
|
+
|
945
|
+
|
946
|
+
<code class="ruby"></code>
|
947
|
+
</li>
|
948
|
+
|
949
|
+
<li class="covered" data-hits="1" data-linenumber="10">
|
950
|
+
<span class="hits">1</span>
|
951
|
+
|
952
|
+
<code class="ruby"> def with_binding(&code)</code>
|
953
|
+
</li>
|
954
|
+
|
955
|
+
<li class="covered" data-hits="1" data-linenumber="11">
|
956
|
+
<span class="hits">1</span>
|
957
|
+
|
958
|
+
<code class="ruby"> BindingValidator.new.with_binding(&code)</code>
|
959
|
+
</li>
|
960
|
+
|
961
|
+
<li class="never" data-hits="" data-linenumber="12">
|
962
|
+
|
963
|
+
|
964
|
+
<code class="ruby"> end</code>
|
965
|
+
</li>
|
966
|
+
|
967
|
+
<li class="never" data-hits="" data-linenumber="13">
|
968
|
+
|
969
|
+
|
970
|
+
<code class="ruby"></code>
|
971
|
+
</li>
|
972
|
+
|
973
|
+
<li class="covered" data-hits="1" data-linenumber="14">
|
974
|
+
<span class="hits">1</span>
|
975
|
+
|
976
|
+
<code class="ruby"> def validate(param, type, validations={})</code>
|
977
|
+
</li>
|
978
|
+
|
979
|
+
<li class="never" data-hits="" data-linenumber="15">
|
980
|
+
|
981
|
+
|
982
|
+
<code class="ruby"></code>
|
983
|
+
</li>
|
984
|
+
|
985
|
+
<li class="covered" data-hits="30" data-linenumber="16">
|
986
|
+
<span class="hits">30</span>
|
987
|
+
|
988
|
+
<code class="ruby"> coercions = Array(validations[:coerce]) << type</code>
|
989
|
+
</li>
|
990
|
+
|
991
|
+
<li class="never" data-hits="" data-linenumber="17">
|
992
|
+
|
993
|
+
|
994
|
+
<code class="ruby"></code>
|
995
|
+
</li>
|
996
|
+
|
997
|
+
<li class="covered" data-hits="30" data-linenumber="18">
|
998
|
+
<span class="hits">30</span>
|
999
|
+
|
1000
|
+
<code class="ruby"> if param.nil? && validations[:default]</code>
|
1001
|
+
</li>
|
1002
|
+
|
1003
|
+
<li class="covered" data-hits="5" data-linenumber="19">
|
1004
|
+
<span class="hits">5</span>
|
1005
|
+
|
1006
|
+
<code class="ruby"> param = validations[:default].respond_to?(:call) ? validations[:default].call() : validations[:default]</code>
|
1007
|
+
</li>
|
1008
|
+
|
1009
|
+
<li class="never" data-hits="" data-linenumber="20">
|
1010
|
+
|
1011
|
+
|
1012
|
+
<code class="ruby"> end</code>
|
1013
|
+
</li>
|
1014
|
+
|
1015
|
+
<li class="never" data-hits="" data-linenumber="21">
|
1016
|
+
|
1017
|
+
|
1018
|
+
<code class="ruby"></code>
|
1019
|
+
</li>
|
1020
|
+
|
1021
|
+
<li class="never" data-hits="" data-linenumber="22">
|
1022
|
+
|
1023
|
+
|
1024
|
+
<code class="ruby"> #if there is a :validate lambda run that too</code>
|
1025
|
+
</li>
|
1026
|
+
|
1027
|
+
<li class="covered" data-hits="30" data-linenumber="23">
|
1028
|
+
<span class="hits">30</span>
|
1029
|
+
|
1030
|
+
<code class="ruby"> if validations[:validate] && validations[:validate].respond_to?(:call)</code>
|
1031
|
+
</li>
|
1032
|
+
|
1033
|
+
<li class="covered" data-hits="2" data-linenumber="24">
|
1034
|
+
<span class="hits">2</span>
|
1035
|
+
|
1036
|
+
<code class="ruby"> param = validations.delete(:validate).call(param)</code>
|
1037
|
+
</li>
|
1038
|
+
|
1039
|
+
<li class="never" data-hits="" data-linenumber="25">
|
1040
|
+
|
1041
|
+
|
1042
|
+
<code class="ruby"> end</code>
|
1043
|
+
</li>
|
1044
|
+
|
1045
|
+
<li class="never" data-hits="" data-linenumber="26">
|
1046
|
+
|
1047
|
+
|
1048
|
+
<code class="ruby"></code>
|
1049
|
+
</li>
|
1050
|
+
|
1051
|
+
<li class="covered" data-hits="30" data-linenumber="27">
|
1052
|
+
<span class="hits">30</span>
|
1053
|
+
|
1054
|
+
<code class="ruby"> if block_given? && !param.is_a?(Hash)</code>
|
1055
|
+
</li>
|
1056
|
+
|
1057
|
+
<li class="covered" data-hits="1" data-linenumber="28">
|
1058
|
+
<span class="hits">1</span>
|
1059
|
+
|
1060
|
+
<code class="ruby"> param = yield(param, validations)</code>
|
1061
|
+
</li>
|
1062
|
+
|
1063
|
+
<li class="never" data-hits="" data-linenumber="29">
|
1064
|
+
|
1065
|
+
|
1066
|
+
<code class="ruby"> end</code>
|
1067
|
+
</li>
|
1068
|
+
|
1069
|
+
<li class="never" data-hits="" data-linenumber="30">
|
1070
|
+
|
1071
|
+
|
1072
|
+
<code class="ruby"></code>
|
1073
|
+
</li>
|
1074
|
+
|
1075
|
+
<li class="never" data-hits="" data-linenumber="31">
|
1076
|
+
|
1077
|
+
|
1078
|
+
<code class="ruby"> # do all coercion and transformation first there could be an array of coersions they will be run in order</code>
|
1079
|
+
</li>
|
1080
|
+
|
1081
|
+
<li class="covered" data-hits="30" data-linenumber="32">
|
1082
|
+
<span class="hits">30</span>
|
1083
|
+
|
1084
|
+
<code class="ruby"> coercions.each do |c|</code>
|
1085
|
+
</li>
|
1086
|
+
|
1087
|
+
<li class="covered" data-hits="32" data-linenumber="33">
|
1088
|
+
<span class="hits">32</span>
|
1089
|
+
|
1090
|
+
<code class="ruby"> param = coerce(param, c, validations)</code>
|
1091
|
+
</li>
|
1092
|
+
|
1093
|
+
<li class="never" data-hits="" data-linenumber="34">
|
1094
|
+
|
1095
|
+
|
1096
|
+
<code class="ruby"> end</code>
|
1097
|
+
</li>
|
1098
|
+
|
1099
|
+
<li class="never" data-hits="" data-linenumber="35">
|
1100
|
+
|
1101
|
+
|
1102
|
+
<code class="ruby"></code>
|
1103
|
+
</li>
|
1104
|
+
|
1105
|
+
<li class="covered" data-hits="30" data-linenumber="36">
|
1106
|
+
<span class="hits">30</span>
|
1107
|
+
|
1108
|
+
<code class="ruby"> if param.is_a?(Hash)</code>
|
1109
|
+
</li>
|
1110
|
+
|
1111
|
+
<li class="covered" data-hits="2" data-linenumber="37">
|
1112
|
+
<span class="hits">2</span>
|
1113
|
+
|
1114
|
+
<code class="ruby"> param = if block_given?</code>
|
1115
|
+
</li>
|
1116
|
+
|
1117
|
+
<li class="covered" data-hits="1" data-linenumber="38">
|
1118
|
+
<span class="hits">1</span>
|
1119
|
+
|
1120
|
+
<code class="ruby"> HashParams::HashValidator.new.validate_hash(param, validations, &Proc.new)</code>
|
1121
|
+
</li>
|
1122
|
+
|
1123
|
+
<li class="never" data-hits="" data-linenumber="39">
|
1124
|
+
|
1125
|
+
|
1126
|
+
<code class="ruby"> else</code>
|
1127
|
+
</li>
|
1128
|
+
|
1129
|
+
<li class="covered" data-hits="1" data-linenumber="40">
|
1130
|
+
<span class="hits">1</span>
|
1131
|
+
|
1132
|
+
<code class="ruby"> HashParams::HashValidator.new.validate_hash(param, validations)</code>
|
1133
|
+
</li>
|
1134
|
+
|
1135
|
+
<li class="never" data-hits="" data-linenumber="41">
|
1136
|
+
|
1137
|
+
|
1138
|
+
<code class="ruby"> end</code>
|
1139
|
+
</li>
|
1140
|
+
|
1141
|
+
<li class="never" data-hits="" data-linenumber="42">
|
1142
|
+
|
1143
|
+
|
1144
|
+
<code class="ruby"> end</code>
|
1145
|
+
</li>
|
1146
|
+
|
1147
|
+
<li class="never" data-hits="" data-linenumber="43">
|
1148
|
+
|
1149
|
+
|
1150
|
+
<code class="ruby"></code>
|
1151
|
+
</li>
|
1152
|
+
|
1153
|
+
<li class="never" data-hits="" data-linenumber="44">
|
1154
|
+
|
1155
|
+
|
1156
|
+
<code class="ruby"> #don't bother with the rest if required parameter is missing</code>
|
1157
|
+
</li>
|
1158
|
+
|
1159
|
+
<li class="covered" data-hits="30" data-linenumber="45">
|
1160
|
+
<span class="hits">30</span>
|
1161
|
+
|
1162
|
+
<code class="ruby"> if validations[:required] && param.nil?</code>
|
1163
|
+
</li>
|
1164
|
+
|
1165
|
+
<li class="covered" data-hits="2" data-linenumber="46">
|
1166
|
+
<span class="hits">2</span>
|
1167
|
+
|
1168
|
+
<code class="ruby"> raise ValidationError.new('Required Parameter missing and has no default specified')</code>
|
1169
|
+
</li>
|
1170
|
+
|
1171
|
+
<li class="never" data-hits="" data-linenumber="47">
|
1172
|
+
|
1173
|
+
|
1174
|
+
<code class="ruby"> end</code>
|
1175
|
+
</li>
|
1176
|
+
|
1177
|
+
<li class="never" data-hits="" data-linenumber="48">
|
1178
|
+
|
1179
|
+
|
1180
|
+
<code class="ruby"></code>
|
1181
|
+
</li>
|
1182
|
+
|
1183
|
+
<li class="covered" data-hits="28" data-linenumber="49">
|
1184
|
+
<span class="hits">28</span>
|
1185
|
+
|
1186
|
+
<code class="ruby"> error = nil</code>
|
1187
|
+
</li>
|
1188
|
+
|
1189
|
+
<li class="covered" data-hits="28" data-linenumber="50">
|
1190
|
+
<span class="hits">28</span>
|
1191
|
+
|
1192
|
+
<code class="ruby"> validations.each do |key, value|</code>
|
1193
|
+
</li>
|
1194
|
+
|
1195
|
+
<li class="covered" data-hits="23" data-linenumber="51">
|
1196
|
+
<span class="hits">23</span>
|
1197
|
+
|
1198
|
+
<code class="ruby"> error = case key</code>
|
1199
|
+
</li>
|
1200
|
+
|
1201
|
+
<li class="never" data-hits="" data-linenumber="52">
|
1202
|
+
|
1203
|
+
|
1204
|
+
<code class="ruby"> when :blank</code>
|
1205
|
+
</li>
|
1206
|
+
|
1207
|
+
<li class="missed" data-hits="0" data-linenumber="53">
|
1208
|
+
|
1209
|
+
|
1210
|
+
<code class="ruby"> 'Parameter cannot be blank' if !value && (param.nil? || (param.respond_to?(:empty) && param.empty)) #)!value && blank?(value)</code>
|
1211
|
+
</li>
|
1212
|
+
|
1213
|
+
<li class="never" data-hits="" data-linenumber="54">
|
1214
|
+
|
1215
|
+
|
1216
|
+
<code class="ruby"> when :format</code>
|
1217
|
+
</li>
|
1218
|
+
|
1219
|
+
<li class="covered" data-hits="2" data-linenumber="55">
|
1220
|
+
<span class="hits">2</span>
|
1221
|
+
|
1222
|
+
<code class="ruby"> "#{param} must be a string if using the format validation" && next unless param.kind_of?(String)</code>
|
1223
|
+
</li>
|
1224
|
+
|
1225
|
+
<li class="covered" data-hits="2" data-linenumber="56">
|
1226
|
+
<span class="hits">2</span>
|
1227
|
+
|
1228
|
+
<code class="ruby"> "#{param} must match format #{value}" unless param =~ value</code>
|
1229
|
+
</li>
|
1230
|
+
|
1231
|
+
<li class="never" data-hits="" data-linenumber="57">
|
1232
|
+
|
1233
|
+
|
1234
|
+
<code class="ruby"> when :is</code>
|
1235
|
+
</li>
|
1236
|
+
|
1237
|
+
<li class="covered" data-hits="1" data-linenumber="58">
|
1238
|
+
<span class="hits">1</span>
|
1239
|
+
|
1240
|
+
<code class="ruby"> "#{param} must be #{value}" unless param === value</code>
|
1241
|
+
</li>
|
1242
|
+
|
1243
|
+
<li class="never" data-hits="" data-linenumber="59">
|
1244
|
+
|
1245
|
+
|
1246
|
+
<code class="ruby"> when :in, :within, :range</code>
|
1247
|
+
</li>
|
1248
|
+
|
1249
|
+
<li class="covered" data-hits="1" data-linenumber="60">
|
1250
|
+
<span class="hits">1</span>
|
1251
|
+
|
1252
|
+
<code class="ruby"> "#{param} must be within #{value}" unless value.respond_to?(:include) ? value.include?(param) : Array(value).include?(param)</code>
|
1253
|
+
</li>
|
1254
|
+
|
1255
|
+
<li class="never" data-hits="" data-linenumber="61">
|
1256
|
+
|
1257
|
+
|
1258
|
+
<code class="ruby"> when :min</code>
|
1259
|
+
</li>
|
1260
|
+
|
1261
|
+
<li class="covered" data-hits="2" data-linenumber="62">
|
1262
|
+
<span class="hits">2</span>
|
1263
|
+
|
1264
|
+
<code class="ruby"> "#{param} cannot be less than #{value}" unless value <= param</code>
|
1265
|
+
</li>
|
1266
|
+
|
1267
|
+
<li class="never" data-hits="" data-linenumber="63">
|
1268
|
+
|
1269
|
+
|
1270
|
+
<code class="ruby"> when :max</code>
|
1271
|
+
</li>
|
1272
|
+
|
1273
|
+
<li class="covered" data-hits="2" data-linenumber="64">
|
1274
|
+
<span class="hits">2</span>
|
1275
|
+
|
1276
|
+
<code class="ruby"> "#{param} cannot be greater than #{value}" unless value >= param</code>
|
1277
|
+
</li>
|
1278
|
+
|
1279
|
+
<li class="never" data-hits="" data-linenumber="65">
|
1280
|
+
|
1281
|
+
|
1282
|
+
<code class="ruby"> when :min_length</code>
|
1283
|
+
</li>
|
1284
|
+
|
1285
|
+
<li class="covered" data-hits="2" data-linenumber="66">
|
1286
|
+
<span class="hits">2</span>
|
1287
|
+
|
1288
|
+
<code class="ruby"> "#{param} cannot have length less than #{value}" unless value <= param.length</code>
|
1289
|
+
</li>
|
1290
|
+
|
1291
|
+
<li class="never" data-hits="" data-linenumber="67">
|
1292
|
+
|
1293
|
+
|
1294
|
+
<code class="ruby"> when :max_length</code>
|
1295
|
+
</li>
|
1296
|
+
|
1297
|
+
<li class="covered" data-hits="2" data-linenumber="68">
|
1298
|
+
<span class="hits">2</span>
|
1299
|
+
|
1300
|
+
<code class="ruby"> "#{param} cannot have length greater than #{value}" unless value >= param.length</code>
|
1301
|
+
</li>
|
1302
|
+
|
1303
|
+
<li class="never" data-hits="" data-linenumber="69">
|
1304
|
+
|
1305
|
+
|
1306
|
+
<code class="ruby"> else</code>
|
1307
|
+
</li>
|
1308
|
+
|
1309
|
+
<li class="covered" data-hits="11" data-linenumber="70">
|
1310
|
+
<span class="hits">11</span>
|
1311
|
+
|
1312
|
+
<code class="ruby"> nil</code>
|
1313
|
+
</li>
|
1314
|
+
|
1315
|
+
<li class="never" data-hits="" data-linenumber="71">
|
1316
|
+
|
1317
|
+
|
1318
|
+
<code class="ruby"> end</code>
|
1319
|
+
</li>
|
1320
|
+
|
1321
|
+
<li class="never" data-hits="" data-linenumber="72">
|
1322
|
+
|
1323
|
+
|
1324
|
+
<code class="ruby"> end</code>
|
1325
|
+
</li>
|
1326
|
+
|
1327
|
+
<li class="never" data-hits="" data-linenumber="73">
|
1328
|
+
|
1329
|
+
|
1330
|
+
<code class="ruby"></code>
|
1331
|
+
</li>
|
1332
|
+
|
1333
|
+
<li class="covered" data-hits="28" data-linenumber="74">
|
1334
|
+
<span class="hits">28</span>
|
1335
|
+
|
1336
|
+
<code class="ruby"> raise ValidationError.new(error) if error</code>
|
1337
|
+
</li>
|
1338
|
+
|
1339
|
+
<li class="covered" data-hits="28" data-linenumber="75">
|
1340
|
+
<span class="hits">28</span>
|
1341
|
+
|
1342
|
+
<code class="ruby"> param</code>
|
1343
|
+
</li>
|
1344
|
+
|
1345
|
+
<li class="never" data-hits="" data-linenumber="76">
|
1346
|
+
|
1347
|
+
|
1348
|
+
<code class="ruby"> end</code>
|
1349
|
+
</li>
|
1350
|
+
|
1351
|
+
<li class="never" data-hits="" data-linenumber="77">
|
1352
|
+
|
1353
|
+
|
1354
|
+
<code class="ruby"></code>
|
1355
|
+
</li>
|
1356
|
+
|
1357
|
+
<li class="covered" data-hits="1" data-linenumber="78">
|
1358
|
+
<span class="hits">1</span>
|
1359
|
+
|
1360
|
+
<code class="ruby"> private</code>
|
1361
|
+
</li>
|
1362
|
+
|
1363
|
+
<li class="never" data-hits="" data-linenumber="79">
|
1364
|
+
|
1365
|
+
|
1366
|
+
<code class="ruby"></code>
|
1367
|
+
</li>
|
1368
|
+
|
1369
|
+
<li class="covered" data-hits="1" data-linenumber="80">
|
1370
|
+
<span class="hits">1</span>
|
1371
|
+
|
1372
|
+
<code class="ruby"> def coerce(val, type, opts={})</code>
|
1373
|
+
</li>
|
1374
|
+
|
1375
|
+
<li class="never" data-hits="" data-linenumber="81">
|
1376
|
+
|
1377
|
+
|
1378
|
+
<code class="ruby"></code>
|
1379
|
+
</li>
|
1380
|
+
|
1381
|
+
<li class="never" data-hits="" data-linenumber="82">
|
1382
|
+
|
1383
|
+
|
1384
|
+
<code class="ruby"> # exceptions bubble up</code>
|
1385
|
+
</li>
|
1386
|
+
|
1387
|
+
<li class="never" data-hits="" data-linenumber="83">
|
1388
|
+
|
1389
|
+
|
1390
|
+
<code class="ruby"> #order is important</code>
|
1391
|
+
</li>
|
1392
|
+
|
1393
|
+
<li class="never" data-hits="" data-linenumber="84">
|
1394
|
+
|
1395
|
+
|
1396
|
+
<code class="ruby"></code>
|
1397
|
+
</li>
|
1398
|
+
|
1399
|
+
<li class="never" data-hits="" data-linenumber="85">
|
1400
|
+
|
1401
|
+
|
1402
|
+
<code class="ruby"> #if type is nil just return the object</code>
|
1403
|
+
</li>
|
1404
|
+
|
1405
|
+
<li class="covered" data-hits="32" data-linenumber="86">
|
1406
|
+
<span class="hits">32</span>
|
1407
|
+
|
1408
|
+
<code class="ruby"> return val if type.nil?</code>
|
1409
|
+
</li>
|
1410
|
+
|
1411
|
+
<li class="never" data-hits="" data-linenumber="87">
|
1412
|
+
|
1413
|
+
|
1414
|
+
<code class="ruby"></code>
|
1415
|
+
</li>
|
1416
|
+
|
1417
|
+
<li class="never" data-hits="" data-linenumber="88">
|
1418
|
+
|
1419
|
+
|
1420
|
+
<code class="ruby"> #two special types of transforms</code>
|
1421
|
+
</li>
|
1422
|
+
|
1423
|
+
<li class="never" data-hits="" data-linenumber="89">
|
1424
|
+
|
1425
|
+
|
1426
|
+
<code class="ruby"> #There is no Boolean type so we handle them special</code>
|
1427
|
+
</li>
|
1428
|
+
|
1429
|
+
<li class="covered" data-hits="30" data-linenumber="90">
|
1430
|
+
<span class="hits">30</span>
|
1431
|
+
|
1432
|
+
<code class="ruby"> if type.to_s == 'boolean'</code>
|
1433
|
+
</li>
|
1434
|
+
|
1435
|
+
<li class="covered" data-hits="11" data-linenumber="91">
|
1436
|
+
<span class="hits">11</span>
|
1437
|
+
|
1438
|
+
<code class="ruby"> return val if (val == true || val == false)</code>
|
1439
|
+
</li>
|
1440
|
+
|
1441
|
+
<li class="covered" data-hits="10" data-linenumber="92">
|
1442
|
+
<span class="hits">10</span>
|
1443
|
+
|
1444
|
+
<code class="ruby"> return false if /(false|f|no|n|0)$/i === val.to_s.downcase</code>
|
1445
|
+
</li>
|
1446
|
+
|
1447
|
+
<li class="covered" data-hits="5" data-linenumber="93">
|
1448
|
+
<span class="hits">5</span>
|
1449
|
+
|
1450
|
+
<code class="ruby"> return true if /(true|t|yes|y|1)$/i === val.to_s.downcase</code>
|
1451
|
+
</li>
|
1452
|
+
|
1453
|
+
<li class="never" data-hits="" data-linenumber="94">
|
1454
|
+
|
1455
|
+
|
1456
|
+
<code class="ruby"></code>
|
1457
|
+
</li>
|
1458
|
+
|
1459
|
+
<li class="never" data-hits="" data-linenumber="95">
|
1460
|
+
|
1461
|
+
|
1462
|
+
<code class="ruby"> # if we can't parse we return a nil</code>
|
1463
|
+
</li>
|
1464
|
+
|
1465
|
+
<li class="never" data-hits="" data-linenumber="96">
|
1466
|
+
|
1467
|
+
|
1468
|
+
<code class="ruby"> # maybe !!val is a better return?</code>
|
1469
|
+
</li>
|
1470
|
+
|
1471
|
+
<li class="missed" data-hits="0" data-linenumber="97">
|
1472
|
+
|
1473
|
+
|
1474
|
+
<code class="ruby"> raise CoercionError.new("Unable to coerce #{val} to boolean")</code>
|
1475
|
+
</li>
|
1476
|
+
|
1477
|
+
<li class="never" data-hits="" data-linenumber="98">
|
1478
|
+
|
1479
|
+
|
1480
|
+
<code class="ruby"> end</code>
|
1481
|
+
</li>
|
1482
|
+
|
1483
|
+
<li class="never" data-hits="" data-linenumber="99">
|
1484
|
+
|
1485
|
+
|
1486
|
+
<code class="ruby"> #they have given us a coercion which is a string or symbol which is not "boolean", we are going to cast this into a proc and run it</code>
|
1487
|
+
</li>
|
1488
|
+
|
1489
|
+
<li class="never" data-hits="" data-linenumber="100">
|
1490
|
+
|
1491
|
+
|
1492
|
+
<code class="ruby"></code>
|
1493
|
+
</li>
|
1494
|
+
|
1495
|
+
<li class="covered" data-hits="19" data-linenumber="101">
|
1496
|
+
<span class="hits">19</span>
|
1497
|
+
|
1498
|
+
<code class="ruby"> return type.to_proc.call(val) if type.is_a?(Symbol) || type.is_a?(String)</code>
|
1499
|
+
</li>
|
1500
|
+
|
1501
|
+
<li class="never" data-hits="" data-linenumber="102">
|
1502
|
+
|
1503
|
+
|
1504
|
+
<code class="ruby"> #could be a proc</code>
|
1505
|
+
</li>
|
1506
|
+
|
1507
|
+
<li class="never" data-hits="" data-linenumber="103">
|
1508
|
+
|
1509
|
+
|
1510
|
+
<code class="ruby"></code>
|
1511
|
+
</li>
|
1512
|
+
|
1513
|
+
<li class="covered" data-hits="17" data-linenumber="104">
|
1514
|
+
<span class="hits">17</span>
|
1515
|
+
|
1516
|
+
<code class="ruby"> return type.call(val) if type.respond_to?(:call)</code>
|
1517
|
+
</li>
|
1518
|
+
|
1519
|
+
<li class="never" data-hits="" data-linenumber="105">
|
1520
|
+
|
1521
|
+
|
1522
|
+
<code class="ruby"> #nothing but simple types left</code>
|
1523
|
+
</li>
|
1524
|
+
|
1525
|
+
<li class="covered" data-hits="16" data-linenumber="106">
|
1526
|
+
<span class="hits">16</span>
|
1527
|
+
|
1528
|
+
<code class="ruby"> return val if val.is_a?(type)</code>
|
1529
|
+
</li>
|
1530
|
+
|
1531
|
+
<li class="covered" data-hits="5" data-linenumber="107">
|
1532
|
+
<span class="hits">5</span>
|
1533
|
+
|
1534
|
+
<code class="ruby"> return Integer(val) if type == Integer</code>
|
1535
|
+
</li>
|
1536
|
+
|
1537
|
+
<li class="covered" data-hits="4" data-linenumber="108">
|
1538
|
+
<span class="hits">4</span>
|
1539
|
+
|
1540
|
+
<code class="ruby"> return Float(val) if type == Float</code>
|
1541
|
+
</li>
|
1542
|
+
|
1543
|
+
<li class="covered" data-hits="3" data-linenumber="109">
|
1544
|
+
<span class="hits">3</span>
|
1545
|
+
|
1546
|
+
<code class="ruby"> return String(val) if type == String</code>
|
1547
|
+
</li>
|
1548
|
+
|
1549
|
+
<li class="covered" data-hits="2" data-linenumber="110">
|
1550
|
+
<span class="hits">2</span>
|
1551
|
+
|
1552
|
+
<code class="ruby"> return Date.parse(val) if type == Date</code>
|
1553
|
+
</li>
|
1554
|
+
|
1555
|
+
<li class="covered" data-hits="2" data-linenumber="111">
|
1556
|
+
<span class="hits">2</span>
|
1557
|
+
|
1558
|
+
<code class="ruby"> return Time.parse(val) if type == Time</code>
|
1559
|
+
</li>
|
1560
|
+
|
1561
|
+
<li class="covered" data-hits="2" data-linenumber="112">
|
1562
|
+
<span class="hits">2</span>
|
1563
|
+
|
1564
|
+
<code class="ruby"> return DateTime.parse(val) if type == DateTime</code>
|
1565
|
+
</li>
|
1566
|
+
|
1567
|
+
<li class="covered" data-hits="2" data-linenumber="113">
|
1568
|
+
<span class="hits">2</span>
|
1569
|
+
|
1570
|
+
<code class="ruby"> return Array(val.split(opts[:delimiter] || ',')) if type == Array</code>
|
1571
|
+
</li>
|
1572
|
+
|
1573
|
+
<li class="covered" data-hits="10" data-linenumber="114">
|
1574
|
+
<span class="hits">10</span>
|
1575
|
+
|
1576
|
+
<code class="ruby"> return Hash[val.gsub(/[{}]/, '').gsub('}', '').split(opts[:delimiter] || ',').map { |c| c.split(opts[:separator] ||':').map { |i| i.strip } }] if type == Hash</code>
|
1577
|
+
</li>
|
1578
|
+
|
1579
|
+
<li class="never" data-hits="" data-linenumber="115">
|
1580
|
+
|
1581
|
+
|
1582
|
+
<code class="ruby"></code>
|
1583
|
+
</li>
|
1584
|
+
|
1585
|
+
<li class="missed" data-hits="0" data-linenumber="116">
|
1586
|
+
|
1587
|
+
|
1588
|
+
<code class="ruby"> raise CoercionError("Unable to coerce #{val} to #{type}")</code>
|
1589
|
+
</li>
|
1590
|
+
|
1591
|
+
<li class="never" data-hits="" data-linenumber="117">
|
1592
|
+
|
1593
|
+
|
1594
|
+
<code class="ruby"> end</code>
|
1595
|
+
</li>
|
1596
|
+
|
1597
|
+
<li class="never" data-hits="" data-linenumber="118">
|
1598
|
+
|
1599
|
+
|
1600
|
+
<code class="ruby"> end</code>
|
1601
|
+
</li>
|
1602
|
+
|
1603
|
+
<li class="never" data-hits="" data-linenumber="119">
|
1604
|
+
|
1605
|
+
|
1606
|
+
<code class="ruby">end</code>
|
1607
|
+
</li>
|
1608
|
+
|
1609
|
+
</ol>
|
1610
|
+
</pre>
|
1611
|
+
</div>
|
1612
|
+
|
1613
|
+
<div class="source_table" id="abb09c4ec783968d5f7a1a3adac854712f21ee1e">
|
1614
|
+
<div class="header">
|
1615
|
+
<h3>lib/hash_params/yaml_params.rb</h3>
|
1616
|
+
<h4><span class="red">12.5 %</span> covered</h4>
|
1617
|
+
<div>
|
1618
|
+
<b>40</b> relevant lines.
|
1619
|
+
<span class="green"><b>5</b> lines covered</span> and
|
1620
|
+
<span class="red"><b>35</b> lines missed.</span>
|
1621
|
+
</div>
|
1622
|
+
</div>
|
1623
|
+
|
1624
|
+
<pre>
|
1625
|
+
<ol>
|
1626
|
+
|
1627
|
+
<li class="covered" data-hits="1" data-linenumber="1">
|
1628
|
+
<span class="hits">1</span>
|
1629
|
+
|
1630
|
+
<code class="ruby">module YamlParams</code>
|
1631
|
+
</li>
|
1632
|
+
|
1633
|
+
<li class="never" data-hits="" data-linenumber="2">
|
1634
|
+
|
1635
|
+
|
1636
|
+
<code class="ruby"></code>
|
1637
|
+
</li>
|
1638
|
+
|
1639
|
+
<li class="covered" data-hits="1" data-linenumber="3">
|
1640
|
+
<span class="hits">1</span>
|
1641
|
+
|
1642
|
+
<code class="ruby"> ENVIRONMENT = ENV['YAML_PARAMS_ENV'] || (defined?(HashParams) && HashParams::ENVIRONMENT) || 'development'</code>
|
1643
|
+
</li>
|
1644
|
+
|
1645
|
+
<li class="never" data-hits="" data-linenumber="4">
|
1646
|
+
|
1647
|
+
|
1648
|
+
<code class="ruby"></code>
|
1649
|
+
</li>
|
1650
|
+
|
1651
|
+
<li class="covered" data-hits="1" data-linenumber="5">
|
1652
|
+
<span class="hits">1</span>
|
1653
|
+
|
1654
|
+
<code class="ruby"> def self.autoconfig(opts={})</code>
|
1655
|
+
</li>
|
1656
|
+
|
1657
|
+
<li class="never" data-hits="" data-linenumber="6">
|
1658
|
+
|
1659
|
+
|
1660
|
+
<code class="ruby"></code>
|
1661
|
+
</li>
|
1662
|
+
|
1663
|
+
<li class="missed" data-hits="0" data-linenumber="7">
|
1664
|
+
|
1665
|
+
|
1666
|
+
<code class="ruby"> script_name = File.basename($0)</code>
|
1667
|
+
</li>
|
1668
|
+
|
1669
|
+
<li class="missed" data-hits="0" data-linenumber="8">
|
1670
|
+
|
1671
|
+
|
1672
|
+
<code class="ruby"> script_dir = File.dirname($0)</code>
|
1673
|
+
</li>
|
1674
|
+
|
1675
|
+
<li class="missed" data-hits="0" data-linenumber="9">
|
1676
|
+
|
1677
|
+
|
1678
|
+
<code class="ruby"> home_dir = File.expand_path('~')</code>
|
1679
|
+
</li>
|
1680
|
+
|
1681
|
+
<li class="missed" data-hits="0" data-linenumber="10">
|
1682
|
+
|
1683
|
+
|
1684
|
+
<code class="ruby"> host_name = Socket.gethostname</code>
|
1685
|
+
</li>
|
1686
|
+
|
1687
|
+
<li class="missed" data-hits="0" data-linenumber="11">
|
1688
|
+
|
1689
|
+
|
1690
|
+
<code class="ruby"> special_file_names = opts.delete(:files)</code>
|
1691
|
+
</li>
|
1692
|
+
|
1693
|
+
<li class="missed" data-hits="0" data-linenumber="12">
|
1694
|
+
|
1695
|
+
|
1696
|
+
<code class="ruby"> special_file_names = Array(special_file_names && special_file_names.is_a?(String) && special_file_names.split(','))</code>
|
1697
|
+
</li>
|
1698
|
+
|
1699
|
+
<li class="missed" data-hits="0" data-linenumber="13">
|
1700
|
+
|
1701
|
+
|
1702
|
+
<code class="ruby"> special_roots = opts.delete(:roots)</code>
|
1703
|
+
</li>
|
1704
|
+
|
1705
|
+
<li class="missed" data-hits="0" data-linenumber="14">
|
1706
|
+
|
1707
|
+
|
1708
|
+
<code class="ruby"> special_roots = Array(special_roots && special_roots.is_a?(String) && special_roots.split(','))</code>
|
1709
|
+
</li>
|
1710
|
+
|
1711
|
+
<li class="missed" data-hits="0" data-linenumber="15">
|
1712
|
+
|
1713
|
+
|
1714
|
+
<code class="ruby"> app_name = opts.delete(:app_name) || script_name</code>
|
1715
|
+
</li>
|
1716
|
+
|
1717
|
+
<li class="missed" data-hits="0" data-linenumber="16">
|
1718
|
+
|
1719
|
+
|
1720
|
+
<code class="ruby"> env = opts.delete(:env) || opts.delete(:environment) || ENVIRONMENT</code>
|
1721
|
+
</li>
|
1722
|
+
|
1723
|
+
<li class="missed" data-hits="0" data-linenumber="17">
|
1724
|
+
|
1725
|
+
|
1726
|
+
<code class="ruby"> generated_hash = {}</code>
|
1727
|
+
</li>
|
1728
|
+
|
1729
|
+
<li class="missed" data-hits="0" data-linenumber="18">
|
1730
|
+
|
1731
|
+
|
1732
|
+
<code class="ruby"> all_file_names = []</code>
|
1733
|
+
</li>
|
1734
|
+
|
1735
|
+
<li class="never" data-hits="" data-linenumber="19">
|
1736
|
+
|
1737
|
+
|
1738
|
+
<code class="ruby"></code>
|
1739
|
+
</li>
|
1740
|
+
|
1741
|
+
<li class="never" data-hits="" data-linenumber="20">
|
1742
|
+
|
1743
|
+
|
1744
|
+
<code class="ruby"></code>
|
1745
|
+
</li>
|
1746
|
+
|
1747
|
+
<li class="never" data-hits="" data-linenumber="21">
|
1748
|
+
|
1749
|
+
|
1750
|
+
<code class="ruby"> #Sequence is important when constructing this list as later files will override the earlier ones</code>
|
1751
|
+
</li>
|
1752
|
+
|
1753
|
+
<li class="missed" data-hits="0" data-linenumber="22">
|
1754
|
+
|
1755
|
+
|
1756
|
+
<code class="ruby"> generic_file_names = %W(</code>
|
1757
|
+
</li>
|
1758
|
+
|
1759
|
+
<li class="never" data-hits="" data-linenumber="23">
|
1760
|
+
|
1761
|
+
|
1762
|
+
<code class="ruby"> settings.yml</code>
|
1763
|
+
</li>
|
1764
|
+
|
1765
|
+
<li class="never" data-hits="" data-linenumber="24">
|
1766
|
+
|
1767
|
+
|
1768
|
+
<code class="ruby"> config.yml</code>
|
1769
|
+
</li>
|
1770
|
+
|
1771
|
+
<li class="never" data-hits="" data-linenumber="25">
|
1772
|
+
|
1773
|
+
|
1774
|
+
<code class="ruby"> default.yml</code>
|
1775
|
+
</li>
|
1776
|
+
|
1777
|
+
<li class="never" data-hits="" data-linenumber="26">
|
1778
|
+
|
1779
|
+
|
1780
|
+
<code class="ruby"> #{env}.yml</code>
|
1781
|
+
</li>
|
1782
|
+
|
1783
|
+
<li class="never" data-hits="" data-linenumber="27">
|
1784
|
+
|
1785
|
+
|
1786
|
+
<code class="ruby"> #{host_name}.yml</code>
|
1787
|
+
</li>
|
1788
|
+
|
1789
|
+
<li class="never" data-hits="" data-linenumber="28">
|
1790
|
+
|
1791
|
+
|
1792
|
+
<code class="ruby"> #{host_name}_#{env}.yml</code>
|
1793
|
+
</li>
|
1794
|
+
|
1795
|
+
<li class="never" data-hits="" data-linenumber="29">
|
1796
|
+
|
1797
|
+
|
1798
|
+
<code class="ruby"> local.yml</code>
|
1799
|
+
</li>
|
1800
|
+
|
1801
|
+
<li class="never" data-hits="" data-linenumber="30">
|
1802
|
+
|
1803
|
+
|
1804
|
+
<code class="ruby"> local_#{env}.yml</code>
|
1805
|
+
</li>
|
1806
|
+
|
1807
|
+
<li class="never" data-hits="" data-linenumber="31">
|
1808
|
+
|
1809
|
+
|
1810
|
+
<code class="ruby"> settings.local.yml</code>
|
1811
|
+
</li>
|
1812
|
+
|
1813
|
+
<li class="never" data-hits="" data-linenumber="32">
|
1814
|
+
|
1815
|
+
|
1816
|
+
<code class="ruby"> settings.local_#{env}.yml</code>
|
1817
|
+
</li>
|
1818
|
+
|
1819
|
+
<li class="never" data-hits="" data-linenumber="33">
|
1820
|
+
|
1821
|
+
|
1822
|
+
<code class="ruby"> config.local.yml</code>
|
1823
|
+
</li>
|
1824
|
+
|
1825
|
+
<li class="never" data-hits="" data-linenumber="34">
|
1826
|
+
|
1827
|
+
|
1828
|
+
<code class="ruby"> config.local_#{env}.yml</code>
|
1829
|
+
</li>
|
1830
|
+
|
1831
|
+
<li class="never" data-hits="" data-linenumber="35">
|
1832
|
+
|
1833
|
+
|
1834
|
+
<code class="ruby"> )</code>
|
1835
|
+
</li>
|
1836
|
+
|
1837
|
+
<li class="never" data-hits="" data-linenumber="36">
|
1838
|
+
|
1839
|
+
|
1840
|
+
<code class="ruby"> #prepend the app name to the default file names</code>
|
1841
|
+
</li>
|
1842
|
+
|
1843
|
+
<li class="missed" data-hits="0" data-linenumber="37">
|
1844
|
+
|
1845
|
+
|
1846
|
+
<code class="ruby"> app_file_names = generic_file_names.map { |f| "#{app_name}_#{f}" }</code>
|
1847
|
+
</li>
|
1848
|
+
|
1849
|
+
<li class="never" data-hits="" data-linenumber="38">
|
1850
|
+
|
1851
|
+
|
1852
|
+
<code class="ruby"></code>
|
1853
|
+
</li>
|
1854
|
+
|
1855
|
+
<li class="missed" data-hits="0" data-linenumber="39">
|
1856
|
+
|
1857
|
+
|
1858
|
+
<code class="ruby"> default_roots = [</code>
|
1859
|
+
</li>
|
1860
|
+
|
1861
|
+
<li class="never" data-hits="" data-linenumber="40">
|
1862
|
+
|
1863
|
+
|
1864
|
+
<code class="ruby"> script_dir,</code>
|
1865
|
+
</li>
|
1866
|
+
|
1867
|
+
<li class="never" data-hits="" data-linenumber="41">
|
1868
|
+
|
1869
|
+
|
1870
|
+
<code class="ruby"> File.join('/etc', app_name.to_s),</code>
|
1871
|
+
</li>
|
1872
|
+
|
1873
|
+
<li class="never" data-hits="" data-linenumber="42">
|
1874
|
+
|
1875
|
+
|
1876
|
+
<code class="ruby"> File.join('/usr', 'local', 'etc', app_name.to_s),</code>
|
1877
|
+
</li>
|
1878
|
+
|
1879
|
+
<li class="never" data-hits="" data-linenumber="43">
|
1880
|
+
|
1881
|
+
|
1882
|
+
<code class="ruby"> File.join(home_dir, 'etc', app_name.to_s),</code>
|
1883
|
+
</li>
|
1884
|
+
|
1885
|
+
<li class="never" data-hits="" data-linenumber="44">
|
1886
|
+
|
1887
|
+
|
1888
|
+
<code class="ruby"> File.join(home_dir, ".#{app_name}"),</code>
|
1889
|
+
</li>
|
1890
|
+
|
1891
|
+
<li class="never" data-hits="" data-linenumber="45">
|
1892
|
+
|
1893
|
+
|
1894
|
+
<code class="ruby"> File.join(home_dir, '.hash_params', app_name.to_s),</code>
|
1895
|
+
</li>
|
1896
|
+
|
1897
|
+
<li class="never" data-hits="" data-linenumber="46">
|
1898
|
+
|
1899
|
+
|
1900
|
+
<code class="ruby"> File.join(script_dir, 'config'),</code>
|
1901
|
+
</li>
|
1902
|
+
|
1903
|
+
<li class="never" data-hits="" data-linenumber="47">
|
1904
|
+
|
1905
|
+
|
1906
|
+
<code class="ruby"> File.join(script_dir, 'settings')</code>
|
1907
|
+
</li>
|
1908
|
+
|
1909
|
+
<li class="never" data-hits="" data-linenumber="48">
|
1910
|
+
|
1911
|
+
|
1912
|
+
<code class="ruby"> ]</code>
|
1913
|
+
</li>
|
1914
|
+
|
1915
|
+
<li class="missed" data-hits="0" data-linenumber="49">
|
1916
|
+
|
1917
|
+
|
1918
|
+
<code class="ruby"> if defined?(Rails)</code>
|
1919
|
+
</li>
|
1920
|
+
|
1921
|
+
<li class="missed" data-hits="0" data-linenumber="50">
|
1922
|
+
|
1923
|
+
|
1924
|
+
<code class="ruby"> default_roots << Rails.root.join('config')</code>
|
1925
|
+
</li>
|
1926
|
+
|
1927
|
+
<li class="never" data-hits="" data-linenumber="51">
|
1928
|
+
|
1929
|
+
|
1930
|
+
<code class="ruby"> end</code>
|
1931
|
+
</li>
|
1932
|
+
|
1933
|
+
<li class="never" data-hits="" data-linenumber="52">
|
1934
|
+
|
1935
|
+
|
1936
|
+
<code class="ruby"></code>
|
1937
|
+
</li>
|
1938
|
+
|
1939
|
+
<li class="never" data-hits="" data-linenumber="53">
|
1940
|
+
|
1941
|
+
|
1942
|
+
<code class="ruby"></code>
|
1943
|
+
</li>
|
1944
|
+
|
1945
|
+
<li class="never" data-hits="" data-linenumber="54">
|
1946
|
+
|
1947
|
+
|
1948
|
+
<code class="ruby"> #process the /etc/app_name* files</code>
|
1949
|
+
</li>
|
1950
|
+
|
1951
|
+
<li class="missed" data-hits="0" data-linenumber="55">
|
1952
|
+
|
1953
|
+
|
1954
|
+
<code class="ruby"> app_file_names.each do |fname|</code>
|
1955
|
+
</li>
|
1956
|
+
|
1957
|
+
<li class="missed" data-hits="0" data-linenumber="56">
|
1958
|
+
|
1959
|
+
|
1960
|
+
<code class="ruby"> all_file_names << File.join('/etc', fname)</code>
|
1961
|
+
</li>
|
1962
|
+
|
1963
|
+
<li class="never" data-hits="" data-linenumber="57">
|
1964
|
+
|
1965
|
+
|
1966
|
+
<code class="ruby"> end</code>
|
1967
|
+
</li>
|
1968
|
+
|
1969
|
+
<li class="never" data-hits="" data-linenumber="58">
|
1970
|
+
|
1971
|
+
|
1972
|
+
<code class="ruby"> #now process the default roots which will override the above</code>
|
1973
|
+
</li>
|
1974
|
+
|
1975
|
+
<li class="missed" data-hits="0" data-linenumber="59">
|
1976
|
+
|
1977
|
+
|
1978
|
+
<code class="ruby"> (default_roots + special_roots).each do |root|</code>
|
1979
|
+
</li>
|
1980
|
+
|
1981
|
+
<li class="missed" data-hits="0" data-linenumber="60">
|
1982
|
+
|
1983
|
+
|
1984
|
+
<code class="ruby"> (generic_file_names + app_file_names + special_file_names).each do |fname|</code>
|
1985
|
+
</li>
|
1986
|
+
|
1987
|
+
<li class="missed" data-hits="0" data-linenumber="61">
|
1988
|
+
|
1989
|
+
|
1990
|
+
<code class="ruby"> all_file_names << File.join(root, fname)</code>
|
1991
|
+
</li>
|
1992
|
+
|
1993
|
+
<li class="never" data-hits="" data-linenumber="62">
|
1994
|
+
|
1995
|
+
|
1996
|
+
<code class="ruby"> end</code>
|
1997
|
+
</li>
|
1998
|
+
|
1999
|
+
<li class="never" data-hits="" data-linenumber="63">
|
2000
|
+
|
2001
|
+
|
2002
|
+
<code class="ruby"> end</code>
|
2003
|
+
</li>
|
2004
|
+
|
2005
|
+
<li class="never" data-hits="" data-linenumber="64">
|
2006
|
+
|
2007
|
+
|
2008
|
+
<code class="ruby"></code>
|
2009
|
+
</li>
|
2010
|
+
|
2011
|
+
<li class="missed" data-hits="0" data-linenumber="65">
|
2012
|
+
|
2013
|
+
|
2014
|
+
<code class="ruby"> all_file_names.each do |file|</code>
|
2015
|
+
</li>
|
2016
|
+
|
2017
|
+
<li class="missed" data-hits="0" data-linenumber="66">
|
2018
|
+
|
2019
|
+
|
2020
|
+
<code class="ruby"> generated_hash = deep_merge(generated_hash, hash_from_yaml_file(file)) if File.exists?(file)</code>
|
2021
|
+
</li>
|
2022
|
+
|
2023
|
+
<li class="never" data-hits="" data-linenumber="67">
|
2024
|
+
|
2025
|
+
|
2026
|
+
<code class="ruby"> end</code>
|
2027
|
+
</li>
|
2028
|
+
|
2029
|
+
<li class="never" data-hits="" data-linenumber="68">
|
2030
|
+
|
2031
|
+
|
2032
|
+
<code class="ruby"></code>
|
2033
|
+
</li>
|
2034
|
+
|
2035
|
+
<li class="missed" data-hits="0" data-linenumber="69">
|
2036
|
+
|
2037
|
+
|
2038
|
+
<code class="ruby"> if block_given?</code>
|
2039
|
+
</li>
|
2040
|
+
|
2041
|
+
<li class="missed" data-hits="0" data-linenumber="70">
|
2042
|
+
|
2043
|
+
|
2044
|
+
<code class="ruby"> HashParams::HashValidator.new.validate_hash(generated_hash, opts, &Proc.new)</code>
|
2045
|
+
</li>
|
2046
|
+
|
2047
|
+
<li class="never" data-hits="" data-linenumber="71">
|
2048
|
+
|
2049
|
+
|
2050
|
+
<code class="ruby"> else</code>
|
2051
|
+
</li>
|
2052
|
+
|
2053
|
+
<li class="missed" data-hits="0" data-linenumber="72">
|
2054
|
+
|
2055
|
+
|
2056
|
+
<code class="ruby"> HashParams::HashValidator.new.validate_hash(generated_hash, opts)</code>
|
2057
|
+
</li>
|
2058
|
+
|
2059
|
+
<li class="never" data-hits="" data-linenumber="73">
|
2060
|
+
|
2061
|
+
|
2062
|
+
<code class="ruby"> end</code>
|
2063
|
+
</li>
|
2064
|
+
|
2065
|
+
<li class="never" data-hits="" data-linenumber="74">
|
2066
|
+
|
2067
|
+
|
2068
|
+
<code class="ruby"> end</code>
|
2069
|
+
</li>
|
2070
|
+
|
2071
|
+
<li class="never" data-hits="" data-linenumber="75">
|
2072
|
+
|
2073
|
+
|
2074
|
+
<code class="ruby"></code>
|
2075
|
+
</li>
|
2076
|
+
|
2077
|
+
<li class="covered" data-hits="1" data-linenumber="76">
|
2078
|
+
<span class="hits">1</span>
|
2079
|
+
|
2080
|
+
<code class="ruby"> def self.hash_from_yaml_file(filename, env=nil)</code>
|
2081
|
+
</li>
|
2082
|
+
|
2083
|
+
<li class="missed" data-hits="0" data-linenumber="77">
|
2084
|
+
|
2085
|
+
|
2086
|
+
<code class="ruby"> env ||= ENVIRONMENT</code>
|
2087
|
+
</li>
|
2088
|
+
|
2089
|
+
<li class="missed" data-hits="0" data-linenumber="78">
|
2090
|
+
|
2091
|
+
|
2092
|
+
<code class="ruby"> r = File.exists?(filename) ? YAML::load(ERB.new(File.read(filename)).result) : {}</code>
|
2093
|
+
</li>
|
2094
|
+
|
2095
|
+
<li class="missed" data-hits="0" data-linenumber="79">
|
2096
|
+
|
2097
|
+
|
2098
|
+
<code class="ruby"> r[env] || r</code>
|
2099
|
+
</li>
|
2100
|
+
|
2101
|
+
<li class="never" data-hits="" data-linenumber="80">
|
2102
|
+
|
2103
|
+
|
2104
|
+
<code class="ruby"> end</code>
|
2105
|
+
</li>
|
2106
|
+
|
2107
|
+
<li class="never" data-hits="" data-linenumber="81">
|
2108
|
+
|
2109
|
+
|
2110
|
+
<code class="ruby"></code>
|
2111
|
+
</li>
|
2112
|
+
|
2113
|
+
<li class="covered" data-hits="1" data-linenumber="82">
|
2114
|
+
<span class="hits">1</span>
|
2115
|
+
|
2116
|
+
<code class="ruby"> def self.deep_merge(hash, other_hash)</code>
|
2117
|
+
</li>
|
2118
|
+
|
2119
|
+
<li class="missed" data-hits="0" data-linenumber="83">
|
2120
|
+
|
2121
|
+
|
2122
|
+
<code class="ruby"> if other_hash.is_a?(::Hash) && hash.is_a?(::Hash)</code>
|
2123
|
+
</li>
|
2124
|
+
|
2125
|
+
<li class="missed" data-hits="0" data-linenumber="84">
|
2126
|
+
|
2127
|
+
|
2128
|
+
<code class="ruby"> other_hash.each do |k, v|</code>
|
2129
|
+
</li>
|
2130
|
+
|
2131
|
+
<li class="missed" data-hits="0" data-linenumber="85">
|
2132
|
+
|
2133
|
+
|
2134
|
+
<code class="ruby"> hash[k] = hash.key?(k) ? deep_merge(hash[k], v) : v</code>
|
2135
|
+
</li>
|
2136
|
+
|
2137
|
+
<li class="never" data-hits="" data-linenumber="86">
|
2138
|
+
|
2139
|
+
|
2140
|
+
<code class="ruby"> end</code>
|
2141
|
+
</li>
|
2142
|
+
|
2143
|
+
<li class="missed" data-hits="0" data-linenumber="87">
|
2144
|
+
|
2145
|
+
|
2146
|
+
<code class="ruby"> hash</code>
|
2147
|
+
</li>
|
2148
|
+
|
2149
|
+
<li class="never" data-hits="" data-linenumber="88">
|
2150
|
+
|
2151
|
+
|
2152
|
+
<code class="ruby"> else</code>
|
2153
|
+
</li>
|
2154
|
+
|
2155
|
+
<li class="missed" data-hits="0" data-linenumber="89">
|
2156
|
+
|
2157
|
+
|
2158
|
+
<code class="ruby"> other_hash</code>
|
2159
|
+
</li>
|
2160
|
+
|
2161
|
+
<li class="never" data-hits="" data-linenumber="90">
|
2162
|
+
|
2163
|
+
|
2164
|
+
<code class="ruby"> end</code>
|
2165
|
+
</li>
|
2166
|
+
|
2167
|
+
<li class="never" data-hits="" data-linenumber="91">
|
2168
|
+
|
2169
|
+
|
2170
|
+
<code class="ruby"> end</code>
|
2171
|
+
</li>
|
2172
|
+
|
2173
|
+
<li class="never" data-hits="" data-linenumber="92">
|
2174
|
+
|
2175
|
+
|
2176
|
+
<code class="ruby"></code>
|
2177
|
+
</li>
|
2178
|
+
|
2179
|
+
<li class="never" data-hits="" data-linenumber="93">
|
2180
|
+
|
2181
|
+
|
2182
|
+
<code class="ruby">end</code>
|
2183
|
+
</li>
|
2184
|
+
|
2185
|
+
</ol>
|
2186
|
+
</pre>
|
2187
|
+
</div>
|
2188
|
+
|
2189
|
+
</div>
|
2190
|
+
</div>
|
2191
|
+
</body>
|
2192
|
+
</html>
|