dotenv 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +28 -6
- data/lib/dotenv.rb +15 -0
- data/lib/dotenv/missing_keys.rb +10 -0
- data/lib/dotenv/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5a6cb2f17a09a77368aa3f18a06cfc18434adfef2d8dfa072fb541a7bb35100a
|
4
|
+
data.tar.gz: da472aca7324a5c382f04239c6388672279642bc94822709dc0b4b8738347e74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ec4da6c555c2b4532247ee733df7b365b7c77500723b3c45f3ae1246adf0929af729ac3c1d753da1aa04c546d32f6a7c7fdfeec8f803184154cc74de96d04f1
|
7
|
+
data.tar.gz: af06a29d17da59c84f461d16102772d2927885983160b5c6a6c91d12e6c28e6a878fc44ae3cc610bc122241fc953a0407ed85c6316b2689d32e5de4f81233034
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# dotenv [![Build Status](https://secure.travis-ci.org/bkeepers/dotenv.
|
1
|
+
# dotenv [![Build Status](https://secure.travis-ci.org/bkeepers/dotenv.svg?branch=master)](https://travis-ci.org/bkeepers/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
|
|
@@ -163,6 +163,21 @@ SECRET_KEY=YOURSECRETKEYGOESHERE # comment
|
|
163
163
|
SECRET_HASH="something-with-a-#-hash"
|
164
164
|
```
|
165
165
|
|
166
|
+
### Required Keys
|
167
|
+
|
168
|
+
If a particular configuration value is required but not set, it's appropriate to raise an error.
|
169
|
+
|
170
|
+
To require configuration keys:
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
# config/initializers/dotenv.rb
|
174
|
+
|
175
|
+
Dotenv.require_keys("SERVICE_APP_ID", "SERVICE_KEY", "SERVICE_SECRET")
|
176
|
+
```
|
177
|
+
|
178
|
+
If any of the configuration keys above are not set, your application will raise an error during initialization. This method is preferred because it prevents runtime errors in a production application due to improper configuration.
|
179
|
+
|
180
|
+
|
166
181
|
## Frequently Answered Questions
|
167
182
|
|
168
183
|
### Can I use dotenv in production?
|
@@ -175,12 +190,19 @@ If you use this gem to handle env vars for multiple Rails environments (developm
|
|
175
190
|
|
176
191
|
### What other .env* files can I use?
|
177
192
|
|
178
|
-
`dotenv-rails` will
|
193
|
+
`dotenv-rails` will override in the following order (highest defined varible overrides lower):
|
194
|
+
|
195
|
+
| Hierarchy Priority | Filename | Environment | Should I `.gitignore`it? | Notes |
|
196
|
+
| ------------------ | ------------------------ | -------------------- | --------------------------------------------------- | ------------------------------------------------------------ |
|
197
|
+
| 1st (highest) | `.env.development.local` | Development | Yes! | Local overrides of environment-specific settings. |
|
198
|
+
| 1st | `.env.test.local` | Test | Yes! | Local overrides of environment-specific settings. |
|
199
|
+
| 1st | `.env.production.local` | Production | Yes! | Local overrides of environment-specific settings. |
|
200
|
+
| 2nd | `.env.local` | Wherever the file is | Definitely. | Local overrides. This file is loaded for all environments _except_ `test`. |
|
201
|
+
| 3rd | `.env.development` | Development | No. | Shared environment-specific settings |
|
202
|
+
| 3rd | `.env.test` | Test | No. | Shared environment-specific settings |
|
203
|
+
| 3rd | `.env.production` | Production | No. | Shared environment-specific settings |
|
204
|
+
| Last | `.env` | All Environments | Depends (See [below](#should-i-commit-my-env-file)) | The Original® |
|
179
205
|
|
180
|
-
- `.env` - The Original®
|
181
|
-
- `.env.development`, `.env.test`, `.env.production` - Environment-specific settings.
|
182
|
-
- `.env.local` - Local overrides. This file is loaded for all environments _except_ `test`.
|
183
|
-
- `.env.development.local`, `.env.test.local`, `.env.production.local` - Local overrides of environment-specific settings.
|
184
206
|
|
185
207
|
### Should I commit my .env file?
|
186
208
|
|
data/lib/dotenv.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "dotenv/parser"
|
2
2
|
require "dotenv/environment"
|
3
|
+
require "dotenv/missing_keys"
|
3
4
|
|
4
5
|
# The top level Dotenv module. The entrypoint for the application logic.
|
5
6
|
module Dotenv
|
@@ -36,6 +37,14 @@ module Dotenv
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
40
|
+
# same as `overload`, but raises Errno::ENOENT if any files don't exist
|
41
|
+
def overload!(*filenames)
|
42
|
+
with(*filenames) do |f|
|
43
|
+
env = Environment.new(f, false)
|
44
|
+
instrument("dotenv.overload", env: env) { env.apply! }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
39
48
|
# Internal: Helper to expand list of filenames.
|
40
49
|
#
|
41
50
|
# Returns a hash of all the loaded environment variables.
|
@@ -55,6 +64,12 @@ module Dotenv
|
|
55
64
|
end
|
56
65
|
end
|
57
66
|
|
67
|
+
def require_keys(*keys)
|
68
|
+
missing_keys = keys.flatten - ::ENV.keys
|
69
|
+
return if missing_keys.empty?
|
70
|
+
raise MissingKeys, missing_keys
|
71
|
+
end
|
72
|
+
|
58
73
|
def ignoring_nonexistent_files
|
59
74
|
yield
|
60
75
|
rescue Errno::ENOENT
|
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: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Keepers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/dotenv/cli.rb
|
68
68
|
- lib/dotenv/environment.rb
|
69
69
|
- lib/dotenv/load.rb
|
70
|
+
- lib/dotenv/missing_keys.rb
|
70
71
|
- lib/dotenv/parser.rb
|
71
72
|
- lib/dotenv/substitutions/command.rb
|
72
73
|
- lib/dotenv/substitutions/variable.rb
|
@@ -92,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
93
|
version: '0'
|
93
94
|
requirements: []
|
94
95
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.6
|
96
|
+
rubygems_version: 2.7.6
|
96
97
|
signing_key:
|
97
98
|
specification_version: 4
|
98
99
|
summary: Loads environment variables from `.env`.
|