dotenv 2.0.2 → 2.1.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: 39a2b727e06c9a55620194609c240d04c7e94649
4
- data.tar.gz: f1e22eac1b800ed26cb8f3c02afbe3fb54c73bdc
3
+ metadata.gz: 97b35237fb293817afb2b3fb79b08b21a5425b65
4
+ data.tar.gz: f1ec39284e95bcf5a9b96e5cf3cd4aaa1e4d9e67
5
5
  SHA512:
6
- metadata.gz: eb5f26934458e39686244acc86cdc47ad3549a8c47527cb5382a4177225e9995decd0d7930c459a4cc48bc63150e3667cc069578a4205b5d8ea150739599008a
7
- data.tar.gz: 7076bf1cd763d703c291de86a01919826df5c73d5c6ddf79d248f29c392f994e25586f6276ea73fc89c52f2c4cccfd441579bd3613229fee20dc60d181711bce
6
+ metadata.gz: aab63b855e90cb05ceedcc3877f425e2af3cdb94327423f3ce8f253b5da5e392a64f5b00b9114480ed83b42ad72a3ffdc1ec2bfaa0f3d94fed1c5d0858c0d459
7
+ data.tar.gz: 4e097555c5daa7e2bcb800d771da52936298906ba5e3affa6b5835c50921690191d2610ceae5a1de329fa51ed64f494ea66ff5d80cc917fd34e5065019c73d4c
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Shim to load environment variables from `.env` into `ENV` in *development*.
6
6
 
7
- Storing [configuration in the environment](http://www.12factor.net/config) is one of the tenets of a [twelve-factor app](http://www.12factor.net/). Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables.
7
+ Storing [configuration in the environment](http://12factor.net/config) is one of the tenets of a [twelve-factor app](http://12factor.net). Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables.
8
8
 
9
9
  But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. dotenv loads variables from a `.env` file into `ENV` when the environment is bootstrapped.
10
10
 
@@ -90,6 +90,11 @@ If you need multiline variables, for example private keys, you can double quote
90
90
  PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nHkVN9…\n-----END DSA PRIVATE KEY-----\n"
91
91
  ```
92
92
 
93
+ You need to add the output of a command in one of your variables? Simply add it with `$(your_command)`:
94
+ ```shell
95
+ DATABASE_URL="postgres://$(whoami)@localhost/my_database"
96
+ ```
97
+
93
98
  You may also add `export` in front of each line so you can `source` the file in bash:
94
99
 
95
100
  ```shell
@@ -115,7 +120,7 @@ Variable names may not contain the `#` symbol. Values can use the `#` if they ar
115
120
 
116
121
  ## Multiple Rails Environments
117
122
 
118
- 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/opscode/chef), `heroku config`, etc.
123
+ 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.
119
124
 
120
125
  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`.
121
126
 
@@ -1,5 +1,5 @@
1
1
  module Dotenv
2
- # This class inherits from Hash and represents the environemnt into which
2
+ # This class inherits from Hash and represents the environment into which
3
3
  # Dotenv will load key value pairs from a file.
4
4
  class Environment < Hash
5
5
  attr_reader :filename
@@ -14,7 +14,7 @@ module Dotenv
14
14
  end
15
15
 
16
16
  def read
17
- File.read(@filename)
17
+ File.open(@filename, "rb:bom|utf-8") { |file| file.read }
18
18
  end
19
19
 
20
20
  def apply
@@ -10,11 +10,12 @@ module Dotenv
10
10
  module Variable
11
11
  class << self
12
12
  VARIABLE = /
13
- (\\)? # is it escaped with a backslash?
14
- (\$) # literal $
15
- \{? # allow brace wrapping
16
- ([A-Z0-9_]+) # match the variable
17
- \}? # closing brace
13
+ (\\)? # is it escaped with a backslash?
14
+ (\$) # literal $
15
+ (?!\() # shouldnt be followed by paranthesis
16
+ \{? # allow brace wrapping
17
+ ([A-Z0-9_]+)? # optional alpha nums
18
+ \}? # closing brace
18
19
  /xi
19
20
 
20
21
  def call(value, env)
@@ -23,8 +24,10 @@ module Dotenv
23
24
 
24
25
  if match[1] == '\\'
25
26
  variable[1..-1]
26
- else
27
+ elsif match[3]
27
28
  env.fetch(match[3]) { ENV[match[3]] }
29
+ else
30
+ variable
28
31
  end
29
32
  end
30
33
  end
@@ -1,3 +1,3 @@
1
1
  module Dotenv
2
- VERSION = "2.0.2"
2
+ VERSION = "2.1.0"
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.0.2
4
+ version: 2.1.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: 2015-06-19 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.2.3
94
+ rubygems_version: 2.4.5.1
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Loads environment variables from `.env`.