nvar 0.1.1 → 0.2.0
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/.github/workflows/rubyonrails-lint.yml +1 -1
- data/.tool-versions +1 -1
- data/Gemfile +3 -3
- data/Gemfile.lock +221 -144
- data/README.md +10 -2
- data/Rakefile +2 -2
- data/bin/standardrb +29 -0
- data/lib/nvar/engine.rb +3 -3
- data/lib/nvar/environment_variable.rb +8 -8
- data/lib/nvar/version.rb +1 -1
- data/lib/nvar.rb +16 -15
- data/nvar.gemspec +27 -29
- metadata +10 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcd99458bfe71f2186f552eb9c0759108c86ceeed9b9ed405edf34a758d2dfba
|
4
|
+
data.tar.gz: ec71795cc0dad1e4b8d5ba2e75dfa9c1f6e56d32df73e9244258f62615d67397
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1d1b2066a8f922f57a26aebba4c47f5b3a71475360e24899422c0bbb4650fe6ae928fc5c49190d401a43d3ce775f1e8ba91a13212ac22a011b207ddca4e6755
|
7
|
+
data.tar.gz: 1bb2f8a67579ed8a771c2f827fced75478c5a8db23dc68158ad168579c9b4292546ba6d364675ea983d2d3742c7cb6aaf04f7c578bf4d1a6e47dcd8b920c9a8d
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby
|
1
|
+
ruby 3.3.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,194 +1,273 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nvar (0.
|
4
|
+
nvar (0.2.0)
|
5
5
|
activesupport (>= 5.0.0, < 8.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (
|
11
|
-
actionpack (=
|
12
|
-
activesupport (=
|
10
|
+
actioncable (7.1.3.2)
|
11
|
+
actionpack (= 7.1.3.2)
|
12
|
+
activesupport (= 7.1.3.2)
|
13
13
|
nio4r (~> 2.0)
|
14
14
|
websocket-driver (>= 0.6.1)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
zeitwerk (~> 2.6)
|
16
|
+
actionmailbox (7.1.3.2)
|
17
|
+
actionpack (= 7.1.3.2)
|
18
|
+
activejob (= 7.1.3.2)
|
19
|
+
activerecord (= 7.1.3.2)
|
20
|
+
activestorage (= 7.1.3.2)
|
21
|
+
activesupport (= 7.1.3.2)
|
21
22
|
mail (>= 2.7.1)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
net-imap
|
24
|
+
net-pop
|
25
|
+
net-smtp
|
26
|
+
actionmailer (7.1.3.2)
|
27
|
+
actionpack (= 7.1.3.2)
|
28
|
+
actionview (= 7.1.3.2)
|
29
|
+
activejob (= 7.1.3.2)
|
30
|
+
activesupport (= 7.1.3.2)
|
27
31
|
mail (~> 2.5, >= 2.5.4)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
net-imap
|
33
|
+
net-pop
|
34
|
+
net-smtp
|
35
|
+
rails-dom-testing (~> 2.2)
|
36
|
+
actionpack (7.1.3.2)
|
37
|
+
actionview (= 7.1.3.2)
|
38
|
+
activesupport (= 7.1.3.2)
|
39
|
+
nokogiri (>= 1.8.5)
|
40
|
+
racc
|
41
|
+
rack (>= 2.2.4)
|
42
|
+
rack-session (>= 1.0.1)
|
33
43
|
rack-test (>= 0.6.3)
|
34
|
-
rails-dom-testing (~> 2.
|
35
|
-
rails-html-sanitizer (~> 1.
|
36
|
-
actiontext (
|
37
|
-
actionpack (=
|
38
|
-
activerecord (=
|
39
|
-
activestorage (=
|
40
|
-
activesupport (=
|
44
|
+
rails-dom-testing (~> 2.2)
|
45
|
+
rails-html-sanitizer (~> 1.6)
|
46
|
+
actiontext (7.1.3.2)
|
47
|
+
actionpack (= 7.1.3.2)
|
48
|
+
activerecord (= 7.1.3.2)
|
49
|
+
activestorage (= 7.1.3.2)
|
50
|
+
activesupport (= 7.1.3.2)
|
51
|
+
globalid (>= 0.6.0)
|
41
52
|
nokogiri (>= 1.8.5)
|
42
|
-
actionview (
|
43
|
-
activesupport (=
|
53
|
+
actionview (7.1.3.2)
|
54
|
+
activesupport (= 7.1.3.2)
|
44
55
|
builder (~> 3.1)
|
45
|
-
erubi (~> 1.
|
46
|
-
rails-dom-testing (~> 2.
|
47
|
-
rails-html-sanitizer (~> 1.
|
48
|
-
activejob (
|
49
|
-
activesupport (=
|
56
|
+
erubi (~> 1.11)
|
57
|
+
rails-dom-testing (~> 2.2)
|
58
|
+
rails-html-sanitizer (~> 1.6)
|
59
|
+
activejob (7.1.3.2)
|
60
|
+
activesupport (= 7.1.3.2)
|
50
61
|
globalid (>= 0.3.6)
|
51
|
-
activemodel (
|
52
|
-
activesupport (=
|
53
|
-
activerecord (
|
54
|
-
activemodel (=
|
55
|
-
activesupport (=
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
activesupport (
|
62
|
+
activemodel (7.1.3.2)
|
63
|
+
activesupport (= 7.1.3.2)
|
64
|
+
activerecord (7.1.3.2)
|
65
|
+
activemodel (= 7.1.3.2)
|
66
|
+
activesupport (= 7.1.3.2)
|
67
|
+
timeout (>= 0.4.0)
|
68
|
+
activestorage (7.1.3.2)
|
69
|
+
actionpack (= 7.1.3.2)
|
70
|
+
activejob (= 7.1.3.2)
|
71
|
+
activerecord (= 7.1.3.2)
|
72
|
+
activesupport (= 7.1.3.2)
|
73
|
+
marcel (~> 1.0)
|
74
|
+
activesupport (7.1.3.2)
|
75
|
+
base64
|
76
|
+
bigdecimal
|
64
77
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
78
|
+
connection_pool (>= 2.2.5)
|
79
|
+
drb
|
65
80
|
i18n (>= 1.6, < 2)
|
66
81
|
minitest (>= 5.1)
|
82
|
+
mutex_m
|
67
83
|
tzinfo (~> 2.0)
|
68
|
-
zeitwerk (~> 2.3)
|
69
84
|
ast (2.4.2)
|
85
|
+
base64 (0.2.0)
|
86
|
+
bigdecimal (3.1.6)
|
70
87
|
builder (3.2.4)
|
71
|
-
bundler-audit (0.9.
|
88
|
+
bundler-audit (0.9.1)
|
72
89
|
bundler (>= 1.2.0, < 3)
|
73
90
|
thor (~> 1.0)
|
74
91
|
byebug (11.1.3)
|
75
|
-
climate_control (1.0
|
76
|
-
concurrent-ruby (1.
|
92
|
+
climate_control (1.2.0)
|
93
|
+
concurrent-ruby (1.2.3)
|
94
|
+
connection_pool (2.4.1)
|
77
95
|
crass (1.0.6)
|
78
|
-
|
96
|
+
date (3.3.4)
|
97
|
+
diff-lcs (1.5.1)
|
79
98
|
docile (1.4.0)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
99
|
+
drb (2.2.0)
|
100
|
+
ruby2_keywords
|
101
|
+
erubi (1.12.0)
|
102
|
+
globalid (1.2.1)
|
103
|
+
activesupport (>= 6.1)
|
104
|
+
i18n (1.14.1)
|
84
105
|
concurrent-ruby (~> 1.0)
|
85
|
-
|
106
|
+
io-console (0.7.2)
|
107
|
+
irb (1.11.2)
|
108
|
+
rdoc
|
109
|
+
reline (>= 0.4.2)
|
110
|
+
json (2.7.1)
|
111
|
+
language_server-protocol (3.17.0.3)
|
112
|
+
lint_roller (1.1.0)
|
113
|
+
loofah (2.22.0)
|
86
114
|
crass (~> 1.0.2)
|
87
|
-
nokogiri (>= 1.
|
88
|
-
mail (2.
|
115
|
+
nokogiri (>= 1.12.0)
|
116
|
+
mail (2.8.1)
|
89
117
|
mini_mime (>= 0.1.1)
|
118
|
+
net-imap
|
119
|
+
net-pop
|
120
|
+
net-smtp
|
90
121
|
marcel (1.0.2)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
122
|
+
mini_mime (1.1.5)
|
123
|
+
minitest (5.22.2)
|
124
|
+
mutex_m (0.2.0)
|
125
|
+
net-imap (0.4.10)
|
126
|
+
date
|
127
|
+
net-protocol
|
128
|
+
net-pop (0.1.2)
|
129
|
+
net-protocol
|
130
|
+
net-protocol (0.2.2)
|
131
|
+
timeout
|
132
|
+
net-smtp (0.4.0.1)
|
133
|
+
net-protocol
|
134
|
+
nio4r (2.7.0)
|
135
|
+
nokogiri (1.16.2-aarch64-linux)
|
136
|
+
racc (~> 1.4)
|
137
|
+
nokogiri (1.16.2-arm-linux)
|
138
|
+
racc (~> 1.4)
|
139
|
+
nokogiri (1.16.2-arm64-darwin)
|
140
|
+
racc (~> 1.4)
|
141
|
+
nokogiri (1.16.2-x86-linux)
|
98
142
|
racc (~> 1.4)
|
99
|
-
|
100
|
-
|
143
|
+
nokogiri (1.16.2-x86_64-darwin)
|
144
|
+
racc (~> 1.4)
|
145
|
+
nokogiri (1.16.2-x86_64-linux)
|
146
|
+
racc (~> 1.4)
|
147
|
+
parallel (1.24.0)
|
148
|
+
parser (3.3.0.5)
|
101
149
|
ast (~> 2.4.1)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
150
|
+
racc
|
151
|
+
psych (5.1.2)
|
152
|
+
stringio
|
153
|
+
racc (1.7.3)
|
154
|
+
rack (3.0.9.1)
|
155
|
+
rack-session (2.0.0)
|
156
|
+
rack (>= 3.0.0)
|
157
|
+
rack-test (2.1.0)
|
158
|
+
rack (>= 1.3)
|
159
|
+
rackup (2.1.0)
|
160
|
+
rack (>= 3)
|
161
|
+
webrick (~> 1.8)
|
162
|
+
rails (7.1.3.2)
|
163
|
+
actioncable (= 7.1.3.2)
|
164
|
+
actionmailbox (= 7.1.3.2)
|
165
|
+
actionmailer (= 7.1.3.2)
|
166
|
+
actionpack (= 7.1.3.2)
|
167
|
+
actiontext (= 7.1.3.2)
|
168
|
+
actionview (= 7.1.3.2)
|
169
|
+
activejob (= 7.1.3.2)
|
170
|
+
activemodel (= 7.1.3.2)
|
171
|
+
activerecord (= 7.1.3.2)
|
172
|
+
activestorage (= 7.1.3.2)
|
173
|
+
activesupport (= 7.1.3.2)
|
118
174
|
bundler (>= 1.15.0)
|
119
|
-
railties (=
|
120
|
-
|
121
|
-
|
122
|
-
|
175
|
+
railties (= 7.1.3.2)
|
176
|
+
rails-dom-testing (2.2.0)
|
177
|
+
activesupport (>= 5.0.0)
|
178
|
+
minitest
|
123
179
|
nokogiri (>= 1.6)
|
124
|
-
rails-html-sanitizer (1.
|
125
|
-
loofah (~> 2.
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
180
|
+
rails-html-sanitizer (1.6.0)
|
181
|
+
loofah (~> 2.21)
|
182
|
+
nokogiri (~> 1.14)
|
183
|
+
railties (7.1.3.2)
|
184
|
+
actionpack (= 7.1.3.2)
|
185
|
+
activesupport (= 7.1.3.2)
|
186
|
+
irb
|
187
|
+
rackup (>= 1.0.0)
|
188
|
+
rake (>= 12.2)
|
189
|
+
thor (~> 1.0, >= 1.2.2)
|
190
|
+
zeitwerk (~> 2.6)
|
191
|
+
rainbow (3.1.1)
|
133
192
|
rake (12.3.3)
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
rspec
|
141
|
-
rspec-
|
142
|
-
|
193
|
+
rdoc (6.6.2)
|
194
|
+
psych (>= 4.0.0)
|
195
|
+
regexp_parser (2.9.0)
|
196
|
+
reline (0.4.3)
|
197
|
+
io-console (~> 0.5)
|
198
|
+
rexml (3.2.6)
|
199
|
+
rspec (3.13.0)
|
200
|
+
rspec-core (~> 3.13.0)
|
201
|
+
rspec-expectations (~> 3.13.0)
|
202
|
+
rspec-mocks (~> 3.13.0)
|
203
|
+
rspec-core (3.13.0)
|
204
|
+
rspec-support (~> 3.13.0)
|
205
|
+
rspec-expectations (3.13.0)
|
143
206
|
diff-lcs (>= 1.2.0, < 2.0)
|
144
|
-
rspec-support (~> 3.
|
145
|
-
rspec-mocks (3.
|
207
|
+
rspec-support (~> 3.13.0)
|
208
|
+
rspec-mocks (3.13.0)
|
146
209
|
diff-lcs (>= 1.2.0, < 2.0)
|
147
|
-
rspec-support (~> 3.
|
148
|
-
rspec-support (3.
|
149
|
-
rubocop (1.
|
210
|
+
rspec-support (~> 3.13.0)
|
211
|
+
rspec-support (3.13.1)
|
212
|
+
rubocop (1.60.2)
|
213
|
+
json (~> 2.3)
|
214
|
+
language_server-protocol (>= 3.17.0)
|
150
215
|
parallel (~> 1.10)
|
151
|
-
parser (>= 3.
|
216
|
+
parser (>= 3.3.0.2)
|
152
217
|
rainbow (>= 2.2.2, < 4.0)
|
153
218
|
regexp_parser (>= 1.8, < 3.0)
|
154
|
-
rexml
|
155
|
-
rubocop-ast (>= 1.
|
219
|
+
rexml (>= 3.2.5, < 4.0)
|
220
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
156
221
|
ruby-progressbar (~> 1.7)
|
157
|
-
unicode-display_width (>=
|
158
|
-
rubocop-ast (1.
|
159
|
-
parser (>= 3.
|
160
|
-
rubocop-
|
161
|
-
rubocop (
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
simplecov (0.21.2)
|
222
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
223
|
+
rubocop-ast (1.30.0)
|
224
|
+
parser (>= 3.2.1.0)
|
225
|
+
rubocop-performance (1.20.2)
|
226
|
+
rubocop (>= 1.48.1, < 2.0)
|
227
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
228
|
+
ruby-progressbar (1.13.0)
|
229
|
+
ruby2_keywords (0.0.5)
|
230
|
+
simplecov (0.22.0)
|
167
231
|
docile (~> 1.1)
|
168
232
|
simplecov-html (~> 0.11)
|
169
233
|
simplecov_json_formatter (~> 0.1)
|
170
234
|
simplecov-html (0.12.3)
|
171
|
-
simplecov_json_formatter (0.1.
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
235
|
+
simplecov_json_formatter (0.1.4)
|
236
|
+
standard (1.34.0)
|
237
|
+
language_server-protocol (~> 3.17.0.2)
|
238
|
+
lint_roller (~> 1.0)
|
239
|
+
rubocop (~> 1.60)
|
240
|
+
standard-custom (~> 1.0.0)
|
241
|
+
standard-performance (~> 1.3)
|
242
|
+
standard-custom (1.0.2)
|
243
|
+
lint_roller (~> 1.0)
|
244
|
+
rubocop (~> 1.50)
|
245
|
+
standard-performance (1.3.1)
|
246
|
+
lint_roller (~> 1.1)
|
247
|
+
rubocop-performance (~> 1.20.2)
|
248
|
+
standardrb (1.0.1)
|
249
|
+
standard
|
250
|
+
stringio (3.1.0)
|
251
|
+
tempfile (0.2.1)
|
252
|
+
thor (1.3.1)
|
253
|
+
timeout (0.4.1)
|
254
|
+
tzinfo (2.0.6)
|
182
255
|
concurrent-ruby (~> 1.0)
|
183
|
-
unicode-display_width (2.
|
184
|
-
vcr (6.
|
185
|
-
|
256
|
+
unicode-display_width (2.5.0)
|
257
|
+
vcr (6.2.0)
|
258
|
+
webrick (1.8.1)
|
259
|
+
websocket-driver (0.7.6)
|
186
260
|
websocket-extensions (>= 0.1.0)
|
187
261
|
websocket-extensions (0.1.5)
|
188
|
-
zeitwerk (2.
|
262
|
+
zeitwerk (2.6.13)
|
189
263
|
|
190
264
|
PLATFORMS
|
191
|
-
|
265
|
+
aarch64-linux
|
266
|
+
arm-linux
|
267
|
+
arm64-darwin
|
268
|
+
x86-linux
|
269
|
+
x86_64-darwin
|
270
|
+
x86_64-linux
|
192
271
|
|
193
272
|
DEPENDENCIES
|
194
273
|
bundler-audit
|
@@ -198,12 +277,10 @@ DEPENDENCIES
|
|
198
277
|
rails
|
199
278
|
rake (~> 12.0)
|
200
279
|
rspec (~> 3.0)
|
201
|
-
rubocop (~> 1.12.0)
|
202
|
-
rubocop-rake
|
203
|
-
rubocop-rspec
|
204
280
|
simplecov
|
281
|
+
standardrb
|
205
282
|
tempfile
|
206
283
|
vcr
|
207
284
|
|
208
285
|
BUNDLED WITH
|
209
|
-
2.
|
286
|
+
2.5.6
|
data/README.md
CHANGED
@@ -60,9 +60,13 @@ Your tests shouldn't be reliant on your environment, so generally, you want to h
|
|
60
60
|
Now that you've been through and configured the environment variables that are necessary for your app, `Nvar` will write your environment variables to top-level constants, cast to any types you've specified, and raise an informative error if any are absent.
|
61
61
|
### .env files
|
62
62
|
|
63
|
-
`Nvar` works well with gems like `dotenv` that source their config from a `.env` file. If an environment variable is unset when the app initializes and isn't present in `.env`, it will be added to that file. If a default value is specified in your `Nvar` config, that will be passed to `.env` too.
|
63
|
+
`Nvar` works well with gems like `dotenv-rails` that source their config from a `.env` file. If an environment variable is unset when the app initializes and isn't present in `.env`, it will be added to that file. If a default value is specified in your `Nvar` config, that will be passed to `.env` too.
|
64
64
|
|
65
|
-
When using gems such as `dotenv`, make sure you load those first so that the environment is ready for `Nvar` to check.
|
65
|
+
When using gems such as `dotenv-rails`, make sure you load those first so that the environment is ready for `Nvar` to check.
|
66
|
+
|
67
|
+
### `rake nvar:verify_environment_file`
|
68
|
+
|
69
|
+
This Rake task provided by `Nvar` is super helpful for your project's developer experience. Based on what's currently in the environment, it'll show any environment variables that are missing and add declarations for them to `.env`. And if you've set a `default_value` in your config, that'll get written too.
|
66
70
|
|
67
71
|
## Development
|
68
72
|
|
@@ -82,3 +86,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
82
86
|
## Code of Conduct
|
83
87
|
|
84
88
|
Everyone interacting in the Nvar project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/boardfish/nvar/blob/master/CODE_OF_CONDUCT.md).
|
89
|
+
|
90
|
+
## This gem's name
|
91
|
+
|
92
|
+
This gem isn't associated with [sneakertack/nvar](https://github.com/sneakertack/nvar).
|
data/Rakefile
CHANGED
data/bin/standardrb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'standardrb' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("standard", "standardrb")
|
data/lib/nvar/engine.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "rails"
|
4
|
+
require_relative "environment_variable"
|
5
5
|
|
6
6
|
module Nvar
|
7
7
|
class Engine < Rails::Engine # :nodoc:
|
@@ -21,7 +21,7 @@ module Nvar
|
|
21
21
|
end
|
22
22
|
|
23
23
|
rake_tasks do
|
24
|
-
load
|
24
|
+
load "nvar/rails/tasks/verify_environment_file.rake"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
# Wrapper for retrieval of environment variables. See
|
4
4
|
# config/initializers/environment_variable_loader.rb to check out how it's used.
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
5
|
+
require "active_support/core_ext/hash/keys"
|
6
|
+
require "active_support/core_ext/object/blank"
|
7
|
+
require "yaml"
|
8
8
|
|
9
9
|
module Nvar
|
10
10
|
# Wrapper for loading environment variables, used across relevant Rake tasks
|
11
11
|
class EnvironmentVariable
|
12
12
|
attr_reader :name, :type, :value, :required, :defined
|
13
13
|
|
14
|
-
def initialize(name:, type:
|
14
|
+
def initialize(name:, type: "String", filter_from_requests: nil, **args)
|
15
15
|
@name = name
|
16
16
|
@type = type
|
17
17
|
@required = args[:required].nil? ? true : args[:required]
|
18
18
|
@filter_from_requests = filter_from_requests.yield_self { |f| [true, false].include?(f) ? f : f&.to_sym }
|
19
|
-
@value = fetch_value(args.slice(:passthrough, :default_value))
|
19
|
+
@value = fetch_value(**args.slice(:passthrough, :default_value))
|
20
20
|
@defined = true
|
21
21
|
rescue KeyError
|
22
22
|
@value = args[:default_value]
|
@@ -40,7 +40,7 @@ module Nvar
|
|
40
40
|
def add_to_env_file
|
41
41
|
return if present_in_env_file?
|
42
42
|
|
43
|
-
File.write(Nvar.env_file_path, to_env_assign, mode:
|
43
|
+
File.write(Nvar.env_file_path, to_env_assign, mode: "a")
|
44
44
|
end
|
45
45
|
|
46
46
|
def filter_from_vcr_cassettes(config)
|
@@ -50,7 +50,7 @@ module Nvar
|
|
50
50
|
# :nocov:
|
51
51
|
case @filter_from_requests
|
52
52
|
when :alone_as_basic_auth_password
|
53
|
-
Base64.encode64([
|
53
|
+
Base64.encode64(["", @value].join(":")).delete("\n")
|
54
54
|
when true
|
55
55
|
@value
|
56
56
|
end
|
@@ -76,7 +76,7 @@ module Nvar
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def fetch_value(passthrough: false, default_value: nil)
|
79
|
-
return
|
79
|
+
return default_value || name if ENV["RAILS_ENV"] == "test" && !passthrough
|
80
80
|
|
81
81
|
required ? ENV.fetch(name.to_s) : ENV[name.to_s]
|
82
82
|
end
|
data/lib/nvar/version.rb
CHANGED
data/lib/nvar.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "nvar/version"
|
4
|
+
require "nvar/environment_variable"
|
5
|
+
require "nvar/engine" if defined?(Rails)
|
6
|
+
require "active_support/core_ext/module/attribute_accessors"
|
7
7
|
|
8
8
|
# Centralized configuration for required environment variables in your Ruby app.
|
9
9
|
module Nvar
|
10
|
-
mattr_accessor :config_file_path, default: File.expand_path(
|
11
|
-
mattr_accessor :env_file_path, default: File.expand_path(
|
10
|
+
mattr_accessor :config_file_path, default: File.expand_path("config/environment_variables.yml")
|
11
|
+
mattr_accessor :env_file_path, default: File.expand_path(".env")
|
12
12
|
|
13
13
|
# Comments in .env files must have a leading '#' symbol. This cannot be
|
14
14
|
# followed by a space.
|
15
|
-
ENV_COMMENT = <<~
|
15
|
+
ENV_COMMENT = <<~COMMENT
|
16
16
|
#Environment variables are managed through this file (.env). The Scripts to
|
17
17
|
#Rule Them All (in script/) load the environment from here, and the app warns
|
18
18
|
#on startup if any required environment variables are missing. You can see the
|
@@ -33,16 +33,16 @@ module Nvar
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def message
|
36
|
-
"The following variables are unset or blank: #{vars.map(&:name).join(
|
36
|
+
"The following variables are unset or blank: #{vars.map(&:name).join(", ")}"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
class << self
|
41
41
|
def configure_for_rails(app)
|
42
|
-
self.config_file_path = app.root.join(
|
43
|
-
self.env_file_path = app.root.join(
|
42
|
+
self.config_file_path = app.root.join("config/environment_variables.yml")
|
43
|
+
self.env_file_path = app.root.join(".env")
|
44
44
|
[config_file_path, env_file_path].each do |path|
|
45
|
-
File.open(path,
|
45
|
+
File.open(path, "w") {} unless path.exist? # rubocop:disable Lint/EmptyBlock
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -62,19 +62,20 @@ module Nvar
|
|
62
62
|
|
63
63
|
def all
|
64
64
|
variables.map do |variable_name, config|
|
65
|
+
# TODO: Passthrough from environment behaviour might need to go here?
|
65
66
|
EnvironmentVariable.new(**(config || {}).merge(name: variable_name))
|
66
67
|
end.partition(&:set?)
|
67
68
|
end
|
68
69
|
|
69
70
|
def touch_env
|
70
|
-
File.write(env_file_path, ENV_COMMENT, mode:
|
71
|
+
File.write(env_file_path, ENV_COMMENT, mode: "w") unless File.exist?(env_file_path)
|
71
72
|
end
|
72
73
|
|
73
74
|
def verify_env(write_to_file: true)
|
74
75
|
_set, unset = all
|
75
76
|
return true if all_required_env_variables_set?
|
76
77
|
|
77
|
-
puts
|
78
|
+
puts "Please update .env with values for each environment variable:"
|
78
79
|
touch_env if write_to_file
|
79
80
|
unset.each do |variable|
|
80
81
|
variable.add_to_env_file if write_to_file
|
@@ -88,11 +89,11 @@ module Nvar
|
|
88
89
|
private
|
89
90
|
|
90
91
|
def all_required_env_variables_set?
|
91
|
-
all[1].none? || ENV[
|
92
|
+
all[1].none? || ENV["RAILS_ENV"] == "test"
|
92
93
|
end
|
93
94
|
|
94
95
|
def variables
|
95
|
-
(YAML.
|
96
|
+
(YAML.safe_load_file(config_file_path) || {}).deep_symbolize_keys
|
96
97
|
end
|
97
98
|
end
|
98
99
|
end
|
data/nvar.gemspec
CHANGED
@@ -1,45 +1,43 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "lib/nvar/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = "nvar"
|
7
|
+
spec.version = Nvar::VERSION
|
8
|
+
spec.authors = ["Simon Fish"]
|
9
|
+
spec.email = ["si@mon.fish"]
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
11
|
+
spec.summary = "Manage environment variables in Ruby"
|
12
|
+
spec.description = "Manage environment variables in Ruby"
|
13
|
+
spec.homepage = "https://github.com/boardfish/nvar"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3")
|
16
16
|
|
17
|
-
spec.metadata[
|
17
|
+
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
18
|
|
19
|
-
spec.metadata[
|
20
|
-
spec.metadata[
|
21
|
-
spec.metadata[
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
22
22
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
25
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
26
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
27
|
end
|
28
|
-
spec.bindir
|
29
|
-
spec.executables
|
30
|
-
spec.require_paths = [
|
31
|
-
spec.add_runtime_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
38
|
-
spec.add_development_dependency
|
39
|
-
spec.add_development_dependency
|
40
|
-
spec.add_development_dependency 'tempfile'
|
41
|
-
spec.add_development_dependency 'vcr'
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
spec.add_runtime_dependency "activesupport", [">= 5.0.0", "< 8.0"]
|
32
|
+
spec.add_development_dependency "bundler-audit"
|
33
|
+
spec.add_development_dependency "byebug"
|
34
|
+
spec.add_development_dependency "climate_control"
|
35
|
+
spec.add_development_dependency "rails"
|
36
|
+
spec.add_development_dependency "simplecov"
|
37
|
+
spec.add_development_dependency "standardrb"
|
38
|
+
spec.add_development_dependency "tempfile"
|
39
|
+
spec.add_development_dependency "vcr"
|
42
40
|
spec.metadata = {
|
43
|
-
|
41
|
+
"rubygems_mfa_required" => "true"
|
44
42
|
}
|
45
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nvar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Fish
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -87,35 +87,7 @@ dependencies:
|
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: 1.12.0
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 1.12.0
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: rubocop-rake
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - ">="
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - ">="
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '0'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: rubocop-rspec
|
90
|
+
name: simplecov
|
119
91
|
requirement: !ruby/object:Gem::Requirement
|
120
92
|
requirements:
|
121
93
|
- - ">="
|
@@ -129,7 +101,7 @@ dependencies:
|
|
129
101
|
- !ruby/object:Gem::Version
|
130
102
|
version: '0'
|
131
103
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
104
|
+
name: standardrb
|
133
105
|
requirement: !ruby/object:Gem::Requirement
|
134
106
|
requirements:
|
135
107
|
- - ">="
|
@@ -203,6 +175,7 @@ files:
|
|
203
175
|
- bin/rspec
|
204
176
|
- bin/rubocop
|
205
177
|
- bin/setup
|
178
|
+
- bin/standardrb
|
206
179
|
- lib/nvar.rb
|
207
180
|
- lib/nvar/engine.rb
|
208
181
|
- lib/nvar/environment_variable.rb
|
@@ -215,7 +188,7 @@ licenses:
|
|
215
188
|
- MIT
|
216
189
|
metadata:
|
217
190
|
rubygems_mfa_required: 'true'
|
218
|
-
post_install_message:
|
191
|
+
post_install_message:
|
219
192
|
rdoc_options: []
|
220
193
|
require_paths:
|
221
194
|
- lib
|
@@ -223,15 +196,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
196
|
requirements:
|
224
197
|
- - ">="
|
225
198
|
- !ruby/object:Gem::Version
|
226
|
-
version:
|
199
|
+
version: '3'
|
227
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
201
|
requirements:
|
229
202
|
- - ">="
|
230
203
|
- !ruby/object:Gem::Version
|
231
204
|
version: '0'
|
232
205
|
requirements: []
|
233
|
-
rubygems_version: 3.
|
234
|
-
signing_key:
|
206
|
+
rubygems_version: 3.5.5
|
207
|
+
signing_key:
|
235
208
|
specification_version: 4
|
236
209
|
summary: Manage environment variables in Ruby
|
237
210
|
test_files: []
|