dotenv-rails 2.7.4 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -5
- data/lib/dotenv/rails.rb +12 -3
- metadata +8 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a8ba4039c1bdd46569ac907b8fb2f3a76b1c6d00a451a55aadf931c15f69d90
|
4
|
+
data.tar.gz: 619354ce54dfb1689c7ccae402cfb3230df4fd0284783859906fae4c994488c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4084c7af6d0e380f3209b302d9d116acb2f7eda31879c1d5c34b9705e7667239993fab2b5d69286a7bd268813c8f0d394cfd2fca92837b4fe38f5a2adbf59535
|
7
|
+
data.tar.gz: 7cb29fd7b1572845347b8d26dd4b45141595c404d5b9b019228a712c6fd640e34b62a9fe49d664b9381ee34339d8c2ab1bbc7d6da989a7b4f526e9cc1fcad3d3
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# dotenv [![
|
1
|
+
# dotenv [![Gem Version](https://badge.fury.io/rb/dotenv.svg)](https://badge.fury.io/rb/dotenv) [![Join the chat at https://gitter.im/bkeepers/dotenv](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bkeepers/dotenv?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
2
2
|
|
3
3
|
Shim to load environment variables from `.env` into `ENV` in *development*.
|
4
4
|
|
@@ -30,7 +30,10 @@ dotenv is initialized in your Rails app during the `before_configuration` callba
|
|
30
30
|
# config/application.rb
|
31
31
|
Bundler.require(*Rails.groups)
|
32
32
|
|
33
|
-
|
33
|
+
# Load dotenv only in development or test environment
|
34
|
+
if ['development', 'test'].include? ENV['RAILS_ENV']
|
35
|
+
Dotenv::Railtie.load
|
36
|
+
end
|
34
37
|
|
35
38
|
HOSTNAME = ENV['HOSTNAME']
|
36
39
|
```
|
@@ -62,7 +65,7 @@ Dotenv.load
|
|
62
65
|
|
63
66
|
By default, `load` will look for a file called `.env` in the current working directory. Pass in multiple files and they will be loaded in order. The first value set for a variable will win.
|
64
67
|
|
65
|
-
```
|
68
|
+
```ruby
|
66
69
|
require 'dotenv'
|
67
70
|
Dotenv.load('file1.env', 'file2.env')
|
68
71
|
```
|
@@ -223,7 +226,7 @@ You can use the `-t` or `--template` flag on the dotenv cli to create a template
|
|
223
226
|
```shell
|
224
227
|
$ dotenv -t .env
|
225
228
|
```
|
226
|
-
A template will be created in your working directory named `{FINAME}.template`. So in the above example, it would create a `.env.template` file.
|
229
|
+
A template will be created in your working directory named `{FINAME}.template`. So in the above example, it would create a `.env.template` file.
|
227
230
|
|
228
231
|
The template will contain all the environment variables in your `.env` file but with their values set to the variable names.
|
229
232
|
|
@@ -233,7 +236,7 @@ S3_BUCKET=YOURS3BUCKET
|
|
233
236
|
SECRET_KEY=YOURSECRETKEYGOESHERE
|
234
237
|
```
|
235
238
|
|
236
|
-
Would become
|
239
|
+
Would become
|
237
240
|
|
238
241
|
```shell
|
239
242
|
# .env.template
|
@@ -247,6 +250,11 @@ Personally, I prefer to commit the `.env` file with development-only settings. T
|
|
247
250
|
|
248
251
|
By default, it **won't** overwrite existing environment variables as dotenv assumes the deployment environment has more knowledge about configuration than the application does. To overwrite existing environment variables you can use `Dotenv.overload`.
|
249
252
|
|
253
|
+
You can also use the `-o` or `--overload` flag on the dotenv cli to override existing `ENV` variables.
|
254
|
+
```shell
|
255
|
+
$ dotenv -o -f ".env.local,.env"
|
256
|
+
```
|
257
|
+
|
250
258
|
## Contributing
|
251
259
|
|
252
260
|
If you want a better idea of how dotenv works, check out the [Ruby Rogues Code Reading of dotenv](https://www.youtube.com/watch?v=lKmY_0uY86s).
|
data/lib/dotenv/rails.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "dotenv"
|
2
2
|
|
3
|
-
# Fix for
|
3
|
+
# Fix for rake tasks loading in development
|
4
4
|
#
|
5
5
|
# Dotenv loads environment variables when the Rails application is initialized.
|
6
6
|
# When running `rake`, the Rails application is initialized in development.
|
@@ -9,8 +9,10 @@ require "dotenv"
|
|
9
9
|
#
|
10
10
|
# See https://github.com/bkeepers/dotenv/issues/219
|
11
11
|
if defined?(Rake.application)
|
12
|
-
|
13
|
-
|
12
|
+
task_regular_expression = /^(default$|parallel:spec|spec(:|$))/
|
13
|
+
if Rake.application.top_level_tasks.grep(task_regular_expression).any?
|
14
|
+
environment = Rake.application.options.show_tasks ? "development" : "test"
|
15
|
+
Rails.env = ENV["RAILS_ENV"] ||= environment
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
@@ -39,6 +41,13 @@ module Dotenv
|
|
39
41
|
Dotenv.load(*dotenv_files)
|
40
42
|
end
|
41
43
|
|
44
|
+
# Public: Reload dotenv
|
45
|
+
#
|
46
|
+
# Same as `load`, but will override existing values in `ENV`
|
47
|
+
def overload
|
48
|
+
Dotenv.overload(*dotenv_files)
|
49
|
+
end
|
50
|
+
|
42
51
|
# Internal: `Rails.root` is nil in Rails 4.1 before the application is
|
43
52
|
# initialized, so this falls back to the `RAILS_ROOT` environment variable,
|
44
53
|
# or the current working directory.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotenv-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Keepers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: railties
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,9 +31,6 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.2'
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '6.1'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -41,9 +38,6 @@ dependencies:
|
|
41
38
|
- - ">="
|
42
39
|
- !ruby/object:Gem::Version
|
43
40
|
version: '3.2'
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '6.1'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: spring
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,7 +68,7 @@ homepage: https://github.com/bkeepers/dotenv
|
|
74
68
|
licenses:
|
75
69
|
- MIT
|
76
70
|
metadata: {}
|
77
|
-
post_install_message:
|
71
|
+
post_install_message:
|
78
72
|
rdoc_options: []
|
79
73
|
require_paths:
|
80
74
|
- lib
|
@@ -89,8 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
83
|
- !ruby/object:Gem::Version
|
90
84
|
version: '0'
|
91
85
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
93
|
-
signing_key:
|
86
|
+
rubygems_version: 3.2.32
|
87
|
+
signing_key:
|
94
88
|
specification_version: 4
|
95
89
|
summary: Autoload dotenv in Rails.
|
96
90
|
test_files: []
|