env_parser 1.6.1 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +5 -4
- data/.ruby-version +1 -1
- data/Gemfile.lock +108 -43
- data/README.md +28 -15
- data/docs/EnvParser/AutoregisterFileNotFound.html +12 -9
- data/docs/EnvParser/Error.html +10 -8
- data/docs/EnvParser/TypeAlreadyDefinedError.html +11 -8
- data/docs/EnvParser/Types/BaseTypes.html +11 -11
- data/docs/EnvParser/Types/ChronologyTypes.html +10 -9
- data/docs/EnvParser/Types/InternetTypes.html +10 -9
- data/docs/EnvParser/Types.html +12 -10
- data/docs/EnvParser/UnknownTypeError.html +12 -9
- data/docs/EnvParser/UnparseableAutoregisterSpec.html +12 -9
- data/docs/EnvParser/ValueNotAllowedError.html +12 -9
- data/docs/EnvParser/ValueNotConvertibleError.html +11 -8
- data/docs/EnvParser.html +67 -113
- data/docs/_index.html +9 -7
- data/docs/class_list.html +10 -7
- data/docs/css/common.css +1 -1
- data/docs/css/full_list.css +201 -53
- data/docs/css/style.css +991 -399
- data/docs/file.README.html +243 -315
- data/docs/file_list.html +9 -6
- data/docs/frames.html +10 -5
- data/docs/index.html +243 -315
- data/docs/js/app.js +799 -312
- data/docs/js/full_list.js +332 -214
- data/docs/method_list.html +9 -6
- data/docs/top-level-namespace.html +8 -6
- data/env_parser.gemspec +5 -5
- data/lib/env_parser/types/internet_types.rb +2 -2
- data/lib/env_parser/version.rb +1 -1
- data/lib/env_parser.rb +1 -3
- metadata +9 -21
- data/spec/env_parser/types/base_types_spec.rb +0 -98
- data/spec/env_parser/types/chronology_types_spec.rb +0 -49
- data/spec/env_parser/types/internet_types_spec.rb +0 -95
- data/spec/env_parser_spec.rb +0 -214
- data/spec/spec_helper.rb +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7a22f6fe6059d6b8831b48ade5fcaead64017946c022f5052a8e5271684f8e96
|
|
4
|
+
data.tar.gz: d214cb37e02dddb67883d52cd835d64c61eb40358210fa9e022bdaf7e20ea2d7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9a18edca052bbe93997029ca7d45667d43a0c172da047ec017ffeaaef613d4c00caa2ff2e228ad0e923d0b7bbb83c51cd1a136c4eb0b11f49aa40d403ab0a47
|
|
7
|
+
data.tar.gz: f41c2471b26f4c8884f00d83224f811391515c95ee849c5b58150185ae4945d97418e3fb23eee552f00bb00062635c3f4fc988e3e40fd5a835df97d32fa450a5
|
data/.circleci/config.yml
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
#
|
|
3
3
|
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
|
4
4
|
#
|
|
5
|
-
version: 2
|
|
5
|
+
version: 2.1
|
|
6
6
|
jobs:
|
|
7
7
|
build:
|
|
8
8
|
docker:
|
|
9
9
|
# specify the version you desire here
|
|
10
|
-
- image: cimg/ruby:3.
|
|
10
|
+
- image: cimg/ruby:3.4
|
|
11
11
|
|
|
12
12
|
# Specify service dependencies here if necessary
|
|
13
13
|
# CircleCI maintains a library of pre-built images
|
|
@@ -23,7 +23,7 @@ jobs:
|
|
|
23
23
|
- restore_cache:
|
|
24
24
|
keys:
|
|
25
25
|
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
|
26
|
-
#
|
|
26
|
+
# fall back to using the latest cache if no exact match is found
|
|
27
27
|
- v1-dependencies
|
|
28
28
|
|
|
29
29
|
- run:
|
|
@@ -34,7 +34,8 @@ jobs:
|
|
|
34
34
|
- run:
|
|
35
35
|
name: install dependencies
|
|
36
36
|
command: |
|
|
37
|
-
bundle
|
|
37
|
+
bundle config set path vendor/bundle
|
|
38
|
+
bundle install --jobs=$(nproc) --retry=3
|
|
38
39
|
|
|
39
40
|
- save_cache:
|
|
40
41
|
paths:
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.4
|
data/Gemfile.lock
CHANGED
|
@@ -1,81 +1,146 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
env_parser (1.6.
|
|
5
|
-
activesupport (>= 6.1.0, <
|
|
4
|
+
env_parser (1.6.2)
|
|
5
|
+
activesupport (>= 6.1.0, < 9)
|
|
6
6
|
chronic (~> 0)
|
|
7
7
|
chronic_duration (~> 0)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
activesupport (
|
|
13
|
-
|
|
12
|
+
activesupport (8.1.3)
|
|
13
|
+
base64
|
|
14
|
+
bigdecimal
|
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
16
|
+
connection_pool (>= 2.2.5)
|
|
17
|
+
drb
|
|
14
18
|
i18n (>= 1.6, < 2)
|
|
19
|
+
json
|
|
20
|
+
logger (>= 1.4.2)
|
|
15
21
|
minitest (>= 5.1)
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
securerandom (>= 0.3)
|
|
23
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
24
|
+
uri (>= 0.13.1)
|
|
25
|
+
ast (2.4.3)
|
|
26
|
+
base64 (0.3.0)
|
|
27
|
+
bigdecimal (4.1.2)
|
|
18
28
|
chronic (0.10.2)
|
|
19
29
|
chronic_duration (0.10.6)
|
|
20
30
|
numerizer (~> 0.1.1)
|
|
21
|
-
concurrent-ruby (1.
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
concurrent-ruby (1.3.7)
|
|
32
|
+
connection_pool (3.0.2)
|
|
33
|
+
diff-lcs (1.6.2)
|
|
34
|
+
drb (2.2.3)
|
|
35
|
+
i18n (1.15.2)
|
|
24
36
|
concurrent-ruby (~> 1.0)
|
|
25
|
-
json (2.
|
|
26
|
-
|
|
37
|
+
json (2.19.9)
|
|
38
|
+
language_server-protocol (3.17.0.5)
|
|
39
|
+
lint_roller (1.1.0)
|
|
40
|
+
logger (1.7.0)
|
|
41
|
+
minitest (6.0.6)
|
|
42
|
+
drb (~> 2.0)
|
|
43
|
+
prism (~> 1.5)
|
|
27
44
|
numerizer (0.1.1)
|
|
28
|
-
parallel (1.
|
|
29
|
-
parser (3.
|
|
45
|
+
parallel (2.1.0)
|
|
46
|
+
parser (3.3.11.1)
|
|
30
47
|
ast (~> 2.4.1)
|
|
48
|
+
racc
|
|
49
|
+
prism (1.9.0)
|
|
50
|
+
racc (1.8.1)
|
|
31
51
|
rainbow (3.1.1)
|
|
32
|
-
regexp_parser (2.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
rspec-
|
|
36
|
-
rspec-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
rspec-expectations (3.12.1)
|
|
52
|
+
regexp_parser (2.12.0)
|
|
53
|
+
rspec (3.13.2)
|
|
54
|
+
rspec-core (~> 3.13.0)
|
|
55
|
+
rspec-expectations (~> 3.13.0)
|
|
56
|
+
rspec-mocks (~> 3.13.0)
|
|
57
|
+
rspec-core (3.13.6)
|
|
58
|
+
rspec-support (~> 3.13.0)
|
|
59
|
+
rspec-expectations (3.13.5)
|
|
41
60
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
42
|
-
rspec-support (~> 3.
|
|
43
|
-
rspec-mocks (3.
|
|
61
|
+
rspec-support (~> 3.13.0)
|
|
62
|
+
rspec-mocks (3.13.8)
|
|
44
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
45
|
-
rspec-support (~> 3.
|
|
46
|
-
rspec-support (3.
|
|
64
|
+
rspec-support (~> 3.13.0)
|
|
65
|
+
rspec-support (3.13.7)
|
|
47
66
|
rspec_junit_formatter (0.6.0)
|
|
48
67
|
rspec-core (>= 2, < 4, != 2.12.0)
|
|
49
|
-
rubocop (1.
|
|
68
|
+
rubocop (1.88.0)
|
|
50
69
|
json (~> 2.3)
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
language_server-protocol (~> 3.17.0.2)
|
|
71
|
+
lint_roller (~> 1.1.0)
|
|
72
|
+
parallel (>= 1.10)
|
|
73
|
+
parser (>= 3.3.0.2)
|
|
53
74
|
rainbow (>= 2.2.2, < 4.0)
|
|
54
|
-
regexp_parser (>=
|
|
55
|
-
|
|
56
|
-
rubocop-ast (>= 1.23.0, < 2.0)
|
|
75
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
76
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
57
77
|
ruby-progressbar (~> 1.7)
|
|
58
|
-
unicode-display_width (>=
|
|
59
|
-
rubocop-ast (1.
|
|
60
|
-
parser (>= 3.
|
|
61
|
-
|
|
62
|
-
|
|
78
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
79
|
+
rubocop-ast (1.49.1)
|
|
80
|
+
parser (>= 3.3.7.2)
|
|
81
|
+
prism (~> 1.7)
|
|
82
|
+
ruby-progressbar (1.13.0)
|
|
83
|
+
securerandom (0.4.1)
|
|
84
|
+
tzinfo (2.0.6)
|
|
63
85
|
concurrent-ruby (~> 1.0)
|
|
64
|
-
unicode-display_width (2.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
86
|
+
unicode-display_width (3.2.0)
|
|
87
|
+
unicode-emoji (~> 4.1)
|
|
88
|
+
unicode-emoji (4.2.0)
|
|
89
|
+
uri (1.1.1)
|
|
90
|
+
yard (0.9.44)
|
|
68
91
|
|
|
69
92
|
PLATFORMS
|
|
70
93
|
ruby
|
|
94
|
+
x86_64-linux
|
|
71
95
|
|
|
72
96
|
DEPENDENCIES
|
|
73
|
-
bundler (~>
|
|
97
|
+
bundler (~> 4)
|
|
74
98
|
env_parser!
|
|
75
99
|
rspec (~> 3)
|
|
76
100
|
rspec_junit_formatter
|
|
77
101
|
rubocop
|
|
78
102
|
yard
|
|
79
103
|
|
|
104
|
+
CHECKSUMS
|
|
105
|
+
activesupport (8.1.3) sha256=21a5e0dfbd4c3ddd9e1317ec6a4d782fa226e7867dc70b0743acda81a1dca20e
|
|
106
|
+
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
|
107
|
+
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
|
108
|
+
bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
|
|
109
|
+
chronic (0.10.2) sha256=766f2fcce6ac3cc152249ed0f2b827770d3e517e2e87c5fba7ed74f4889d2dc3
|
|
110
|
+
chronic_duration (0.10.6) sha256=fac58d4147d3183a40811400380cafcef049f2bb02421d2fd1c6e685fbe8facc
|
|
111
|
+
concurrent-ruby (1.3.7) sha256=4412caec3a5ea2e5fdc52076724c071a81f2c0593d83b2ac8cbb8ca63b3151b0
|
|
112
|
+
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
|
|
113
|
+
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
|
|
114
|
+
drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
|
|
115
|
+
env_parser (1.6.2)
|
|
116
|
+
i18n (1.15.2) sha256=00f9eb62412fe593b2a65a97daa75300d37abb8f7202ec748e94b6d46a9dd1b5
|
|
117
|
+
json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a
|
|
118
|
+
language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
|
|
119
|
+
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
120
|
+
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
|
121
|
+
minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
|
|
122
|
+
numerizer (0.1.1) sha256=10ec9efec62472b69a3a0e275a18a44baa595ce6e2e4cfc1678d5cb2974c336f
|
|
123
|
+
parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356
|
|
124
|
+
parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54
|
|
125
|
+
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
|
|
126
|
+
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
127
|
+
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
|
|
128
|
+
regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb
|
|
129
|
+
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
130
|
+
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
131
|
+
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
132
|
+
rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
|
|
133
|
+
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
|
|
134
|
+
rspec_junit_formatter (0.6.0) sha256=40dde674e6ae4e6cc0ff560da25497677e34fefd2338cc467a8972f602b62b15
|
|
135
|
+
rubocop (1.88.0) sha256=e420ddf1662d0ef34bc8a2910ac4b396a7ddda0b51a708264405241734b08e0b
|
|
136
|
+
rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035
|
|
137
|
+
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
|
138
|
+
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
|
|
139
|
+
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
|
|
140
|
+
unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
|
|
141
|
+
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
|
|
142
|
+
uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
|
|
143
|
+
yard (0.9.44) sha256=eb087e9b631ccd887b049f303d489963945452d5e2a7eb49a5a74a7cf6887f28
|
|
144
|
+
|
|
80
145
|
BUNDLED WITH
|
|
81
|
-
|
|
146
|
+
4.0.10
|
data/README.md
CHANGED
|
@@ -8,7 +8,7 @@ If your code uses environment variables, you know that `ENV` will always surface
|
|
|
8
8
|
|
|
9
9
|
Things can get out of control pretty fast, especially as the number of environment variables in play grows. Tools like [dotenv](https://github.com/bkeepers/dotenv) help to make sure you're loading the correct **set** of variables, but [EnvParser](https://github.com/nestor-custodio/env_parser) makes **the values themselves** usable with a minimum of effort.
|
|
10
10
|
|
|
11
|
-
[Full documentation is available here](
|
|
11
|
+
[Full documentation is available here](https://nestor-custodio.github.io/env_parser/EnvParser.html), but do read below for a crash course on availble featues!
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
@@ -41,19 +41,20 @@ Things can get out of control pretty fast, especially as the number of environme
|
|
|
41
41
|
```ruby
|
|
42
42
|
# Returns an ENV value parsed "as" a specific type:
|
|
43
43
|
#
|
|
44
|
-
EnvParser.parse env_key_as_a_symbol
|
|
45
|
-
as:
|
|
46
|
-
if_unset:
|
|
47
|
-
from_set:
|
|
44
|
+
EnvParser.parse env_key_as_a_symbol,
|
|
45
|
+
as: …, # ➜ required; Symbol
|
|
46
|
+
if_unset: …, # ➜ optional; default value (of any type)
|
|
47
|
+
from_set: …, # ➜ optional; Array or Range
|
|
48
48
|
validated_by: ->(value) { … } # ➜ optional; may also be given as a block
|
|
49
49
|
|
|
50
50
|
# Parse an ENV value and register it as a constant:
|
|
51
51
|
#
|
|
52
|
-
EnvParser.register env_key_as_a_symbol
|
|
53
|
-
as:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
EnvParser.register env_key_as_a_symbol,
|
|
53
|
+
as: …, # ➜ required; Symbol
|
|
54
|
+
named: …, # ➜ optional; String or Symbol; available only if `within` is also given
|
|
55
|
+
within: …, # ➜ optional; Class or Module
|
|
56
|
+
if_unset: …, # ➜ optional; default value (of any type)
|
|
57
|
+
from_set: …, # ➜ optional; Array or Range
|
|
57
58
|
validated_by: ->(value) { … } # ➜ optional; may also be given as a block
|
|
58
59
|
|
|
59
60
|
# Registers all ENV variables as spec'ed in ".env_parser.yml":
|
|
@@ -84,7 +85,7 @@ EnvParser.add_env_bindings # ENV.parse will now be a proxy for EnvParser.parse
|
|
|
84
85
|
timeout_ms = EnvParser.parse ENV['TIMEOUT_MS'], as: :integer
|
|
85
86
|
```
|
|
86
87
|
|
|
87
|
-
You can check the full documentation for [a list of all **_as_** types available right out of the box](
|
|
88
|
+
You can check the full documentation for [a list of all **_as_** types available right out of the box](https://nestor-custodio.github.io/env_parser/EnvParser/Types.html).
|
|
88
89
|
|
|
89
90
|
- **How About Less Typing?**
|
|
90
91
|
|
|
@@ -119,6 +120,18 @@ EnvParser.add_env_bindings # ENV.parse will now be a proxy for EnvParser.parse
|
|
|
119
120
|
BEST_VIDEO # => raises NameError
|
|
120
121
|
```
|
|
121
122
|
|
|
123
|
+
`EnvParser.register`'s **_within_** option also allows for specifying what you would like the registered constant to be **_named_**, since related ENV variables will tend to have redundant names once namespaced within a single class or module. Note that `named` is only available when used alongside `within`, as it exists solely as a namespacing aid; registering ENV variables as *global* constants with different names would be a debugging nightmare.
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
ENV['CUSTOM_CLIENT_DEFAULT_HOSTNAME'] # => 'localhost'
|
|
127
|
+
ENV['CUSTOM_CLIENT_DEFAULT_PORT' ] # => '3000'
|
|
128
|
+
|
|
129
|
+
EnvParser.register :CUSTOM_CLIENT_DEFAULT_HOSTNAME, as: :string , named: :DEFAULT_HOSTNAME, within: CustomClient
|
|
130
|
+
EnvParser.register :CUSTOM_CLIENT_DEFAULT_PORT , as: :integer, named: :DEFAULT_PORT , within: CustomClient
|
|
131
|
+
CustomClient::DEFAULT_HOSTNAME # => 'localhost'
|
|
132
|
+
CustomClient::DEFAULT_PORT # => 3000
|
|
133
|
+
```
|
|
134
|
+
|
|
122
135
|
You can also register multiple constants with a single call, which is a bit cleaner.
|
|
123
136
|
|
|
124
137
|
```ruby
|
|
@@ -181,7 +194,7 @@ EnvParser.add_env_bindings # ENV.parse will now be a proxy for EnvParser.parse
|
|
|
181
194
|
ENV.parse :MISSING_VAR, as: :integer, if_unset: 250 # => 250
|
|
182
195
|
```
|
|
183
196
|
|
|
184
|
-
Note these default values are used as-is with no type conversion, so exercise caution.
|
|
197
|
+
Note these default values are used as-is, with no type conversion (because sometimes you just want `nil` 🤷), so exercise caution.
|
|
185
198
|
|
|
186
199
|
```ruby
|
|
187
200
|
ENV.parse :MISSING_VAR, as: :integer, if_unset: 'Careful!' # => 'Careful!' (NOT AN INTEGER)
|
|
@@ -202,7 +215,7 @@ EnvParser.add_env_bindings # ENV.parse will now be a proxy for EnvParser.parse
|
|
|
202
215
|
|
|
203
216
|
- **Custom Validation Of Parsed Values**
|
|
204
217
|
|
|
205
|
-
You can write your own, more complex validations by passing in a **_validated_by_** lambda or an equivalent block. The lambda/block should
|
|
218
|
+
You can write your own, more complex validations by passing in a **_validated_by_** lambda or an equivalent block. The lambda/block should expect one value (of the requested **_as_** type) and return true if the given value passes the custom validation.
|
|
206
219
|
|
|
207
220
|
```ruby
|
|
208
221
|
# Via a "validated_by" lambda ...
|
|
@@ -250,7 +263,7 @@ EnvParser.add_env_bindings # ENV.parse will now be a proxy for EnvParser.parse
|
|
|
250
263
|
|
|
251
264
|
- **The `autoregister` Call**
|
|
252
265
|
|
|
253
|
-
Consolidating all of your `EnvParser.register` calls into a single place only makes sense. A single `EnvParser.autoregister` call
|
|
266
|
+
Consolidating all of your `EnvParser.register` calls into a single place only makes sense. A single `EnvParser.autoregister` call takes a filename to read and process as a series of constant registration requests. If no filename is given, the default `".env_parser.yml"` is assumed.
|
|
254
267
|
|
|
255
268
|
You'll normally want to call `EnvParser.autoregister` as early in your application as possible. For Rails applications (and other frameworks that call `require 'bundler/setup'`), requiring the EnvParser gem via ...
|
|
256
269
|
|
|
@@ -292,7 +305,7 @@ EnvParser.add_env_bindings # ENV.parse will now be a proxy for EnvParser.parse
|
|
|
292
305
|
within: MyClassOrModule
|
|
293
306
|
```
|
|
294
307
|
|
|
295
|
-
Because no Ruby *statements* can be safely represented via YAML, the set of `EnvParser.register` options available via autoregistration is limited to **_as_**, **_within_**, **_if_unset_**, and **_from_set_**. As an additional restriction, **_from_set_** (if given) must be an array, as ranges cannot be represented in YAML.
|
|
308
|
+
Because no Ruby *statements* can be safely represented via YAML, the set of `EnvParser.register` options available via autoregistration is limited to **_as_**, **_named_**, **_within_**, **_if_unset_**, and **_from_set_**. As an additional restriction, **_from_set_** (if given) must be an array, as ranges cannot be represented in YAML.
|
|
296
309
|
|
|
297
310
|
|
|
298
311
|
## Feature Roadmap / Future Development
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
Exception: EnvParser::AutoregisterFileNotFound
|
|
8
8
|
|
|
9
|
-
— Documentation by YARD 0.9.
|
|
9
|
+
— Documentation by YARD 0.9.44
|
|
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
17
|
<script type="text/javascript">
|
|
18
18
|
pathId = "EnvParser::AutoregisterFileNotFound";
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
|
|
28
28
|
</head>
|
|
29
29
|
<body>
|
|
30
|
+
<div id="main_progress" aria-hidden="true"></div>
|
|
31
|
+
|
|
30
32
|
<div class="nav_wrap">
|
|
31
33
|
<iframe id="nav" src="../class_list.html?1"></iframe>
|
|
32
34
|
<div id="resizer"></div>
|
|
@@ -98,17 +100,17 @@
|
|
|
98
100
|
|
|
99
101
|
<dl>
|
|
100
102
|
<dt>Defined in:</dt>
|
|
101
|
-
<dd>lib/env_parser/errors.rb
|
|
103
|
+
<dd>lib/env_parser/errors.rb
|
|
104
|
+
</dd>
|
|
102
105
|
</dl>
|
|
103
106
|
|
|
104
107
|
</div>
|
|
105
108
|
|
|
106
109
|
<h2>Overview</h2><div class="docstring">
|
|
107
110
|
<div class="discussion">
|
|
108
|
-
<p>Error class used to indicate a missing auto-registration spec file (used by the
|
|
111
|
+
<p>Error class used to indicate a missing auto-registration spec file (used by the "autoregister"
|
|
109
112
|
feature).</p>
|
|
110
113
|
|
|
111
|
-
|
|
112
114
|
</div>
|
|
113
115
|
</div>
|
|
114
116
|
<div class="tags">
|
|
@@ -129,15 +131,16 @@ feature).</p>
|
|
|
129
131
|
|
|
130
132
|
|
|
131
133
|
|
|
134
|
+
|
|
132
135
|
|
|
133
136
|
</div>
|
|
134
137
|
|
|
135
138
|
<div id="footer">
|
|
136
|
-
Generated on
|
|
139
|
+
Generated on Sun Jun 21 01:17:51 2026 by
|
|
137
140
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
138
|
-
0.9.
|
|
141
|
+
0.9.44 (ruby-3.4.8).
|
|
139
142
|
</div>
|
|
140
143
|
|
|
141
144
|
</div>
|
|
142
145
|
</body>
|
|
143
|
-
</html>
|
|
146
|
+
</html>
|
data/docs/EnvParser/Error.html
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
Exception: EnvParser::Error
|
|
8
8
|
|
|
9
|
-
— Documentation by YARD 0.9.
|
|
9
|
+
— Documentation by YARD 0.9.44
|
|
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
17
|
<script type="text/javascript">
|
|
18
18
|
pathId = "EnvParser::Error";
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
|
|
28
28
|
</head>
|
|
29
29
|
<body>
|
|
30
|
+
<div id="main_progress" aria-hidden="true"></div>
|
|
31
|
+
|
|
30
32
|
<div class="nav_wrap">
|
|
31
33
|
<iframe id="nav" src="../class_list.html?1"></iframe>
|
|
32
34
|
<div id="resizer"></div>
|
|
@@ -96,7 +98,8 @@
|
|
|
96
98
|
|
|
97
99
|
<dl>
|
|
98
100
|
<dt>Defined in:</dt>
|
|
99
|
-
<dd>lib/env_parser/errors.rb
|
|
101
|
+
<dd>lib/env_parser/errors.rb
|
|
102
|
+
</dd>
|
|
100
103
|
</dl>
|
|
101
104
|
|
|
102
105
|
</div>
|
|
@@ -105,7 +108,6 @@
|
|
|
105
108
|
<div class="discussion">
|
|
106
109
|
<p>Base error class for EnvParser.</p>
|
|
107
110
|
|
|
108
|
-
|
|
109
111
|
</div>
|
|
110
112
|
</div>
|
|
111
113
|
<div class="tags">
|
|
@@ -128,11 +130,11 @@
|
|
|
128
130
|
</div>
|
|
129
131
|
|
|
130
132
|
<div id="footer">
|
|
131
|
-
Generated on
|
|
133
|
+
Generated on Sun Jun 21 01:17:51 2026 by
|
|
132
134
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
133
|
-
0.9.
|
|
135
|
+
0.9.44 (ruby-3.4.8).
|
|
134
136
|
</div>
|
|
135
137
|
|
|
136
138
|
</div>
|
|
137
139
|
</body>
|
|
138
|
-
</html>
|
|
140
|
+
</html>
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
Exception: EnvParser::TypeAlreadyDefinedError
|
|
8
8
|
|
|
9
|
-
— Documentation by YARD 0.9.
|
|
9
|
+
— Documentation by YARD 0.9.44
|
|
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
17
|
<script type="text/javascript">
|
|
18
18
|
pathId = "EnvParser::TypeAlreadyDefinedError";
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
|
|
28
28
|
</head>
|
|
29
29
|
<body>
|
|
30
|
+
<div id="main_progress" aria-hidden="true"></div>
|
|
31
|
+
|
|
30
32
|
<div class="nav_wrap">
|
|
31
33
|
<iframe id="nav" src="../class_list.html?1"></iframe>
|
|
32
34
|
<div id="resizer"></div>
|
|
@@ -98,7 +100,8 @@
|
|
|
98
100
|
|
|
99
101
|
<dl>
|
|
100
102
|
<dt>Defined in:</dt>
|
|
101
|
-
<dd>lib/env_parser/errors.rb
|
|
103
|
+
<dd>lib/env_parser/errors.rb
|
|
104
|
+
</dd>
|
|
102
105
|
</dl>
|
|
103
106
|
|
|
104
107
|
</div>
|
|
@@ -107,7 +110,6 @@
|
|
|
107
110
|
<div class="discussion">
|
|
108
111
|
<p>Error class used to indicate a type has already been defined.</p>
|
|
109
112
|
|
|
110
|
-
|
|
111
113
|
</div>
|
|
112
114
|
</div>
|
|
113
115
|
<div class="tags">
|
|
@@ -128,15 +130,16 @@
|
|
|
128
130
|
|
|
129
131
|
|
|
130
132
|
|
|
133
|
+
|
|
131
134
|
|
|
132
135
|
</div>
|
|
133
136
|
|
|
134
137
|
<div id="footer">
|
|
135
|
-
Generated on
|
|
138
|
+
Generated on Sun Jun 21 01:17:51 2026 by
|
|
136
139
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
137
|
-
0.9.
|
|
140
|
+
0.9.44 (ruby-3.4.8).
|
|
138
141
|
</div>
|
|
139
142
|
|
|
140
143
|
</div>
|
|
141
144
|
</body>
|
|
142
|
-
</html>
|
|
145
|
+
</html>
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
Module: EnvParser::Types::BaseTypes
|
|
8
8
|
|
|
9
|
-
— Documentation by YARD 0.9.
|
|
9
|
+
— Documentation by YARD 0.9.44
|
|
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
17
|
<script type="text/javascript">
|
|
18
18
|
pathId = "EnvParser::Types::BaseTypes";
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
|
|
28
28
|
</head>
|
|
29
29
|
<body>
|
|
30
|
+
<div id="main_progress" aria-hidden="true"></div>
|
|
31
|
+
|
|
30
32
|
<div class="nav_wrap">
|
|
31
33
|
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
|
32
34
|
<div id="resizer"></div>
|
|
@@ -78,7 +80,8 @@
|
|
|
78
80
|
|
|
79
81
|
<dl>
|
|
80
82
|
<dt>Defined in:</dt>
|
|
81
|
-
<dd>lib/env_parser/types/base_types.rb
|
|
83
|
+
<dd>lib/env_parser/types/base_types.rb
|
|
84
|
+
</dd>
|
|
82
85
|
</dl>
|
|
83
86
|
|
|
84
87
|
</div>
|
|
@@ -86,7 +89,6 @@
|
|
|
86
89
|
<h2>Overview</h2><div class="docstring">
|
|
87
90
|
<div class="discussion">
|
|
88
91
|
<p>Defines types for primitive classes, adding the following:</p>
|
|
89
|
-
|
|
90
92
|
<table>
|
|
91
93
|
<tbody>
|
|
92
94
|
<tr>
|
|
@@ -147,11 +149,9 @@
|
|
|
147
149
|
</tr>
|
|
148
150
|
</tbody>
|
|
149
151
|
</table>
|
|
150
|
-
|
|
151
|
-
<p>Note JSON is parsed using <em>quirks-mode</em> (meaning ‘true’, ‘25’, and ‘null’ are all considered
|
|
152
|
+
<p>Note JSON is parsed using <em>quirks-mode</em> (meaning 'true', '25', and 'null' are all considered
|
|
152
153
|
valid, parseable JSON).</p>
|
|
153
154
|
|
|
154
|
-
|
|
155
155
|
</div>
|
|
156
156
|
</div>
|
|
157
157
|
<div class="tags">
|
|
@@ -169,11 +169,11 @@ valid, parseable JSON).</p>
|
|
|
169
169
|
</div>
|
|
170
170
|
|
|
171
171
|
<div id="footer">
|
|
172
|
-
Generated on
|
|
172
|
+
Generated on Sun Jun 21 01:17:51 2026 by
|
|
173
173
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
174
|
-
0.9.
|
|
174
|
+
0.9.44 (ruby-3.4.8).
|
|
175
175
|
</div>
|
|
176
176
|
|
|
177
177
|
</div>
|
|
178
178
|
</body>
|
|
179
|
-
</html>
|
|
179
|
+
</html>
|