dotenv-rails 2.6.0 → 2.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -2
  3. data/lib/dotenv/rails.rb +15 -5
  4. metadata +5 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e919ac045eaf29163f767080ac21c201e91fe366e77aea3eafdceb0f088d1f84
4
- data.tar.gz: 82745ab4e48e7f79d366351d8aa44b44e94a7ba859b08a4ec9093ea5eff76e96
3
+ metadata.gz: 63a5d656ee0a5beec3233432fe5132ddcaae19276ddb1bf57eeb0303e7533dd0
4
+ data.tar.gz: 42d7b7894c089250b36e14263c175c6ed0dd3952076bc2008a9b2312ba4f36c1
5
5
  SHA512:
6
- metadata.gz: 3e61d18e243b7025ac832048fa1f68cd6eef7c4cfc3949c8e24402c2b6c1d9f25e4338252ba1f5eb2e4101173cd2a8751d543dcee09c42a2dee2ae7f14d9e5e2
7
- data.tar.gz: 1146bc5f56f10d03657aa76d8cadc35f8b5a986dcf98b2e94c97b40e7d29f1d9259248757cd08a423ed34b4ad22723e5d7c402af988da0d5f81fa16b14243cd9
6
+ metadata.gz: a469e40e9eb8a977108a5c00ab6b6d3178892a4b06eb2c9e5157a04bb5219d05df934d51d6b09ffaeedacacbfe9e05441a890311895b24d6bf687c671e55bac9
7
+ data.tar.gz: 01fdb41bcd5eeaaa41fdfe14df7fec1e1632aaac050e00f46089635d28aad1598b28b44fa30b737bc09821d6fcacceef913e3298f5f4ba238a19445c9a0a9c27
data/README.md CHANGED
@@ -62,7 +62,7 @@ Dotenv.load
62
62
 
63
63
  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
64
 
65
- ```
65
+ ```ruby
66
66
  require 'dotenv'
67
67
  Dotenv.load('file1.env', 'file2.env')
68
68
  ```
@@ -177,6 +177,16 @@ Dotenv.require_keys("SERVICE_APP_ID", "SERVICE_KEY", "SERVICE_SECRET")
177
177
 
178
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
179
 
180
+ ### Parsing
181
+
182
+ To parse a list of env files for programmatic inspection without modifying the ENV:
183
+
184
+ ```ruby
185
+ Dotenv.parse(".env.local", ".env")
186
+ # => {'S3_BUCKET' => 'YOURS3BUCKET', 'SECRET_KEY' => 'YOURSECRETKEYGOESHERE', ...}
187
+ ```
188
+
189
+ This method returns a hash of the ENV var name/value pairs.
180
190
 
181
191
  ## Frequently Answered Questions
182
192
 
@@ -190,7 +200,7 @@ If you use this gem to handle env vars for multiple Rails environments (developm
190
200
 
191
201
  ### What other .env* files can I use?
192
202
 
193
- `dotenv-rails` will override in the following order (highest defined varible overrides lower):
203
+ `dotenv-rails` will override in the following order (highest defined variable overrides lower):
194
204
 
195
205
  | Hierarchy Priority | Filename | Environment | Should I `.gitignore`it? | Notes |
196
206
  | ------------------ | ------------------------ | -------------------- | --------------------------------------------------- | ------------------------------------------------------------ |
@@ -208,6 +218,29 @@ If you use this gem to handle env vars for multiple Rails environments (developm
208
218
 
209
219
  Credentials should only be accessible on the machines that need access to them. Never commit sensitive information to a repository that is not needed by every development machine and server.
210
220
 
221
+
222
+ You can use the `-t` or `--template` flag on the dotenv cli to create a template of your `.env` file.
223
+ ```shell
224
+ $ dotenv -t .env
225
+ ```
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.
227
+
228
+ The template will contain all the environment variables in your `.env` file but with their values set to the variable names.
229
+
230
+ ```shell
231
+ # .env
232
+ S3_BUCKET=YOURS3BUCKET
233
+ SECRET_KEY=YOURSECRETKEYGOESHERE
234
+ ```
235
+
236
+ Would become
237
+
238
+ ```shell
239
+ # .env.template
240
+ S3_BUCKET=S3_BUCKET
241
+ SECRET_KEY=SECRET_KEY
242
+ ```
243
+
211
244
  Personally, I prefer to commit the `.env` file with development-only settings. This makes it easy for other developers to get started on the project without compromising credentials for other environments. If you follow this advice, make sure that all the credentials for your development environment are different from your other deployments and that the development credentials do not have access to any confidential data.
212
245
 
213
246
  ### Why is it not overriding existing `ENV` variables?
data/lib/dotenv/rails.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "dotenv"
2
2
 
3
- # Fix for rspec rake tasks loading in development
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,11 @@ require "dotenv"
9
9
  #
10
10
  # See https://github.com/bkeepers/dotenv/issues/219
11
11
  if defined?(Rake.application)
12
- is_running_specs = Rake.application.top_level_tasks.grep(/^spec(:|$)/).any?
13
- Rails.env = ENV["RAILS_ENV"] ||= "test" if is_running_specs
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
16
+ end
14
17
  end
15
18
 
16
19
  Dotenv.instrumenter = ActiveSupport::Notifications
@@ -38,6 +41,13 @@ module Dotenv
38
41
  Dotenv.load(*dotenv_files)
39
42
  end
40
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
+
41
51
  # Internal: `Rails.root` is nil in Rails 4.1 before the application is
42
52
  # initialized, so this falls back to the `RAILS_ROOT` environment variable,
43
53
  # or the current working directory.
@@ -51,8 +61,6 @@ module Dotenv
51
61
  instance.load
52
62
  end
53
63
 
54
- config.before_configuration { load }
55
-
56
64
  private
57
65
 
58
66
  def dotenv_files
@@ -63,5 +71,7 @@ module Dotenv
63
71
  root.join(".env")
64
72
  ].compact
65
73
  end
74
+
75
+ config.before_configuration { load }
66
76
  end
67
77
  end
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.6.0
4
+ version: 2.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Keepers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-10 00:00:00.000000000 Z
11
+ date: 2020-07-11 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.6.0
19
+ version: 2.7.6
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.6.0
26
+ version: 2.7.6
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.0'
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.0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: spring
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -89,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
83
  - !ruby/object:Gem::Version
90
84
  version: '0'
91
85
  requirements: []
92
- rubyforge_project:
93
- rubygems_version: 2.7.6
86
+ rubygems_version: 3.0.3
94
87
  signing_key:
95
88
  specification_version: 4
96
89
  summary: Autoload dotenv in Rails.