env_parser 0.8.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +7 -6
  3. data/.rubocop.yml +56 -57
  4. data/.ruby-version +1 -1
  5. data/Gemfile.lock +58 -28
  6. data/README.md +252 -176
  7. data/docs/EnvParser.html +305 -169
  8. data/docs/EnvParser/AutoregisterFileNotFound.html +143 -0
  9. data/docs/EnvParser/Error.html +9 -9
  10. data/docs/EnvParser/TypeAlreadyDefinedError.html +143 -0
  11. data/docs/EnvParser/Types.html +128 -0
  12. data/docs/EnvParser/Types/BaseTypes.html +177 -0
  13. data/docs/EnvParser/Types/ChronologyTypes.html +159 -0
  14. data/docs/EnvParser/Types/InternetTypes.html +159 -0
  15. data/docs/EnvParser/UnknownTypeError.html +143 -0
  16. data/docs/EnvParser/UnparseableAutoregisterSpec.html +143 -0
  17. data/docs/EnvParser/ValueNotAllowedError.html +143 -0
  18. data/docs/EnvParser/ValueNotConvertibleError.html +143 -0
  19. data/docs/EnvParserTypes.html +129 -0
  20. data/docs/EnvParserTypes/BaseTypes.html +178 -0
  21. data/docs/EnvParserTypes/ChronologyTypes.html +159 -0
  22. data/docs/EnvParserTypes/InternetTypes.html +159 -0
  23. data/docs/EnvParserTypes/TimeTypes.html +158 -0
  24. data/docs/_index.html +108 -9
  25. data/docs/class_list.html +3 -3
  26. data/docs/css/style.css +7 -9
  27. data/docs/file.README.html +215 -226
  28. data/docs/file_list.html +2 -2
  29. data/docs/frames.html +2 -2
  30. data/docs/index.html +215 -226
  31. data/docs/js/app.js +69 -3
  32. data/docs/method_list.html +13 -5
  33. data/docs/top-level-namespace.html +9 -9
  34. data/env_parser.gemspec +6 -2
  35. data/lib/env_parser.rb +111 -83
  36. data/lib/env_parser/autoregister.rb +3 -0
  37. data/lib/env_parser/errors.rb +40 -0
  38. data/lib/env_parser/types.rb +3 -0
  39. data/lib/env_parser/types/base_types.rb +99 -26
  40. data/lib/env_parser/types/chronology_types.rb +104 -0
  41. data/lib/env_parser/types/internet_types.rb +99 -0
  42. data/lib/env_parser/version.rb +1 -1
  43. metadata +85 -10
@@ -6,15 +6,15 @@
6
6
  <title>
7
7
  Class: EnvParser
8
8
 
9
- &mdash; Documentation by YARD 0.9.11
9
+ &mdash; Documentation by YARD 0.9.26
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
14
 
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
16
 
17
- <script type="text/javascript" charset="utf-8">
17
+ <script type="text/javascript">
18
18
  pathId = "EnvParser";
19
19
  relpath = '';
20
20
  </script>
@@ -95,7 +95,7 @@
95
95
  <dl>
96
96
  <dt>Defined in:</dt>
97
97
  <dd>lib/env_parser.rb<span class="defines">,<br />
98
- lib/env_parser/version.rb</span>
98
+ lib/env_parser/errors.rb,<br /> lib/env_parser/version.rb</span>
99
99
  </dd>
100
100
  </dl>
101
101
 
@@ -104,8 +104,7 @@
104
104
  <h2>Overview</h2><div class="docstring">
105
105
  <div class="discussion">
106
106
 
107
- <p>The EnvParser class simplifies parsing of environment variables as
108
- different data types.</p>
107
+ <p>The EnvParser class simplifies parsing of environment variables as different data types.</p>
109
108
 
110
109
 
111
110
  </div>
@@ -117,22 +116,46 @@ different data types.</p>
117
116
  <p class="children">
118
117
 
119
118
 
119
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="EnvParser/Types.html" title="EnvParser::Types (module)">Types</a></span>
120
+
120
121
 
121
122
 
122
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="EnvParser/Error.html" title="EnvParser::Error (class)">Error</a></span>, <span class='object_link'><a href="EnvParser/TypeAlreadyDefined.html" title="EnvParser::TypeAlreadyDefined (class)">TypeAlreadyDefined</a></span>, <span class='object_link'><a href="EnvParser/ValueNotAllowed.html" title="EnvParser::ValueNotAllowed (class)">ValueNotAllowed</a></span>
123
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="EnvParser/AutoregisterFileNotFound.html" title="EnvParser::AutoregisterFileNotFound (class)">AutoregisterFileNotFound</a></span>, <span class='object_link'><a href="EnvParser/Error.html" title="EnvParser::Error (class)">Error</a></span>, <span class='object_link'><a href="EnvParser/TypeAlreadyDefinedError.html" title="EnvParser::TypeAlreadyDefinedError (class)">TypeAlreadyDefinedError</a></span>, <span class='object_link'><a href="EnvParser/UnknownTypeError.html" title="EnvParser::UnknownTypeError (class)">UnknownTypeError</a></span>, <span class='object_link'><a href="EnvParser/UnparseableAutoregisterSpec.html" title="EnvParser::UnparseableAutoregisterSpec (class)">UnparseableAutoregisterSpec</a></span>, <span class='object_link'><a href="EnvParser/ValueNotAllowedError.html" title="EnvParser::ValueNotAllowedError (class)">ValueNotAllowedError</a></span>, <span class='object_link'><a href="EnvParser/ValueNotConvertibleError.html" title="EnvParser::ValueNotConvertibleError (class)">ValueNotConvertibleError</a></span>
123
124
 
124
125
 
125
126
  </p>
126
127
 
127
- <h2>Constant Summary</h2>
128
- <dl class="constants">
129
-
130
- <dt id="VERSION-constant" class="">VERSION =
131
-
132
- </dt>
133
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.8.0</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
128
+
129
+ <h2>
130
+ Constant Summary
131
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
132
+ </h2>
133
+
134
+ <dl class="constants">
135
+
136
+ <dt id="AUTOREGISTER_FILE-constant" class="">AUTOREGISTER_FILE =
137
+ <div class="docstring">
138
+ <div class="discussion">
134
139
 
135
- </dl>
140
+ <p>The default filename to use for <span class='object_link'><a href="#autoregister-class_method" title="EnvParser.autoregister (method)">autoregister</a></span> requests.</p>
141
+
142
+
143
+ </div>
144
+ </div>
145
+ <div class="tags">
146
+
147
+
148
+ </div>
149
+ </dt>
150
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>.env_parser.yml</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
151
+
152
+ <dt id="VERSION-constant" class="">VERSION =
153
+
154
+ </dt>
155
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.3.1</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
156
+
157
+ </dl>
158
+
136
159
 
137
160
 
138
161
 
@@ -166,8 +189,31 @@ different data types.</p>
166
189
 
167
190
 
168
191
  <span class="summary_desc"><div class='inline'>
169
- <p>Creates ENV bindings for EnvParser.parse and EnvParser.register proxy
170
- methods.</p>
192
+ <p>Creates ENV bindings for <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">EnvParser.parse</a></span> and <span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">EnvParser.register</a></span> proxy methods.</p>
193
+ </div></span>
194
+
195
+ </li>
196
+
197
+
198
+ <li class="public ">
199
+ <span class="summary_signature">
200
+
201
+ <a href="#autoregister-class_method" title="autoregister (class method)">.<strong>autoregister</strong>(filename = nil) &#x21d2; Hash </a>
202
+
203
+
204
+
205
+ </span>
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+ <span class="summary_desc"><div class='inline'>
216
+ <p>Reads an “autoregister” file and registers the ENV constants defined therein.</p>
171
217
  </div></span>
172
218
 
173
219
  </li>
@@ -176,7 +222,7 @@ methods.</p>
176
222
  <li class="public ">
177
223
  <span class="summary_signature">
178
224
 
179
- <a href="#define_type-class_method" title="define_type (class method)">.<strong>define_type</strong>(name, options = {}) { ... } &#x21d2; nil </a>
225
+ <a href="#define_type-class_method" title="define_type (class method)">.<strong>define_type</strong>(name, options = {}) {|value| ... } &#x21d2; nil </a>
180
226
 
181
227
 
182
228
 
@@ -191,8 +237,7 @@ methods.</p>
191
237
 
192
238
 
193
239
  <span class="summary_desc"><div class='inline'>
194
- <p>Defines a new type for use as the “as” option on a subsequent
195
- <code>.parse</code> or <code>.register</code> call.</p>
240
+ <p>Defines a new type for use as the “as” option on a subsequent <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">EnvParser.parse</a></span> or <span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">EnvParser.register</a></span> call.</p>
196
241
  </div></span>
197
242
 
198
243
  </li>
@@ -240,8 +285,7 @@ methods.</p>
240
285
 
241
286
 
242
287
  <span class="summary_desc"><div class='inline'>
243
- <p>Parses the referenced value and creates a matching constant in the
244
- requested context.</p>
288
+ <p>Parses the referenced value and creates a matching constant in the requested context.</p>
245
289
  </div></span>
246
290
 
247
291
  </li>
@@ -268,13 +312,9 @@ requested context.</p>
268
312
  </h3><div class="docstring">
269
313
  <div class="discussion">
270
314
 
271
- <p>Creates ENV bindings for EnvParser.parse and EnvParser.register proxy
272
- methods.</p>
315
+ <p>Creates ENV bindings for <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">parse</a></span> and <span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">register</a></span> proxy methods.</p>
273
316
 
274
- <p>The sole difference between these proxy methods and their EnvParser
275
- counterparts is that ENV.parse will interpret any value given as an ENV key
276
- (as a String), not the given value itself. i.e. ENV.parse(&#39;XYZ&#39;, …)
277
- is equivalent to <a href="'XYZ'">EnvParser.parse(ENV</a>, …)</p>
317
+ <p>The sole difference between these proxy methods and their EnvParser counterparts is that ENV.parse will interpret any value given as an ENV key (as a String), not the given value itself. i.e. ENV.parse(&#39;XYZ&#39;, …) is equivalent to <a href="'XYZ'">EnvParser.parse(ENV</a>, …)</p>
278
318
 
279
319
 
280
320
  </div>
@@ -293,7 +333,7 @@ is equivalent to <a href="'XYZ'">EnvParser.parse(ENV</a>, …)</p>
293
333
 
294
334
  &mdash;
295
335
  <div class='inline'>
296
- <p>This generates no usable value, so we may as well return ENV for chaining?</p>
336
+ <p>This generates no usable value.</p>
297
337
  </div>
298
338
 
299
339
  </li>
@@ -306,22 +346,22 @@ is equivalent to <a href="'XYZ'">EnvParser.parse(ENV</a>, …)</p>
306
346
  <pre class="lines">
307
347
 
308
348
 
349
+ 219
350
+ 220
351
+ 221
352
+ 222
353
+ 223
354
+ 224
355
+ 225
356
+ 226
357
+ 227
358
+ 228
309
359
  229
310
360
  230
311
- 231
312
- 232
313
- 233
314
- 234
315
- 235
316
- 236
317
- 237
318
- 238
319
- 239
320
- 240
321
- 241</pre>
361
+ 231</pre>
322
362
  </td>
323
363
  <td>
324
- <pre class="code"><span class="info file"># File 'lib/env_parser.rb', line 229</span>
364
+ <pre class="code"><span class="info file"># File 'lib/env_parser.rb', line 219</span>
325
365
 
326
366
  <span class='kw'>def</span> <span class='id identifier rubyid_add_env_bindings'>add_env_bindings</span>
327
367
  <span class='const'>ENV</span><span class='period'>.</span><span class='id identifier rubyid_instance_eval'>instance_eval</span> <span class='kw'>do</span>
@@ -339,12 +379,152 @@ is equivalent to <a href="'XYZ'">EnvParser.parse(ENV</a>, …)</p>
339
379
  </td>
340
380
  </tr>
341
381
  </table>
382
+ </div>
383
+
384
+ <div class="method_details ">
385
+ <h3 class="signature " id="autoregister-class_method">
386
+
387
+ .<strong>autoregister</strong>(filename = nil) &#x21d2; <tt>Hash</tt>
388
+
389
+
390
+
391
+
392
+
393
+ </h3><div class="docstring">
394
+ <div class="discussion">
395
+
396
+ <p>Reads an “autoregister” file and registers the ENV constants defined therein.</p>
397
+
398
+ <p>The “autoregister” file is read, parsed as YAML, sanitized for use as a parameter to <span class='object_link'>register_all</span>, and then passed along for processing. The return value from that <span class='object_link'>register_all</span> call is passed through.</p>
399
+
400
+
401
+ </div>
402
+ </div>
403
+ <div class="tags">
404
+ <p class="tag_title">Parameters:</p>
405
+ <ul class="param">
406
+
407
+ <li>
408
+
409
+ <span class='name'>filename</span>
410
+
411
+
412
+ <span class='type'>(<tt>String</tt>)</span>
413
+
414
+
415
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
416
+
417
+
418
+ &mdash;
419
+ <div class='inline'>
420
+ <p>A path for the autoregister file to parse and process. Defaults to <span class='object_link'><a href="#AUTOREGISTER_FILE-constant" title="EnvParser::AUTOREGISTER_FILE (constant)">AUTOREGISTER_FILE</a></span> if unset.</p>
421
+ </div>
422
+
423
+ </li>
424
+
425
+ </ul>
426
+
427
+ <p class="tag_title">Returns:</p>
428
+ <ul class="return">
429
+
430
+ <li>
431
+
432
+
433
+ <span class='type'>(<tt>Hash</tt>)</span>
434
+
435
+
436
+
437
+ &mdash;
438
+ <div class='inline'>
439
+ <p>The return value from the <span class='object_link'>register_all</span> call that handles the actual registration.</p>
440
+ </div>
441
+
442
+ </li>
443
+
444
+ </ul>
445
+ <p class="tag_title">Raises:</p>
446
+ <ul class="raise">
447
+
448
+ <li>
449
+
450
+
451
+ <span class='type'>(<tt><span class='object_link'><a href="EnvParser/AutoregisterFileNotFound.html" title="EnvParser::AutoregisterFileNotFound (class)">EnvParser::AutoregisterFileNotFound</a></span></tt>, <tt><span class='object_link'><a href="EnvParser/UnparseableAutoregisterSpec.html" title="EnvParser::UnparseableAutoregisterSpec (class)">EnvParser::UnparseableAutoregisterSpec</a></span></tt>)</span>
452
+
453
+
454
+
455
+ </li>
456
+
457
+ </ul>
458
+
459
+ </div><table class="source_code">
460
+ <tr>
461
+ <td>
462
+ <pre class="lines">
463
+
464
+
465
+ 248
466
+ 249
467
+ 250
468
+ 251
469
+ 252
470
+ 253
471
+ 254
472
+ 255
473
+ 256
474
+ 257
475
+ 258
476
+ 259
477
+ 260
478
+ 261
479
+ 262
480
+ 263
481
+ 264
482
+ 265
483
+ 266
484
+ 267
485
+ 268
486
+ 269
487
+ 270
488
+ 271
489
+ 272</pre>
490
+ </td>
491
+ <td>
492
+ <pre class="code"><span class="info file"># File 'lib/env_parser.rb', line 248</span>
493
+
494
+ <span class='kw'>def</span> <span class='id identifier rubyid_autoregister'>autoregister</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'><span class='object_link'><a href="top-level-namespace.html#filename-instance_method" title="#filename (method)">filename</a></span></span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
495
+ <span class='id identifier rubyid_filename'><span class='object_link'><a href="top-level-namespace.html#filename-instance_method" title="#filename (method)">filename</a></span></span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="#AUTOREGISTER_FILE-constant" title="EnvParser::AUTOREGISTER_FILE (constant)">AUTOREGISTER_FILE</a></span></span>
496
+ <span class='id identifier rubyid_autoregister_spec'>autoregister_spec</span> <span class='op'>=</span> <span class='const'>Psych</span><span class='period'>.</span><span class='id identifier rubyid_load_file'>load_file</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'><span class='object_link'><a href="top-level-namespace.html#filename-instance_method" title="#filename (method)">filename</a></span></span><span class='rparen'>)</span>
497
+
498
+ <span class='id identifier rubyid_autoregister_spec'>autoregister_spec</span><span class='period'>.</span><span class='id identifier rubyid_deep_symbolize_keys!'>deep_symbolize_keys!</span>
499
+ <span class='id identifier rubyid_autoregister_spec'>autoregister_spec</span><span class='period'>.</span><span class='id identifier rubyid_transform_values!'>transform_values!</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_spec'>spec</span><span class='op'>|</span>
500
+ <span class='id identifier rubyid_sanitized'>sanitized</span> <span class='op'>=</span> <span class='id identifier rubyid_spec'>spec</span><span class='period'>.</span><span class='id identifier rubyid_slice'>slice</span><span class='lparen'>(</span><span class='symbol'>:as</span><span class='comma'>,</span> <span class='symbol'>:within</span><span class='comma'>,</span> <span class='symbol'>:if_unset</span><span class='comma'>,</span> <span class='symbol'>:from_set</span><span class='rparen'>)</span>
501
+ <span class='id identifier rubyid_sanitized'>sanitized</span><span class='lbracket'>[</span><span class='symbol'>:as</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitized'>sanitized</span><span class='lbracket'>[</span><span class='symbol'>:as</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='kw'>if</span> <span class='id identifier rubyid_sanitized'>sanitized</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span> <span class='symbol'>:as</span>
502
+ <span class='id identifier rubyid_sanitized'>sanitized</span><span class='lbracket'>[</span><span class='symbol'>:within</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitized'>sanitized</span><span class='lbracket'>[</span><span class='symbol'>:within</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_constantize'>constantize</span> <span class='kw'>if</span> <span class='id identifier rubyid_sanitized'>sanitized</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span> <span class='symbol'>:within</span>
503
+
504
+ <span class='id identifier rubyid_sanitized'>sanitized</span>
505
+ <span class='kw'>end</span>
506
+
507
+ <span class='id identifier rubyid_register_all'>register_all</span> <span class='id identifier rubyid_autoregister_spec'>autoregister_spec</span>
508
+
509
+ <span class='comment'>## Psych raises an Errno::ENOENT on file-not-found.
510
+ </span><span class='comment'>##
511
+ </span><span class='kw'>rescue</span> <span class='const'>Errno</span><span class='op'>::</span><span class='const'>ENOENT</span>
512
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="" title="EnvParser (class)">EnvParser</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="EnvParser/AutoregisterFileNotFound.html" title="EnvParser::AutoregisterFileNotFound (class)">AutoregisterFileNotFound</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>%(</span><span class='tstring_content'>file not found: &quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_filename'><span class='object_link'><a href="top-level-namespace.html#filename-instance_method" title="#filename (method)">filename</a></span></span><span class='embexpr_end'>}</span><span class='tstring_content'>&quot;</span><span class='tstring_end'>)</span></span>
513
+
514
+ <span class='comment'>## Psych raises a Psych::SyntaxError on unparseable YAML.
515
+ </span><span class='comment'>##
516
+ </span><span class='kw'>rescue</span> <span class='const'>Psych</span><span class='op'>::</span><span class='const'>SyntaxError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
517
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="" title="EnvParser (class)">EnvParser</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="EnvParser/UnparseableAutoregisterSpec.html" title="EnvParser::UnparseableAutoregisterSpec (class)">UnparseableAutoregisterSpec</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>malformed YAML in spec file: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
518
+ <span class='kw'>end</span></pre>
519
+ </td>
520
+ </tr>
521
+ </table>
342
522
  </div>
343
523
 
344
524
  <div class="method_details ">
345
525
  <h3 class="signature " id="define_type-class_method">
346
526
 
347
- .<strong>define_type</strong>(name, options = {}) { ... } &#x21d2; <tt>nil</tt>
527
+ .<strong>define_type</strong>(name, options = {}) {|value| ... } &#x21d2; <tt>nil</tt>
348
528
 
349
529
 
350
530
 
@@ -353,8 +533,7 @@ is equivalent to <a href="'XYZ'">EnvParser.parse(ENV</a>, …)</p>
353
533
  </h3><div class="docstring">
354
534
  <div class="discussion">
355
535
 
356
- <p>Defines a new type for use as the “as” option on a subsequent
357
- <code>.parse</code> or <code>.register</code> call.</p>
536
+ <p>Defines a new type for use as the “as” option on a subsequent <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">parse</a></span> or <span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">register</a></span> call.</p>
358
537
 
359
538
 
360
539
  </div>
@@ -425,14 +604,13 @@ is equivalent to <a href="'XYZ'">EnvParser.parse(ENV</a>, …)</p>
425
604
  <span class="type">(<tt>Object</tt>)</span>
426
605
  <span class="default">
427
606
 
607
+ &mdash; default:
608
+ <tt>nil</tt>
609
+
428
610
  </span>
429
611
 
430
612
  &mdash; <div class='inline'>
431
- <p>Specifies a “sensible default” to return for this type if the value being
432
- parsed (via <code>.parse</code> or <code>.register</code>) is either unset
433
- (<code>nil</code>) or blank (<code>&#39;&#39;</code>). Note this may be
434
- overridden by the user via the <code>.parse</code>/<code>.register</code>
435
- “if_unset” option.</p>
613
+ <p>Specifies a “sensible default” to return for this type if the value being parsed (via <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">parse</a></span> or <span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">register</a></span>) is either unset (<code>nil</code>) or blank (<code>&#39;&#39;</code>). Note this may be overridden by the user via the <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">parse</a></span>/<span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">register</a></span> “if_unset” option.</p>
436
614
  </div>
437
615
 
438
616
  </li>
@@ -446,24 +624,17 @@ overridden by the user via the <code>.parse</code>/<code>.register</code>
446
624
  <li>
447
625
 
448
626
 
449
- <span class='type'></span>
627
+ <span class='type'>(<tt>value</tt>)</span>
450
628
 
451
629
 
452
630
 
453
-
631
+ &mdash;
454
632
  <div class='inline'>
455
- <p>A block to act as the parser for the this type. If no block is given, an
456
- ArgumentError is raised.</p>
457
-
458
- <p>When the type defined is used via a
459
- <code>.parse</code>/<code>.register</code> call, this block is invoked with
460
- the value to be parsed. Said value is guaranteed to be a non-empty String
461
- (the “if_unset” check will have already run), but no other assurances as to
462
- content are given. The block should return the final output of parsing the
463
- given String value as the type being defined.</p>
464
-
465
- <p>If the value given cannot be sensibly parsed into the type defined, the
466
- block should raise an EnvParser::ValueNotAllowed exception.</p>
633
+ <p>A block to act as the parser for the this type. If no block is given, an ArgumentError is raised.</p>
634
+
635
+ <p>When the type defined is used via a <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">parse</a></span>/<span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">register</a></span> call, this block is invoked with the value to be parsed. Said value is guaranteed to be a non-empty String (the “if_unset” check will have already run), but no other assurances as to content are given. The block should return the final output of parsing the given String value as the type being defined.</p>
636
+
637
+ <p>If the value given cannot be sensibly parsed into the type defined, the block should raise an <span class='object_link'><a href="EnvParser/ValueNotConvertibleError.html" title="EnvParser::ValueNotConvertibleError (class)">ValueNotConvertibleError</a></span>.</p>
467
638
  </div>
468
639
 
469
640
  </li>
@@ -493,7 +664,7 @@ block should raise an EnvParser::ValueNotAllowed exception.</p>
493
664
  <li>
494
665
 
495
666
 
496
- <span class='type'>(<tt>ArgumentError</tt>, <tt><span class='object_link'><a href="EnvParser/TypeAlreadyDefined.html" title="EnvParser::TypeAlreadyDefined (class)">EnvParser::TypeAlreadyDefined</a></span></tt>)</span>
667
+ <span class='type'>(<tt>ArgumentError</tt>, <tt><span class='object_link'><a href="EnvParser/TypeAlreadyDefinedError.html" title="EnvParser::TypeAlreadyDefinedError (class)">EnvParser::TypeAlreadyDefinedError</a></span></tt>)</span>
497
668
 
498
669
 
499
670
 
@@ -507,31 +678,31 @@ block should raise an EnvParser::ValueNotAllowed exception.</p>
507
678
  <pre class="lines">
508
679
 
509
680
 
681
+ 44
682
+ 45
683
+ 46
684
+ 47
685
+ 48
686
+ 49
687
+ 50
688
+ 51
689
+ 52
510
690
  53
511
691
  54
512
692
  55
513
693
  56
514
694
  57
515
- 58
516
- 59
517
- 60
518
- 61
519
- 62
520
- 63
521
- 64
522
- 65
523
- 66
524
- 67</pre>
695
+ 58</pre>
525
696
  </td>
526
697
  <td>
527
- <pre class="code"><span class="info file"># File 'lib/env_parser.rb', line 53</span>
698
+ <pre class="code"><span class="info file"># File 'lib/env_parser.rb', line 44</span>
528
699
 
529
700
  <span class='kw'>def</span> <span class='id identifier rubyid_define_type'>define_type</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_parser'>parser</span><span class='rparen'>)</span>
530
701
  <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>no parsing block given</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
531
702
 
532
703
  <span class='id identifier rubyid_given_types'>given_types</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:aliases</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_s</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_sym</span><span class='rparen'>)</span>
533
704
  <span class='id identifier rubyid_given_types'>given_types</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_type'>type</span><span class='op'>|</span>
534
- <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="EnvParser/TypeAlreadyDefined.html" title="EnvParser::TypeAlreadyDefined (class)">TypeAlreadyDefined</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>cannot redefine </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_known_types'>known_types</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
705
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="EnvParser/TypeAlreadyDefinedError.html" title="EnvParser::TypeAlreadyDefinedError (class)">TypeAlreadyDefinedError</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>cannot redefine </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_known_types'>known_types</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
535
706
 
536
707
  <span class='id identifier rubyid_known_types'>known_types</span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbrace'>{</span>
537
708
  <span class='label'>parser:</span> <span class='id identifier rubyid_parser'>parser</span><span class='comma'>,</span>
@@ -578,9 +749,7 @@ block should raise an EnvParser::ValueNotAllowed exception.</p>
578
749
 
579
750
  &mdash;
580
751
  <div class='inline'>
581
- <p>The value to parse/interpret. If a String is given, the value will be used
582
- as-is. If a Symbol is given, the ENV value for the matching string key will
583
- be used.</p>
752
+ <p>The value to parse/interpret. If a String is given, the value will be used as-is. If a Symbol is given, the ENV value for the matching string key will be used.</p>
584
753
  </div>
585
754
 
586
755
  </li>
@@ -621,11 +790,9 @@ be used.</p>
621
790
  </span>
622
791
 
623
792
  &mdash; <div class='inline'>
624
- <p>The expected return type. A best-effort attempt is made to convert the
625
- source String to the requested type.</p>
793
+ <p>The expected return type. A best-effort attempt is made to convert the source String to the requested type.</p>
626
794
 
627
- <p>If no “as” option is given (or the “as” value given has not been defined),
628
- an ArgumentError exception is raised.</p>
795
+ <p>If no “as” option is given, an ArgumentError is raised. If the “as” option given is unknown (the given type has not been previously defined via <span class='object_link'><a href="#define_type-class_method" title="EnvParser.define_type (method)">define_type</a></span>), an <span class='object_link'><a href="EnvParser/UnknownTypeError.html" title="EnvParser::UnknownTypeError (class)">UnknownTypeError</a></span> is raised.</p>
629
796
  </div>
630
797
 
631
798
  </li>
@@ -638,12 +805,7 @@ an ArgumentError exception is raised.</p>
638
805
  </span>
639
806
 
640
807
  &mdash; <div class='inline'>
641
- <p>Specifies the default value to return if the given “value” is either unset
642
- (<code>nil</code>) or blank (<code>&#39;&#39;</code>). Any “if_unset” value
643
- given will be returned as-is, with no type conversion or other change
644
- having been made. If unspecified, the “default” value for
645
- <code>nil</code>/<code>&#39;&#39;</code> input will depend on the “as”
646
- type.</p>
808
+ <p>Specifies the default value to return if the given “value” is either unset (<code>nil</code>) or blank (<code>&#39;&#39;</code>). Any “if_unset” value given will be returned as-is, with no type conversion or other change having been made. If unspecified, the “default” value for <code>nil</code>/<code>&#39;&#39;</code> input will depend on the “as” type.</p>
647
809
  </div>
648
810
 
649
811
  </li>
@@ -656,18 +818,11 @@ type.</p>
656
818
  </span>
657
819
 
658
820
  &mdash; <div class='inline'>
659
- <p>Gives a limited set of allowed values (after type conversion). If, after
660
- parsing, the final value is not included in the “from_set” list/range, an
661
- EnvParser::ValueNotAllowed exception is raised.</p>
662
-
663
- <p>Note that if the “if_unset” option is given and the value to parse is
664
- <code>nil</code>/<code>&#39;&#39;</code>, the “if_unset” value will be
665
- returned, even if it is not part of the “from_set” list/range.</p>
666
-
667
- <p>Also note that, due to the nature of the lookup, the “from_set” option is
668
- only available for scalar values (i.e. not arrays, hashes, or other
669
- enumerables). An attempt to use the “from_set” option with a non-scalar
670
- value will raise an ArgumentError exception.</p>
821
+ <p>Gives a limited set of allowed values (after type conversion). If, after parsing, the final value is not included in the “from_set” list/range, an <span class='object_link'><a href="EnvParser/ValueNotAllowedError.html" title="EnvParser::ValueNotAllowedError (class)">ValueNotAllowedError</a></span> is raised.</p>
822
+
823
+ <p>Note that if the “if_unset” option is given and the value to parse is <code>nil</code>/<code>&#39;&#39;</code>, the “if_unset” value will be returned, even if it is not part of the “from_set” list/range.</p>
824
+
825
+ <p>Also note that, due to the nature of the lookup, the from_set” option is only available for scalar values (i.e. not arrays, hashes, or other enumerables). An attempt to use the “from_set” option with a non-scalar value will raise an ArgumentError.</p>
671
826
  </div>
672
827
 
673
828
  </li>
@@ -680,18 +835,9 @@ value will raise an ArgumentError exception.</p>
680
835
  </span>
681
836
 
682
837
  &mdash; <div class='inline'>
683
- <p>If given, the “validated_by” proc is called with the parsed value (after
684
- type conversion) as its sole argument. This allows for user-defined
685
- validation of the parsed value beyond what can be enforced by use of the
686
- “from_set” option alone. If the proc&#39;s return value is
687
- <code>#blank?</code>, an EnvParser::ValueNotAllowed exception is raised. To
688
- accomodate your syntax of choice, this validation proc may be given as a
689
- yield block instead.</p>
690
-
691
- <p>Note that this option is intended to provide an inspection mechanism only –
692
- no mutation of the parsed value should occur within the given proc. To that
693
- end, the argument passed is a <em>frozen</em> duplicate of the parsed
694
- value.</p>
838
+ <p>If given, the “validated_by” Proc is called with the parsed value (after type conversion) as its sole argument. This allows for user-defined validation of the parsed value beyond what can be enforced by use of the “from_set” option alone. If the Proc&#39;s return value is <code>#blank?</code>, an <span class='object_link'><a href="EnvParser/ValueNotAllowedError.html" title="EnvParser::ValueNotAllowedError (class)">ValueNotAllowedError</a></span> is raised. To accomodate your syntax of choice, this validation Proc may be given as a block instead.</p>
839
+
840
+ <p>Note that this option is intended to provide an inspection mechanism only – no mutation of the parsed value should occur within the given Proc. To that end, the argument passed is a <em>frozen</em> duplicate of the parsed value.</p>
695
841
  </div>
696
842
 
697
843
  </li>
@@ -711,11 +857,9 @@ value.</p>
711
857
 
712
858
  &mdash;
713
859
  <div class='inline'>
714
- <p>A block (if given) is treated exactly as the “validated_by” Proc would.
715
- Although there is no compelling reason to provide both a “validated_by”
716
- proc <em>and</em> a validation block, there is no technical limitation
717
- preventing this. <strong>If both are given, both validation checks must
718
- pass.</strong></p>
860
+ <p>A block (if given) is treated exactly as the “validated_by” Proc would.</p>
861
+
862
+ <p>Although there is no compelling reason to provide both a “validated_by” Proc <em>and</em> a validation block, there is no technical limitation preventing this. <strong>If both are given, both validation checks must pass.</strong></p>
719
863
  </div>
720
864
 
721
865
  </li>
@@ -727,7 +871,7 @@ pass.</strong></p>
727
871
  <li>
728
872
 
729
873
 
730
- <span class='type'>(<tt>ArgumentError</tt>, <tt><span class='object_link'><a href="EnvParser/ValueNotAllowed.html" title="EnvParser::ValueNotAllowed (class)">EnvParser::ValueNotAllowed</a></span></tt>)</span>
874
+ <span class='type'>(<tt>ArgumentError</tt>, <tt><span class='object_link'><a href="EnvParser/UnknownTypeError.html" title="EnvParser::UnknownTypeError (class)">EnvParser::UnknownTypeError</a></span></tt>, <tt><span class='object_link'><a href="EnvParser/ValueNotAllowedError.html" title="EnvParser::ValueNotAllowedError (class)">EnvParser::ValueNotAllowedError</a></span></tt>)</span>
731
875
 
732
876
 
733
877
 
@@ -741,6 +885,13 @@ pass.</strong></p>
741
885
  <pre class="lines">
742
886
 
743
887
 
888
+ 112
889
+ 113
890
+ 114
891
+ 115
892
+ 116
893
+ 117
894
+ 118
744
895
  119
745
896
  120
746
897
  121
@@ -749,23 +900,18 @@ pass.</strong></p>
749
900
  124
750
901
  125
751
902
  126
752
- 127
753
- 128
754
- 129
755
- 130
756
- 131
757
- 132
758
- 133</pre>
903
+ 127</pre>
759
904
  </td>
760
905
  <td>
761
- <pre class="code"><span class="info file"># File 'lib/env_parser.rb', line 119</span>
906
+ <pre class="code"><span class="info file"># File 'lib/env_parser.rb', line 112</span>
762
907
 
763
908
  <span class='kw'>def</span> <span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_validation_block'>validation_block</span><span class='rparen'>)</span>
764
909
  <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Symbol</span>
765
910
  <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
766
911
 
767
912
  <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='id identifier rubyid_known_types'>known_types</span><span class='lbracket'>[</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:as</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
768
- <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>invalid `as` parameter: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:as</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_type'>type</span>
913
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>missing `as` parameter</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='symbol'>:as</span><span class='rparen'>)</span>
914
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="EnvParser/UnknownTypeError.html" title="EnvParser::UnknownTypeError (class)">UnknownTypeError</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>invalid `as` parameter: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:as</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_type'>type</span>
769
915
 
770
916
  <span class='kw'>return</span> <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='symbol'>:if_unset</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:if_unset</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='id identifier rubyid_type'>type</span><span class='lbracket'>[</span><span class='symbol'>:if_unset</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
771
917
 
@@ -792,12 +938,9 @@ pass.</strong></p>
792
938
  </h3><div class="docstring">
793
939
  <div class="discussion">
794
940
 
795
- <p>Parses the referenced value and creates a matching constant in the
796
- requested context.</p>
941
+ <p>Parses the referenced value and creates a matching constant in the requested context.</p>
797
942
 
798
- <p>Multiple calls to register may be shortcutted by passing in a Hash with
799
- the same keys as those in the “from” Hash and each value being the
800
- “register” options set for each variable&#39;s “register” call.</p>
943
+ <p>Multiple calls to <span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">register</a></span> may be shortcutted by passing in a Hash whose keys are the variable names and whose values are the options set for each variable&#39;s <span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">register</a></span> call.</p>
801
944
  <pre class="code ruby"><code class="ruby">
802
945
  ## Example shortcut usage:
803
946
 
@@ -829,9 +972,7 @@ the same keys as those in the “from” Hash and each value being the
829
972
 
830
973
  &mdash;
831
974
  <div class='inline'>
832
- <p>The name of the value to parse/interpret from the “from” Hash. If the
833
- “from” value is ENV, you may give a Symbol and the corresponding String key
834
- will be used instead.</p>
975
+ <p>The name of the value to parse/interpret from the “from” Hash. If the “from” value is <code>ENV</code>, you may give a Symbol and the corresponding String key will be used instead.</p>
835
976
  </div>
836
977
 
837
978
  </li>
@@ -869,11 +1010,13 @@ will be used instead.</p>
869
1010
  <span class="type">(<tt>Hash</tt>)</span>
870
1011
  <span class="default">
871
1012
 
1013
+ &mdash; default:
1014
+ <tt>ENV</tt>
1015
+
872
1016
  </span>
873
1017
 
874
1018
  &mdash; <div class='inline'>
875
- <p>The source Hash from which to pull the value referenced by the “name” key.
876
- Defaults to ENV.</p>
1019
+ <p>The source Hash from which to pull the value referenced by the “name” key.</p>
877
1020
  </div>
878
1021
 
879
1022
  </li>
@@ -883,11 +1026,13 @@ Defaults to ENV.</p>
883
1026
  <span class="type">(<tt>Module</tt>, <tt>Class</tt>)</span>
884
1027
  <span class="default">
885
1028
 
1029
+ &mdash; default:
1030
+ <tt>Kernel</tt>
1031
+
886
1032
  </span>
887
1033
 
888
1034
  &mdash; <div class='inline'>
889
- <p>The module or class in which the constant should be created. Defaults to
890
- Kernel (making it a global constant).</p>
1035
+ <p>The module or class in which the constant should be created. Creates global constants by default.</p>
891
1036
  </div>
892
1037
 
893
1038
  </li>
@@ -900,7 +1045,7 @@ Kernel (making it a global constant).</p>
900
1045
  </span>
901
1046
 
902
1047
  &mdash; <div class='inline'>
903
- <p>See <code>.parse</code>.</p>
1048
+ <p>See <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">parse</a></span>.</p>
904
1049
  </div>
905
1050
 
906
1051
  </li>
@@ -913,7 +1058,7 @@ Kernel (making it a global constant).</p>
913
1058
  </span>
914
1059
 
915
1060
  &mdash; <div class='inline'>
916
- <p>See <code>.parse</code>.</p>
1061
+ <p>See <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">parse</a></span>.</p>
917
1062
  </div>
918
1063
 
919
1064
  </li>
@@ -926,7 +1071,7 @@ Kernel (making it a global constant).</p>
926
1071
  </span>
927
1072
 
928
1073
  &mdash; <div class='inline'>
929
- <p>See <code>.parse</code>.</p>
1074
+ <p>See <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">parse</a></span>.</p>
930
1075
  </div>
931
1076
 
932
1077
  </li>
@@ -939,7 +1084,7 @@ Kernel (making it a global constant).</p>
939
1084
  </span>
940
1085
 
941
1086
  &mdash; <div class='inline'>
942
- <p>See <code>.parse</code>.</p>
1087
+ <p>See <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">parse</a></span>.</p>
943
1088
  </div>
944
1089
 
945
1090
  </li>
@@ -959,10 +1104,7 @@ Kernel (making it a global constant).</p>
959
1104
 
960
1105
  &mdash;
961
1106
  <div class='inline'>
962
- <p>A block (if given) is treated exactly as in <code>.parse</code>. Note,
963
- however, that a single yield block cannot be used to register multiple
964
- constants simultaneously – each value needing validation must give its own
965
- “validated_by” proc.</p>
1107
+ <p>A block (if given) is treated exactly as in <span class='object_link'><a href="#parse-class_method" title="EnvParser.parse (method)">parse</a></span>. Note, however, that a single block cannot be used to register multiple constants simultaneously – each value needing validation must give its own “validated_by” Proc.</p>
966
1108
  </div>
967
1109
 
968
1110
  </li>
@@ -988,6 +1130,13 @@ constants simultaneously – each value needing validation must give its own
988
1130
  <pre class="lines">
989
1131
 
990
1132
 
1133
+ 178
1134
+ 179
1135
+ 180
1136
+ 181
1137
+ 182
1138
+ 183
1139
+ 184
991
1140
  185
992
1141
  186
993
1142
  187
@@ -1011,26 +1160,15 @@ constants simultaneously – each value needing validation must give its own
1011
1160
  205
1012
1161
  206
1013
1162
  207
1014
- 208
1015
- 209
1016
- 210
1017
- 211
1018
- 212
1019
- 213
1020
- 214
1021
- 215
1022
- 216
1023
- 217
1024
- 218</pre>
1163
+ 208</pre>
1025
1164
  </td>
1026
1165
  <td>
1027
- <pre class="code"><span class="info file"># File 'lib/env_parser.rb', line 185</span>
1166
+ <pre class="code"><span class="info file"># File 'lib/env_parser.rb', line 178</span>
1028
1167
 
1029
1168
  <span class='kw'>def</span> <span class='id identifier rubyid_register'>register</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_validation_block'>validation_block</span><span class='rparen'>)</span>
1030
- <span class='comment'>## We want to allow for registering multiple variables simultaneously via a single `.register`
1031
- </span> <span class='comment'>## method call.
1169
+ <span class='comment'>## Allow for registering multiple variables simultaneously via a single call.
1032
1170
  </span> <span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Hash</span>
1033
- <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cannot register multiple values with one yield block</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
1171
+ <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cannot register multiple values with one block</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
1034
1172
  <span class='kw'>return</span> <span class='id identifier rubyid_register_all'>register_all</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
1035
1173
  <span class='kw'>end</span>
1036
1174
 
@@ -1046,9 +1184,7 @@ constants simultaneously – each value needing validation must give its own
1046
1184
  <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
1047
1185
  <span class='kw'>end</span>
1048
1186
 
1049
- <span class='kw'>unless</span> <span class='id identifier rubyid_from'>from</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
1050
- <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>invalid `from` parameter: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_from'>from</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
1051
- <span class='kw'>end</span>
1187
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>invalid `from` parameter: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_from'>from</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_from'>from</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Hash</span>
1052
1188
 
1053
1189
  <span class='kw'>unless</span> <span class='id identifier rubyid_within'>within</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Module</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_within'>within</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Class</span><span class='rparen'>)</span>
1054
1190
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>invalid `within` parameter: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_within'>within</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
@@ -1070,9 +1206,9 @@ constants simultaneously – each value needing validation must give its own
1070
1206
  </div>
1071
1207
 
1072
1208
  <div id="footer">
1073
- Generated on Sun Dec 24 19:33:35 2017 by
1209
+ Generated on Sat Jan 2 17:31:18 2021 by
1074
1210
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1075
- 0.9.11 (ruby-2.4.2).
1211
+ 0.9.26 (ruby-2.7.2).
1076
1212
  </div>
1077
1213
 
1078
1214
  </div>