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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbd76e5c6ca084e248496b42e52b9108a0107e2d
4
- data.tar.gz: d59561a4c5ece858dc36bf61194b8eda14064770
3
+ metadata.gz: 0e18e29270d6ef436918824cab86453fba5143c8
4
+ data.tar.gz: 2303f9975ba1738ebafc3d0baea4f4abd785e558
5
5
  SHA512:
6
- metadata.gz: 1c2fa80964b37fb1dfefb578945b93f0b2bac3476ddfb8429ab72835db67bec5d8c197ec27949a84769bca3895fd9c51916a1bc78eb864d76ce172634ffff7b5
7
- data.tar.gz: f8caadc5aec3fef268b085a99cc032d7e102deb2121239fe2cb5d721414a71d1b428de288d15b8cb51989559b9fac96de245489ba9f1f27c94a5534d8ecae78f
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...\n-----END DSA PRIVATE KEY-----\n"
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
- '(?:\\'|[^'])*' # single quoted value
21
+ '(?:\'|[^'])*' # single quoted value
21
22
  | # or
22
- "(?:\\"|[^"])*" # double quoted value
23
+ "(?:\"|[^"])*" # double quoted value
23
24
  | # or
24
- [^#\r\n]+ # unquoted value
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
- # Process matches
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.split.first == "export"
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/m, '\2')
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))
@@ -1,3 +1,3 @@
1
1
  module Dotenv
2
- VERSION = "2.3.0".freeze
2
+ VERSION = "2.4.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.3.0
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-19 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake