dotenv 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5508950dd1e5103013a6bfe56b9397e41c40f11e
4
- data.tar.gz: ee3ccf9b9429d44b7ad9482159dc300407a52847
3
+ metadata.gz: 747efaacc729db2f028d90a94d8752f955c469cf
4
+ data.tar.gz: d61101393e7343ebbb02ed446737ff5ee21bb748
5
5
  SHA512:
6
- metadata.gz: 6550d4890592e8cb8afb5cda664cb07fb89477784ea112887716f81d8f4a5020e46e222648dbc7b4c034254eb230d4185b577a0897a34cfa5e0220bd70ce891e
7
- data.tar.gz: 083105855f61a20b42f1f2423dfa8fd8dc30efcd6760a2789d5cd0b7c0d85beb759bb574016bf2833c71055191cba6ccb70bcc55e5f525513618b6f359b612ad
6
+ metadata.gz: 4fbbb669ca8e6db0e9b0214af93ada154503829efb43c71ada203a752e3ccfda446a848e9520947b6912dd186572fd795a711910e9769fa3a311ecc3e354b177
7
+ data.tar.gz: 02d85f84448a99277554a0bffaa07cc273956443c8f6f154f38e04e78a848ad1be3fdd16a72159f6560e5de392633ea4407140759093a3213ce274fd34b9e75d
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.
@@ -0,0 +1,2 @@
1
+ require "dotenv"
2
+ Dotenv.load
@@ -9,10 +9,11 @@ module Dotenv
9
9
  # exporting of variables.
10
10
  class Parser
11
11
  @substitutions =
12
- Substitutions.constants.map { |const| Substitutions.const_get(const) }
12
+ [Dotenv::Substitutions::Variable, Dotenv::Substitutions::Command]
13
13
 
14
14
  LINE = /
15
15
  \A
16
+ \s*
16
17
  (?:export\s+)? # optional export
17
18
  ([\w\.]+) # key
18
19
  (?:\s*=\s*|:\s+?) # separator
@@ -1,3 +1,3 @@
1
1
  module Dotenv
2
- VERSION = "2.1.1".freeze
2
+ VERSION = "2.1.2".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.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: rake
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.37.2
47
+ version: 0.40.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.37.2
54
+ version: 0.40.0
55
55
  description: Loads environment variables from `.env`.
56
56
  email:
57
57
  - brandon@opensoul.org
@@ -66,6 +66,7 @@ files:
66
66
  - lib/dotenv.rb
67
67
  - lib/dotenv/cli.rb
68
68
  - lib/dotenv/environment.rb
69
+ - lib/dotenv/load.rb
69
70
  - lib/dotenv/parser.rb
70
71
  - lib/dotenv/substitutions/command.rb
71
72
  - lib/dotenv/substitutions/variable.rb
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project:
94
- rubygems_version: 2.4.5.1
95
+ rubygems_version: 2.5.2
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: Loads environment variables from `.env`.