dotenv 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 747efaacc729db2f028d90a94d8752f955c469cf
4
- data.tar.gz: d61101393e7343ebbb02ed446737ff5ee21bb748
3
+ metadata.gz: 709d168c1067da71893c77f0095e2926234c1563
4
+ data.tar.gz: f5dfdff21d1c187969960c117f4e4c34b50c586b
5
5
  SHA512:
6
- metadata.gz: 4fbbb669ca8e6db0e9b0214af93ada154503829efb43c71ada203a752e3ccfda446a848e9520947b6912dd186572fd795a711910e9769fa3a311ecc3e354b177
7
- data.tar.gz: 02d85f84448a99277554a0bffaa07cc273956443c8f6f154f38e04e78a848ad1be3fdd16a72159f6560e5de392633ea4407140759093a3213ce274fd34b9e75d
6
+ metadata.gz: 171cc72b428e5c94ce1d212799374473892c17c18f2ec71ffac6a52561fc0cd1b35919e2fd4450efec15b454bca794b26c427ef7ccecea56cb3544171db1bd45
7
+ data.tar.gz: 7e09916cd51b2f1e42f8fee2814c2a11c9fc72d4abb30b4e4dcfb311776ca9180fbd68cb731696ceb48802adb1c24ce3d9af0a100c3ab2cf9ba05e5596b8f7d5
data/README.md CHANGED
@@ -15,7 +15,7 @@ But it is not always practical to set environment variables on development machi
15
15
  Add this line to the top of your application's Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'dotenv-rails', :groups => [:development, :test]
18
+ gem 'dotenv-rails', groups: [:development, :test]
19
19
  ```
20
20
 
21
21
  And then execute:
@@ -40,7 +40,7 @@ HOSTNAME = ENV['HOSTNAME']
40
40
  If you use gems that require environment variables to be set before they are loaded, then list `dotenv-rails` in the `Gemfile` before those other gems and require `dotenv/rails-now`.
41
41
 
42
42
  ```ruby
43
- gem 'dotenv-rails', :require => 'dotenv/rails-now'
43
+ gem 'dotenv-rails', require: 'dotenv/rails-now'
44
44
  gem 'gem-that-requires-env-variables'
45
45
  ```
46
46
 
@@ -80,7 +80,7 @@ To ensure `.env` is loaded in rake, load the tasks:
80
80
  ```ruby
81
81
  require 'dotenv/tasks'
82
82
 
83
- task :mytask => :dotenv do
83
+ task mytask: :dotenv do
84
84
  # things that require .env
85
85
  end
86
86
  ```
@@ -147,22 +147,35 @@ SECRET_KEY=YOURSECRETKEYGOESHERE # comment
147
147
  SECRET_HASH="something-with-a-#-hash"
148
148
  ```
149
149
 
150
- ## Multiple Rails Environments
150
+ ## Frequently Answered Questions
151
+
152
+ ### Can I use dotenv in production?
151
153
 
152
154
  dotenv was originally created to load configuration variables into `ENV` in *development*. There are typically better ways to manage configuration in production environments - such as `/etc/environment` managed by [Puppet](https://github.com/puppetlabs/puppet) or [Chef](https://github.com/chef/chef), `heroku config`, etc.
153
155
 
154
156
  However, some find dotenv to be a convenient way to configure Rails applications in staging and production environments, and you can do that by defining environment-specific files like `.env.production` or `.env.test`.
155
157
 
156
- You can also use `.env.local` for local overrides.
158
+ If you use this gem to handle env vars for multiple Rails environments (development, test, production, etc.), please note that env vars that are general to all environments should be stored in `.env`. Then, environment specific env vars should be stored in `.env.<that environment's name>`.
159
+
160
+ ### What other .env* files can I use?
161
+
162
+ `dotenv-rails` will load the following files, starting from the bottom. The first value set (or those already defined in the environment) take precedence:
157
163
 
158
- If you use this gem to handle env vars for multiple Rails environments (development, test, production, etc.), please note that env vars that are general to all environments should be stored in `.env`. Then, environment specific env vars should be stored in `.env.<that environment's name>`. When you load a certain environment, dotenv will first load general env vars from `.env`, then load environment specific env vars from `.env.<current environment>`. Variables defined in `.env.<current environment>` will override any values set in `.env` or already defined in the environment.
164
+ - `.env` - The Original®
165
+ - `.env.development`, `.env.test`, `.env.production` - Environment-specific settings.
166
+ - `.env.local` - Local overrides. This file is loaded for all environments _except_ `test`.
167
+ - `.env.development.local`, `.env.test.local`, `.env.production.local` - Local overrides of environment-specific settings.
159
168
 
160
- ## Should I commit my .env file?
169
+ ### Should I commit my .env file?
161
170
 
162
171
  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.
163
172
 
164
173
  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.
165
174
 
175
+ ### Why is it not overriding existing `ENV` variables?
176
+
177
+ 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`.
178
+
166
179
  ## Contributing
167
180
 
168
181
  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).
@@ -13,7 +13,7 @@ module Dotenv
13
13
  with(*filenames) do |f|
14
14
  ignoring_nonexistent_files do
15
15
  env = Environment.new(f)
16
- instrument("dotenv.load", :env => env) { env.apply }
16
+ instrument("dotenv.load", env: env) { env.apply }
17
17
  end
18
18
  end
19
19
  end
@@ -22,7 +22,7 @@ module Dotenv
22
22
  def load!(*filenames)
23
23
  with(*filenames) do |f|
24
24
  env = Environment.new(f)
25
- instrument("dotenv.load", :env => env) { env.apply }
25
+ instrument("dotenv.load", env: env) { env.apply }
26
26
  end
27
27
  end
28
28
 
@@ -31,7 +31,7 @@ module Dotenv
31
31
  with(*filenames) do |f|
32
32
  ignoring_nonexistent_files do
33
33
  env = Environment.new(f)
34
- instrument("dotenv.overload", :env => env) { env.apply! }
34
+ instrument("dotenv.overload", env: env) { env.apply! }
35
35
  end
36
36
  end
37
37
  end
@@ -24,7 +24,8 @@ module Dotenv
24
24
  | # or
25
25
  [^#\n]+ # unquoted value
26
26
  )? # value end
27
- (?:\s*\#.*)? # optional comment
27
+ \s*
28
+ (?:\#.*)? # optional comment
28
29
  \z
29
30
  /x
30
31
 
@@ -4,4 +4,4 @@ task :dotenv do
4
4
  Dotenv.load
5
5
  end
6
6
 
7
- task :environment => :dotenv
7
+ task environment: :dotenv
@@ -1,3 +1,3 @@
1
1
  module Dotenv
2
- VERSION = "2.1.2".freeze
2
+ VERSION = "2.2.0".freeze
3
3
  end
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.1.2
4
+ version: 2.2.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: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake