dotenv-rails 2.1.1 → 2.1.2

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 +37 -8
  3. data/lib/dotenv/rails.rb +2 -2
  4. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30cce7ec7dfd3836028bedc646424eab5a14cc85
4
- data.tar.gz: 6a018af13b56cc242033495eb3ebe1b14c43c69b
3
+ metadata.gz: fda3b4ebc0fdf813b5f05ad06295b43d346546a9
4
+ data.tar.gz: 495019f65e82ec32fa3c7df2975b112a70dd81b8
5
5
  SHA512:
6
- metadata.gz: e30b502fa351c26da24d87500f1c05b2eb0506c50bbb3f4d4b4e45dadf645afb515cc75fc30f4078d84e51fba01864cb47385b713b9db34d7d24e43abda5d46a
7
- data.tar.gz: e795d812359bc167b896480dca63064b7be6c1664a32e6be65ab1e8858cd28a1426113e5587415918700d68acd9d0b6ba6bb0b46cca59b7160fbfd7dc9cebd61
6
+ metadata.gz: 7279f8f765b5472ce0470448781d087fc2c0360506ff8b89eef20adba5f230fd82d3fe7d56e19d91a72c39af9e08ac3dac6492d03de50225a156f7fdca8c6a86
7
+ data.tar.gz: bec6096e0651571fd99cf3c45b0d6ed47db8ef6b090aa49a4c05cb0b487e48ded7c7280ac6768e6a627c634135579a87b042c04a8189c28d543365628d4303cb
data/README.md CHANGED
@@ -55,10 +55,20 @@ $ gem install dotenv
55
55
  As early as possible in your application bootstrap process, load `.env`:
56
56
 
57
57
  ```ruby
58
+ require 'dotenv/load'
59
+
60
+ # or
58
61
  require 'dotenv'
59
62
  Dotenv.load
60
63
  ```
61
64
 
65
+ 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.
66
+
67
+ ```
68
+ require 'dotenv'
69
+ Dotenv.load('file1.env', 'file2.env')
70
+ ```
71
+
62
72
  Alternatively, you can use the `dotenv` executable to launch your application:
63
73
 
64
74
  ```shell
@@ -84,30 +94,51 @@ S3_BUCKET=YOURS3BUCKET
84
94
  SECRET_KEY=YOURSECRETKEYGOESHERE
85
95
  ```
86
96
 
97
+ Whenever your application loads, these variables will be available in `ENV`:
98
+
99
+ ```ruby
100
+ config.fog_directory = ENV['S3_BUCKET']
101
+ ```
102
+
103
+ You may also add `export` in front of each line so you can `source` the file in bash:
104
+
105
+ ```shell
106
+ export S3_BUCKET=YOURS3BUCKET
107
+ export SECRET_KEY=YOURSECRETKEYGOESHERE
108
+ ```
109
+
110
+ ### Multi-line values
111
+
87
112
  If you need multiline variables, for example private keys, you can double quote strings and use the `\n` character for newlines:
88
113
 
89
114
  ```shell
90
115
  PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nHkVN9…\n-----END DSA PRIVATE KEY-----\n"
91
116
  ```
92
117
 
118
+ ### Command Substitution
119
+
93
120
  You need to add the output of a command in one of your variables? Simply add it with `$(your_command)`:
121
+
94
122
  ```shell
95
123
  DATABASE_URL="postgres://$(whoami)@localhost/my_database"
96
124
  ```
97
125
 
98
- You may also add `export` in front of each line so you can `source` the file in bash:
126
+ ### Variable Substitution
127
+
128
+ You need to add the value of another variable in one of your variables? You can reference the variable with `${VAR}` or often just `$VAR` in unqoted or double-quoted values.
99
129
 
100
130
  ```shell
101
- export S3_BUCKET=YOURS3BUCKET
102
- export SECRET_KEY=YOURSECRETKEYGOESHERE
131
+ DATABASE_URL="postgres://${USER}@localhost/my_database"
103
132
  ```
104
133
 
105
- Whenever your application loads, these variables will be available in `ENV`:
134
+ If a value contains a `$` and it is not intended to be a variable, wrap it in single quotes.
106
135
 
107
- ```ruby
108
- config.fog_directory = ENV['S3_BUCKET']
136
+ ```shell
137
+ PASSWORD='pas$word'
109
138
  ```
110
139
 
140
+ ### Comments
141
+
111
142
  Comments may be added to your file as such:
112
143
 
113
144
  ```shell
@@ -116,8 +147,6 @@ SECRET_KEY=YOURSECRETKEYGOESHERE # comment
116
147
  SECRET_HASH="something-with-a-#-hash"
117
148
  ```
118
149
 
119
- Variable names may not contain the `#` symbol. Values can use the `#` if they are enclosed in quotes.
120
-
121
150
  ## Multiple Rails Environments
122
151
 
123
152
  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.
@@ -17,8 +17,6 @@ module Dotenv
17
17
  # Dotenv Railtie for using Dotenv to load environment from a file into
18
18
  # Rails applications
19
19
  class Railtie < Rails::Railtie
20
- config.before_configuration { load }
21
-
22
20
  # Public: Load dotenv
23
21
  #
24
22
  # This will get called during the `before_configuration` callback, but you
@@ -43,5 +41,7 @@ module Dotenv
43
41
  def self.load
44
42
  instance.load
45
43
  end
44
+
45
+ config.before_configuration { load }
46
46
  end
47
47
  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.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Keepers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-28 00:00:00.000000000 Z
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -16,21 +16,21 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.1
19
+ version: 2.1.2
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.1.1
26
+ version: 2.1.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: railties
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '3.2'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: '5.1'
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: '4.0'
43
+ version: '3.2'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '5.1'
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project:
93
- rubygems_version: 2.4.5.1
93
+ rubygems_version: 2.5.2
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Autoload dotenv in Rails.