env_parser 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +1 -1
- data/.rubocop.yml +15 -7
- data/.ruby-version +1 -1
- data/Gemfile.lock +47 -41
- data/docs/EnvParser.html +39 -98
- data/docs/EnvParser/AutoregisterFileNotFound.html +7 -8
- data/docs/EnvParser/Error.html +6 -6
- data/docs/EnvParser/TypeAlreadyDefinedError.html +6 -6
- data/docs/EnvParser/Types.html +7 -8
- data/docs/EnvParser/Types/BaseTypes.html +7 -8
- data/docs/EnvParser/Types/ChronologyTypes.html +6 -6
- data/docs/EnvParser/Types/InternetTypes.html +6 -6
- data/docs/EnvParser/UnknownTypeError.html +6 -6
- data/docs/EnvParser/UnparseableAutoregisterSpec.html +7 -8
- data/docs/EnvParser/ValueNotAllowedError.html +7 -9
- data/docs/EnvParser/ValueNotConvertibleError.html +7 -8
- data/docs/_index.html +7 -7
- data/docs/class_list.html +2 -2
- data/docs/css/style.css +3 -2
- data/docs/file.README.html +67 -195
- data/docs/file_list.html +2 -2
- data/docs/frames.html +2 -2
- data/docs/index.html +67 -195
- data/docs/js/app.js +14 -3
- data/docs/method_list.html +2 -2
- data/docs/top-level-namespace.html +6 -6
- data/env_parser.gemspec +3 -3
- data/lib/env_parser.rb +1 -4
- data/lib/env_parser/types/chronology_types.rb +1 -1
- data/lib/env_parser/types/internet_types.rb +1 -1
- data/lib/env_parser/version.rb +1 -1
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6d6d57f56549ef5746444f13eb1b306f6d9e2b46de648a0b218ea890e0b59a79
|
4
|
+
data.tar.gz: 981d6ca140586a772801ff1b705508e30c211bfe412f63260192d89fe8630e2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2220164e6600e4f4112cdd3d575454aee82cde8a01e3fde5ab06314f6788d414d513296a75c6fe89ea074c1ccf65d418c8a8d1855057bbe06162fca374a61b06
|
7
|
+
data.tar.gz: ba9946219aa484356e80e1dcac0ebbcd745f6c1cd9d94fdf24a06ca35a4deb0ce91fae9cd67ea268509820fdbc30ed2b3f03698a060008d568c87e1f45f130ce
|
data/.circleci/config.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.7
|
3
|
+
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
3
5
|
Include:
|
4
6
|
- "**/*.rb"
|
5
7
|
- "**/*.rake"
|
@@ -15,6 +17,18 @@ Layout/EmptyLineAfterGuardClause:
|
|
15
17
|
# Add empty line after guard clause.
|
16
18
|
Enabled: false
|
17
19
|
|
20
|
+
Layout/LineLength:
|
21
|
+
# Limit lines to 100 characters.
|
22
|
+
Max: 100
|
23
|
+
Exclude:
|
24
|
+
- 'spec/**/*.rb'
|
25
|
+
|
26
|
+
|
27
|
+
Lint/ConstantDefinitionInBlock:
|
28
|
+
# Do not define constants within a block.
|
29
|
+
Exclude:
|
30
|
+
- 'spec/**/*.rb'
|
31
|
+
|
18
32
|
|
19
33
|
Metrics/AbcSize:
|
20
34
|
# A calculated magnitude based on number of assignments, branches, and conditions.
|
@@ -29,12 +43,6 @@ Metrics/CyclomaticComplexity:
|
|
29
43
|
# A complexity metric that is strongly correlated to the number of test cases needed to validate a method.
|
30
44
|
Max: 10
|
31
45
|
|
32
|
-
Metrics/LineLength:
|
33
|
-
# Limit lines to 100 characters.
|
34
|
-
Max: 100
|
35
|
-
Exclude:
|
36
|
-
- 'spec/**/*.rb'
|
37
|
-
|
38
46
|
Metrics/MethodLength:
|
39
47
|
# Avoid methods longer than 25 lines of code.
|
40
48
|
Max: 25
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
env_parser (1.3.
|
4
|
+
env_parser (1.3.1)
|
5
5
|
activesupport (>= 5.0.0)
|
6
6
|
chronic
|
7
7
|
chronic_duration
|
@@ -9,67 +9,73 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (
|
12
|
+
activesupport (6.1.0)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (>=
|
15
|
-
minitest (
|
16
|
-
tzinfo (~>
|
17
|
-
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
|
+
ast (2.4.1)
|
18
19
|
chronic (0.10.2)
|
19
20
|
chronic_duration (0.10.6)
|
20
21
|
numerizer (~> 0.1.1)
|
21
|
-
concurrent-ruby (1.1.
|
22
|
-
diff-lcs (1.
|
23
|
-
i18n (1.
|
22
|
+
concurrent-ruby (1.1.7)
|
23
|
+
diff-lcs (1.4.4)
|
24
|
+
i18n (1.8.6)
|
24
25
|
concurrent-ruby (~> 1.0)
|
25
|
-
|
26
|
-
minitest (5.12.2)
|
26
|
+
minitest (5.14.2)
|
27
27
|
numerizer (0.1.1)
|
28
|
-
parallel (1.
|
29
|
-
parser (
|
30
|
-
ast (~> 2.4.
|
28
|
+
parallel (1.20.1)
|
29
|
+
parser (3.0.0.0)
|
30
|
+
ast (~> 2.4.1)
|
31
31
|
rainbow (3.0.0)
|
32
|
-
rake (
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
rspec-
|
37
|
-
|
38
|
-
rspec-
|
39
|
-
rspec-
|
32
|
+
rake (13.0.3)
|
33
|
+
regexp_parser (2.0.3)
|
34
|
+
rexml (3.2.4)
|
35
|
+
rspec (3.10.0)
|
36
|
+
rspec-core (~> 3.10.0)
|
37
|
+
rspec-expectations (~> 3.10.0)
|
38
|
+
rspec-mocks (~> 3.10.0)
|
39
|
+
rspec-core (3.10.1)
|
40
|
+
rspec-support (~> 3.10.0)
|
41
|
+
rspec-expectations (3.10.1)
|
40
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.
|
42
|
-
rspec-mocks (3.
|
43
|
+
rspec-support (~> 3.10.0)
|
44
|
+
rspec-mocks (3.10.1)
|
43
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
-
rspec-support (~> 3.
|
45
|
-
rspec-support (3.
|
46
|
-
rspec_junit_formatter (0.
|
46
|
+
rspec-support (~> 3.10.0)
|
47
|
+
rspec-support (3.10.1)
|
48
|
+
rspec_junit_formatter (0.4.1)
|
47
49
|
rspec-core (>= 2, < 4, != 2.12.0)
|
48
|
-
rubocop (
|
49
|
-
jaro_winkler (~> 1.5.1)
|
50
|
+
rubocop (1.7.0)
|
50
51
|
parallel (~> 1.10)
|
51
|
-
parser (>= 2.
|
52
|
+
parser (>= 2.7.1.5)
|
52
53
|
rainbow (>= 2.2.2, < 4.0)
|
54
|
+
regexp_parser (>= 1.8, < 3.0)
|
55
|
+
rexml
|
56
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
53
57
|
ruby-progressbar (~> 1.7)
|
54
|
-
unicode-display_width (>= 1.4.0, <
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
59
|
+
rubocop-ast (1.4.0)
|
60
|
+
parser (>= 2.7.1.5)
|
61
|
+
ruby-progressbar (1.11.0)
|
62
|
+
tzinfo (2.0.4)
|
63
|
+
concurrent-ruby (~> 1.0)
|
64
|
+
unicode-display_width (1.7.0)
|
65
|
+
yard (0.9.26)
|
66
|
+
zeitwerk (2.4.2)
|
61
67
|
|
62
68
|
PLATFORMS
|
63
69
|
ruby
|
64
70
|
|
65
71
|
DEPENDENCIES
|
66
|
-
bundler (~>
|
72
|
+
bundler (~> 2.0)
|
67
73
|
env_parser!
|
68
|
-
rake
|
74
|
+
rake
|
69
75
|
rspec (~> 3.0)
|
70
76
|
rspec_junit_formatter
|
71
|
-
rubocop
|
77
|
+
rubocop (= 1.7)
|
72
78
|
yard
|
73
79
|
|
74
80
|
BUNDLED WITH
|
75
|
-
1.
|
81
|
+
2.1.4
|
data/docs/EnvParser.html
CHANGED
@@ -6,15 +6,15 @@
|
|
6
6
|
<title>
|
7
7
|
Class: EnvParser
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.26
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css"
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
14
14
|
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css"
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
16
16
|
|
17
|
-
<script type="text/javascript"
|
17
|
+
<script type="text/javascript">
|
18
18
|
pathId = "EnvParser";
|
19
19
|
relpath = '';
|
20
20
|
</script>
|
@@ -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>
|
@@ -153,7 +152,7 @@ different data types.</p>
|
|
153
152
|
<dt id="VERSION-constant" class="">VERSION =
|
154
153
|
|
155
154
|
</dt>
|
156
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1.3.
|
155
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1.3.1</span><span class='tstring_end'>'</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
157
156
|
|
158
157
|
</dl>
|
159
158
|
|
@@ -214,8 +213,7 @@ different data types.</p>
|
|
214
213
|
|
215
214
|
|
216
215
|
<span class="summary_desc"><div class='inline'>
|
217
|
-
<p>Reads an “autoregister” file and registers the ENV constants defined
|
218
|
-
therein.</p>
|
216
|
+
<p>Reads an “autoregister” file and registers the ENV constants defined therein.</p>
|
219
217
|
</div></span>
|
220
218
|
|
221
219
|
</li>
|
@@ -239,8 +237,7 @@ therein.</p>
|
|
239
237
|
|
240
238
|
|
241
239
|
<span class="summary_desc"><div class='inline'>
|
242
|
-
<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
|
243
|
-
<span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">EnvParser.register</a></span> 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>
|
244
241
|
</div></span>
|
245
242
|
|
246
243
|
</li>
|
@@ -288,8 +285,7 @@ therein.</p>
|
|
288
285
|
|
289
286
|
|
290
287
|
<span class="summary_desc"><div class='inline'>
|
291
|
-
<p>Parses the referenced value and creates a matching constant in the
|
292
|
-
requested context.</p>
|
288
|
+
<p>Parses the referenced value and creates a matching constant in the requested context.</p>
|
293
289
|
</div></span>
|
294
290
|
|
295
291
|
</li>
|
@@ -318,10 +314,7 @@ requested context.</p>
|
|
318
314
|
|
319
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>
|
320
316
|
|
321
|
-
<p>The sole difference between these proxy methods and their EnvParser
|
322
|
-
counterparts is that ENV.parse will interpret any value given as an ENV key
|
323
|
-
(as a String), not the given value itself. i.e. ENV.parse('XYZ', …)
|
324
|
-
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('XYZ', …) is equivalent to <a href="'XYZ'">EnvParser.parse(ENV</a>, …)</p>
|
325
318
|
|
326
319
|
|
327
320
|
</div>
|
@@ -400,12 +393,9 @@ is equivalent to <a href="'XYZ'">EnvParser.parse(ENV</a>, …)</p>
|
|
400
393
|
</h3><div class="docstring">
|
401
394
|
<div class="discussion">
|
402
395
|
|
403
|
-
<p>Reads an “autoregister” file and registers the ENV constants defined
|
404
|
-
therein.</p>
|
396
|
+
<p>Reads an “autoregister” file and registers the ENV constants defined therein.</p>
|
405
397
|
|
406
|
-
<p>The “autoregister” file is read, parsed as YAML, sanitized for use as a
|
407
|
-
parameter to <span class='object_link'>register_all</span>, and then passed along for processing. The
|
408
|
-
return value from that <span class='object_link'>register_all</span> call is passed through.</p>
|
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>
|
409
399
|
|
410
400
|
|
411
401
|
</div>
|
@@ -427,8 +417,7 @@ return value from that <span class='object_link'>register_all</span> call is pas
|
|
427
417
|
|
428
418
|
—
|
429
419
|
<div class='inline'>
|
430
|
-
<p>A path for the autoregister file to parse and process. Defaults to
|
431
|
-
<span class='object_link'><a href="#AUTOREGISTER_FILE-constant" title="EnvParser::AUTOREGISTER_FILE (constant)">AUTOREGISTER_FILE</a></span> if unset.</p>
|
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>
|
432
421
|
</div>
|
433
422
|
|
434
423
|
</li>
|
@@ -447,8 +436,7 @@ return value from that <span class='object_link'>register_all</span> call is pas
|
|
447
436
|
|
448
437
|
—
|
449
438
|
<div class='inline'>
|
450
|
-
<p>The return value from the <span class='object_link'>register_all</span> call that handles the actual
|
451
|
-
registration.</p>
|
439
|
+
<p>The return value from the <span class='object_link'>register_all</span> call that handles the actual registration.</p>
|
452
440
|
</div>
|
453
441
|
|
454
442
|
</li>
|
@@ -545,8 +533,7 @@ registration.</p>
|
|
545
533
|
</h3><div class="docstring">
|
546
534
|
<div class="discussion">
|
547
535
|
|
548
|
-
<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
|
549
|
-
<span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">register</a></span> 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>
|
550
537
|
|
551
538
|
|
552
539
|
</div>
|
@@ -623,10 +610,7 @@ registration.</p>
|
|
623
610
|
</span>
|
624
611
|
|
625
612
|
— <div class='inline'>
|
626
|
-
<p>Specifies a “sensible default” to return for this type if the value being
|
627
|
-
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
|
628
|
-
blank (<code>''</code>). Note this may be overridden by the user
|
629
|
-
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>
|
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>''</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>
|
630
614
|
</div>
|
631
615
|
|
632
616
|
</li>
|
@@ -646,17 +630,11 @@ via the <span class='object_link'><a href="#parse-class_method" title="EnvParser
|
|
646
630
|
|
647
631
|
—
|
648
632
|
<div class='inline'>
|
649
|
-
<p>A block to act as the parser for the this type. If no block is given, an
|
650
|
-
ArgumentError is raised.</p>
|
633
|
+
<p>A block to act as the parser for the this type. If no block is given, an ArgumentError is raised.</p>
|
651
634
|
|
652
|
-
<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
|
653
|
-
is invoked with the value to be parsed. Said value is guaranteed to be a
|
654
|
-
non-empty String (the “if_unset” check will have already run), but no other
|
655
|
-
assurances as to content are given. The block should return the final
|
656
|
-
output of parsing the given String value as the type being defined.</p>
|
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>
|
657
636
|
|
658
|
-
<p>If the value given cannot be sensibly parsed into the type defined, the
|
659
|
-
block should raise an <span class='object_link'><a href="EnvParser/ValueNotConvertibleError.html" title="EnvParser::ValueNotConvertibleError (class)">ValueNotConvertibleError</a></span>.</p>
|
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>
|
660
638
|
</div>
|
661
639
|
|
662
640
|
</li>
|
@@ -771,9 +749,7 @@ block should raise an <span class='object_link'><a href="EnvParser/ValueNotConve
|
|
771
749
|
|
772
750
|
—
|
773
751
|
<div class='inline'>
|
774
|
-
<p>The value to parse/interpret. If a String is given, the value will be used
|
775
|
-
as-is. If a Symbol is given, the ENV value for the matching string key will
|
776
|
-
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>
|
777
753
|
</div>
|
778
754
|
|
779
755
|
</li>
|
@@ -814,12 +790,9 @@ be used.</p>
|
|
814
790
|
</span>
|
815
791
|
|
816
792
|
— <div class='inline'>
|
817
|
-
<p>The expected return type. A best-effort attempt is made to convert the
|
818
|
-
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>
|
819
794
|
|
820
|
-
<p>If no “as” option is given, an ArgumentError is raised. If the “as” option
|
821
|
-
given is unknown (the given type has not been previously defined via
|
822
|
-
<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>
|
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>
|
823
796
|
</div>
|
824
797
|
|
825
798
|
</li>
|
@@ -832,12 +805,7 @@ given is unknown (the given type has not been previously defined via
|
|
832
805
|
</span>
|
833
806
|
|
834
807
|
— <div class='inline'>
|
835
|
-
<p>Specifies the default value to return if the given “value” is either unset
|
836
|
-
(<code>nil</code>) or blank (<code>''</code>). Any “if_unset” value
|
837
|
-
given will be returned as-is, with no type conversion or other change
|
838
|
-
having been made. If unspecified, the “default” value for
|
839
|
-
<code>nil</code>/<code>''</code> input will depend on the “as”
|
840
|
-
type.</p>
|
808
|
+
<p>Specifies the default value to return if the given “value” is either unset (<code>nil</code>) or blank (<code>''</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>''</code> input will depend on the “as” type.</p>
|
841
809
|
</div>
|
842
810
|
|
843
811
|
</li>
|
@@ -850,18 +818,11 @@ type.</p>
|
|
850
818
|
</span>
|
851
819
|
|
852
820
|
— <div class='inline'>
|
853
|
-
<p>Gives a limited set of allowed values (after type conversion). If, after
|
854
|
-
|
855
|
-
<
|
856
|
-
|
857
|
-
<p>
|
858
|
-
<code>nil</code>/<code>''</code>, the “if_unset” value will be
|
859
|
-
returned, even if it is not part of the “from_set” list/range.</p>
|
860
|
-
|
861
|
-
<p>Also note that, due to the nature of the lookup, the “from_set” option is
|
862
|
-
only available for scalar values (i.e. not arrays, hashes, or other
|
863
|
-
enumerables). An attempt to use the “from_set” option with a non-scalar
|
864
|
-
value will raise an ArgumentError.</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>''</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>
|
865
826
|
</div>
|
866
827
|
|
867
828
|
</li>
|
@@ -874,18 +835,9 @@ value will raise an ArgumentError.</p>
|
|
874
835
|
</span>
|
875
836
|
|
876
837
|
— <div class='inline'>
|
877
|
-
<p>If given, the “validated_by” Proc is called with the parsed value (after
|
878
|
-
|
879
|
-
|
880
|
-
“from_set” option alone. If the Proc's return value is
|
881
|
-
<code>#blank?</code>, an <span class='object_link'><a href="EnvParser/ValueNotAllowedError.html" title="EnvParser::ValueNotAllowedError (class)">ValueNotAllowedError</a></span> is raised. To
|
882
|
-
accomodate your syntax of choice, this validation Proc may be given as a
|
883
|
-
block instead.</p>
|
884
|
-
|
885
|
-
<p>Note that this option is intended to provide an inspection mechanism only –
|
886
|
-
no mutation of the parsed value should occur within the given Proc. To that
|
887
|
-
end, the argument passed is a <em>frozen</em> duplicate of the parsed
|
888
|
-
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'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>
|
889
841
|
</div>
|
890
842
|
|
891
843
|
</li>
|
@@ -907,10 +859,7 @@ value.</p>
|
|
907
859
|
<div class='inline'>
|
908
860
|
<p>A block (if given) is treated exactly as the “validated_by” Proc would.</p>
|
909
861
|
|
910
|
-
<p>Although there is no compelling reason to provide both a “validated_by”
|
911
|
-
Proc <em>and</em> a validation block, there is no technical limitation
|
912
|
-
preventing this. <strong>If both are given, both validation checks must
|
913
|
-
pass.</strong></p>
|
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>
|
914
863
|
</div>
|
915
864
|
|
916
865
|
</li>
|
@@ -989,12 +938,9 @@ pass.</strong></p>
|
|
989
938
|
</h3><div class="docstring">
|
990
939
|
<div class="discussion">
|
991
940
|
|
992
|
-
<p>Parses the referenced value and creates a matching constant in the
|
993
|
-
requested context.</p>
|
941
|
+
<p>Parses the referenced value and creates a matching constant in the requested context.</p>
|
994
942
|
|
995
|
-
<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
|
996
|
-
keys are the variable names and whose values are the options set for each
|
997
|
-
variable's <span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">register</a></span> 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's <span class='object_link'><a href="#register-class_method" title="EnvParser.register (method)">register</a></span> call.</p>
|
998
944
|
<pre class="code ruby"><code class="ruby">
|
999
945
|
## Example shortcut usage:
|
1000
946
|
|
@@ -1026,9 +972,7 @@ variable's <span class='object_link'><a href="#register-class_method" title=
|
|
1026
972
|
|
1027
973
|
—
|
1028
974
|
<div class='inline'>
|
1029
|
-
<p>The name of the value to parse/interpret from the “from” Hash. If the
|
1030
|
-
“from” value is <code>ENV</code>, you may give a Symbol and the
|
1031
|
-
corresponding String key 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>
|
1032
976
|
</div>
|
1033
977
|
|
1034
978
|
</li>
|
@@ -1088,8 +1032,7 @@ corresponding String key will be used instead.</p>
|
|
1088
1032
|
</span>
|
1089
1033
|
|
1090
1034
|
— <div class='inline'>
|
1091
|
-
<p>The module or class in which the constant should be created. Creates global
|
1092
|
-
constants by default.</p>
|
1035
|
+
<p>The module or class in which the constant should be created. Creates global constants by default.</p>
|
1093
1036
|
</div>
|
1094
1037
|
|
1095
1038
|
</li>
|
@@ -1161,9 +1104,7 @@ constants by default.</p>
|
|
1161
1104
|
|
1162
1105
|
—
|
1163
1106
|
<div class='inline'>
|
1164
|
-
<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
|
1165
|
-
single block cannot be used to register multiple constants simultaneously –
|
1166
|
-
each value needing validation must give its own “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>
|
1167
1108
|
</div>
|
1168
1109
|
|
1169
1110
|
</li>
|
@@ -1265,9 +1206,9 @@ each value needing validation must give its own “validated_by” Proc.</p>
|
|
1265
1206
|
</div>
|
1266
1207
|
|
1267
1208
|
<div id="footer">
|
1268
|
-
Generated on
|
1209
|
+
Generated on Sat Jan 2 17:31:18 2021 by
|
1269
1210
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1270
|
-
0.9.
|
1211
|
+
0.9.26 (ruby-2.7.2).
|
1271
1212
|
</div>
|
1272
1213
|
|
1273
1214
|
</div>
|