dotenv 3.0.0.beta → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +54 -6
- data/lib/dotenv/rails.rb +17 -6
- data/lib/dotenv/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e57f916c7fa013b9da143c732ce59d5e37a1707f4cbe9e3ddbb8282eb4a2e977
|
4
|
+
data.tar.gz: a53a753dffcd865f14d92ab7a3d531c2e0e5c9f5157fe29dd6489c767021db0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ca0b269215814e535d5d8ac4480defa76f10a13438906b8211c16feef4b603d2f9085b0376d2612b3fa5c74d636a69f6987b121f2b1099b261c7ed7cf6519aa
|
7
|
+
data.tar.gz: f1c5569eedf88df8c1c62a611eedbc57f4bb6ab464ef3aed432efc902aca041ee74c956799271ae8dda78793085c32c3c8626bf303c9bbf13146e12d19f87cad
|
data/README.md
CHANGED
@@ -56,9 +56,9 @@ Dotenv.load('file1.env', 'file2.env')
|
|
56
56
|
|
57
57
|
## Autorestore in tests
|
58
58
|
|
59
|
-
Since 3.0, dotenv in a Rails app will automatically restore `ENV`
|
59
|
+
Since 3.0, dotenv in a Rails app will automatically restore `ENV` after each test. This means you can modify `ENV` in your tests without fear of leaking state to other tests. It works with both `ActiveSupport::TestCase` and `Rspec`.
|
60
60
|
|
61
|
-
To disable this behavior, set `config.dotenv.autorestore = false` in `config/application.rb` or `config/environments/test.rb`.
|
61
|
+
To disable this behavior, set `config.dotenv.autorestore = false` in `config/application.rb` or `config/environments/test.rb`. It is disabled by default if your app uses [climate_control](https://github.com/thoughtbot/climate_control) or [ice_age](https://github.com/dpep/ice_age_rb).
|
62
62
|
|
63
63
|
To use this behavior outside of a Rails app, just `require "dotenv/autorestore"` in your test suite.
|
64
64
|
|
@@ -107,11 +107,59 @@ gem 'gem-that-requires-env-variables'
|
|
107
107
|
|
108
108
|
### Customizing Rails
|
109
109
|
|
110
|
-
Dotenv will load the following files depending on `RAILS_ENV`, with the
|
110
|
+
Dotenv will load the following files depending on `RAILS_ENV`, with the first file having the highest precedence, and `.env` having the lowest precedence:
|
111
|
+
|
112
|
+
<table>
|
113
|
+
<thead>
|
114
|
+
<tr>
|
115
|
+
<th>Priority</th>
|
116
|
+
<th colspan="3">Environment</th>
|
117
|
+
<th><code>.gitignore</code>it?</th>
|
118
|
+
<th>Notes</th>
|
119
|
+
</tr>
|
120
|
+
<tr>
|
121
|
+
<th></th>
|
122
|
+
<th>development</th>
|
123
|
+
<th>test</th>
|
124
|
+
<th>production</th>
|
125
|
+
<th></th>
|
126
|
+
<th></th>
|
127
|
+
</tr>
|
128
|
+
</thead>
|
129
|
+
<tr>
|
130
|
+
<td>highest</td>
|
131
|
+
<td><code>.env.development.local</code></td>
|
132
|
+
<td><code>.env.test.local</code></td>
|
133
|
+
<td><code>.env.production.local</code></td>
|
134
|
+
<td>Yes</td>
|
135
|
+
<td>Environment-specific local overrides</td>
|
136
|
+
</tr>
|
137
|
+
<tr>
|
138
|
+
<td>2nd</td>
|
139
|
+
<td><code>.env.local</code></td>
|
140
|
+
<td><strong>N/A</strong></td>
|
141
|
+
<td><code>.env.local</code></td>
|
142
|
+
<td>Yes</td>
|
143
|
+
<td>Local overrides</td>
|
144
|
+
</tr>
|
145
|
+
<tr>
|
146
|
+
<td>3rd</td>
|
147
|
+
<td><code>.env.development</code></td>
|
148
|
+
<td><code>.env.test</code></td>
|
149
|
+
<td><code>.env.production</code></td>
|
150
|
+
<td>No</td>
|
151
|
+
<td>Shared environment-specific variables</td>
|
152
|
+
</tr>
|
153
|
+
<tr>
|
154
|
+
<td>last</td>
|
155
|
+
<td><code>.env</code></td>
|
156
|
+
<td><code>.env</code></td>
|
157
|
+
<td><code>.env</code></td>
|
158
|
+
<td><a href="#should-i-commit-my-env-file">Maybe</a></td>
|
159
|
+
<td>Shared for all environments</td>
|
160
|
+
</tr>
|
161
|
+
</table>
|
111
162
|
|
112
|
-
* **development**: `.env`, `.env.development`, `.env.local`, `.env.development.local`
|
113
|
-
* **test**: `.env`, `.env.test`, `.env.test.local` - Note that it will **not** load `.env.local`.
|
114
|
-
* **development**: `.env`, `.env.production`, `.env.local`, `.env.production.local`
|
115
163
|
|
116
164
|
These files are loaded during the `before_configuration` callback, which is fired when the `Application` constant is defined in `config/application.rb` with `class Application < Rails::Application`. If you need it to be initialized sooner, or need to customize the loading process, you can do so at the top of `application.rb`
|
117
165
|
|
data/lib/dotenv/rails.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# Since rubygems doesn't support optional dependencies, we have to manually check
|
2
|
+
unless Gem::Requirement.new(">= 6.1").satisfied_by?(Gem::Version.new(Rails.version))
|
3
|
+
warn "dotenv 3.0 only supports Rails 6.1 or later. Use dotenv ~> 2.0."
|
4
|
+
return
|
5
|
+
end
|
6
|
+
|
1
7
|
require "dotenv"
|
2
8
|
require "dotenv/replay_logger"
|
3
9
|
require "dotenv/log_subscriber"
|
@@ -18,7 +24,7 @@ end
|
|
18
24
|
module Dotenv
|
19
25
|
# Rails integration for using Dotenv to load ENV variables from a file
|
20
26
|
class Rails < ::Rails::Railtie
|
21
|
-
delegate :files
|
27
|
+
delegate :files=, :overwrite, :overwrite=, :autorestore, :autorestore=, :logger, :logger=, to: "config.dotenv"
|
22
28
|
|
23
29
|
def initialize
|
24
30
|
super()
|
@@ -27,15 +33,20 @@ module Dotenv
|
|
27
33
|
logger: Dotenv::ReplayLogger.new,
|
28
34
|
overwrite: false,
|
29
35
|
files: [
|
30
|
-
|
31
|
-
(
|
32
|
-
|
33
|
-
|
36
|
+
".env.#{env}.local",
|
37
|
+
(".env.local" unless env.test?),
|
38
|
+
".env.#{env}",
|
39
|
+
".env"
|
34
40
|
].compact,
|
35
|
-
autorestore: env.test?
|
41
|
+
autorestore: env.test? && !defined?(ClimateControl) && !defined?(IceAge)
|
36
42
|
)
|
37
43
|
end
|
38
44
|
|
45
|
+
# The list of files to load, joined with Rails.root
|
46
|
+
def files
|
47
|
+
config.dotenv.files.map { |file| root.join(file) }
|
48
|
+
end
|
49
|
+
|
39
50
|
# Public: Load dotenv
|
40
51
|
#
|
41
52
|
# This will get called during the `before_configuration` callback, but you
|
data/lib/dotenv/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Keepers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|