dotenv 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -13
- data/lib/dotenv/parser.rb +13 -13
- data/lib/dotenv/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e18e29270d6ef436918824cab86453fba5143c8
|
4
|
+
data.tar.gz: 2303f9975ba1738ebafc3d0baea4f4abd785e558
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec8c2d505f5e77a9d9f638b3f4287c3fcf8de7e6d572d3d70102dea2638219f3184ab631f6c7ce0b1925633b239ddf91a9d788eff39bc90e62e546fcb894210a
|
7
|
+
data.tar.gz: ebeaa07575e7a0026bd17edbea7cf2b83773548cdff59c3b603eda1538b52e9228720ee2d94619d193c0a08b9cb7128bb81b46bda9bede7f30c857b47eef95f5
|
data/README.md
CHANGED
@@ -116,21 +116,9 @@ export SECRET_KEY=YOURSECRETKEYGOESHERE
|
|
116
116
|
If you need multiline variables, for example private keys, you can double quote strings and use the `\n` character for newlines:
|
117
117
|
|
118
118
|
```shell
|
119
|
-
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nHkVN9
|
119
|
+
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nHkVN9…\n-----END DSA PRIVATE KEY-----\n"
|
120
120
|
```
|
121
121
|
|
122
|
-
Alternatively, multi-line values with line breaks are now supported for quoted values.
|
123
|
-
|
124
|
-
```shell
|
125
|
-
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
|
126
|
-
...
|
127
|
-
HkVN9...
|
128
|
-
...
|
129
|
-
-----END DSA PRIVATE KEY-----"
|
130
|
-
```
|
131
|
-
|
132
|
-
This is particularly helpful when using the Heroku command line plugin [`heroku-config`](https://github.com/xavdid/heroku-config) to pull configuration variables down that may have line breaks.
|
133
|
-
|
134
122
|
### Command Substitution
|
135
123
|
|
136
124
|
You need to add the output of a command in one of your variables? Simply add it with `$(your_command)`:
|
data/lib/dotenv/parser.rb
CHANGED
@@ -12,42 +12,39 @@ module Dotenv
|
|
12
12
|
[Dotenv::Substitutions::Variable, Dotenv::Substitutions::Command]
|
13
13
|
|
14
14
|
LINE = /
|
15
|
+
\A
|
15
16
|
\s*
|
16
17
|
(?:export\s+)? # optional export
|
17
18
|
([\w\.]+) # key
|
18
19
|
(?:\s*=\s*|:\s+?) # separator
|
19
20
|
( # optional value begin
|
20
|
-
'(
|
21
|
+
'(?:\'|[^'])*' # single quoted value
|
21
22
|
| # or
|
22
|
-
"(
|
23
|
+
"(?:\"|[^"])*" # double quoted value
|
23
24
|
| # or
|
24
|
-
[^#\
|
25
|
+
[^#\n]+ # unquoted value
|
25
26
|
)? # value end
|
26
27
|
\s*
|
27
28
|
(?:\#.*)? # optional comment
|
29
|
+
\z
|
28
30
|
/x
|
29
31
|
|
30
32
|
class << self
|
31
33
|
attr_reader :substitutions
|
32
34
|
|
33
|
-
def call(string, is_load)
|
35
|
+
def call(string, is_load = false)
|
34
36
|
new(string, is_load).call
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
def initialize(string, is_load)
|
40
|
+
def initialize(string, is_load = false)
|
39
41
|
@string = string
|
40
42
|
@hash = {}
|
41
43
|
@is_load = is_load
|
42
44
|
end
|
43
45
|
|
44
46
|
def call
|
45
|
-
|
46
|
-
@string.scan(LINE).each do |key, value|
|
47
|
-
@hash[key] = parse_value(value || "")
|
48
|
-
end
|
49
|
-
# Process non-matches
|
50
|
-
@string.gsub(LINE, "").split(/[\n\r]+/).each do |line|
|
47
|
+
@string.split(/[\n\r]+/).each do |line|
|
51
48
|
parse_line(line)
|
52
49
|
end
|
53
50
|
@hash
|
@@ -56,7 +53,10 @@ module Dotenv
|
|
56
53
|
private
|
57
54
|
|
58
55
|
def parse_line(line)
|
59
|
-
if line.
|
56
|
+
if (match = line.match(LINE))
|
57
|
+
key, value = match.captures
|
58
|
+
@hash[key] = parse_value(value || "")
|
59
|
+
elsif line.split.first == "export"
|
60
60
|
if variable_not_set?(line)
|
61
61
|
raise FormatError, "Line #{line.inspect} has an unset variable"
|
62
62
|
end
|
@@ -65,7 +65,7 @@ module Dotenv
|
|
65
65
|
|
66
66
|
def parse_value(value)
|
67
67
|
# Remove surrounding quotes
|
68
|
-
value = value.strip.sub(/\A(['"])(.*)\1\z
|
68
|
+
value = value.strip.sub(/\A(['"])(.*)\1\z/, '\2')
|
69
69
|
|
70
70
|
if Regexp.last_match(1) == '"'
|
71
71
|
value = unescape_characters(expand_newlines(value))
|
data/lib/dotenv/version.rb
CHANGED
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.
|
4
|
+
version: 2.4.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: 2018-04-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|