dotenv 2.0.0 → 2.0.1

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: 9ccf9d3a79db7a52a63cb5aeca87cec81e21e3ec
4
- data.tar.gz: abb6bc7fad7f6b2e2c300ff6b6141f30ccb0bc37
3
+ metadata.gz: e9e86533dc0be0761ac61ea33755fc7a717790e4
4
+ data.tar.gz: bb416f9f7c9bd513aeef7e7ec10c08fe3605bc0a
5
5
  SHA512:
6
- metadata.gz: d48b1e23d0ddfac1d8342f97fe4ae862aa43316617561a0d1f702663af6d9ee21716cdef113570a263301422a2e474a572b24992b9fba2114ca3615af6768ab6
7
- data.tar.gz: b2c31269eb2977d37b0707759ad1e03ba428a7ed8a46927ec4b2fa2e23a3f8ba8302c5bc03d46a590f5489b413f24d506c2381b76e6c594364f2eb86199b27dd
6
+ metadata.gz: ad361abae6d86e24262cab7cc5a2ab7a18e3bf43dbd2a923eecf39f56a1bcd3d7292cb6e2be336486106ea7497c044d1ebed155350c0220e2a794db8e404a408
7
+ data.tar.gz: 04068ddc413f631ec3daa24b8e8185bdce861b1d1c49e7507ccb6ee598ebc04df86c59fcc400ac90141df8b60c406dfabbede72252424f8e5a33cec49463bf11
@@ -1,3 +1,5 @@
1
+ require "English"
2
+
1
3
  module Dotenv
2
4
  module Substitutions
3
5
  # Substitute variables in a value.
@@ -8,30 +10,23 @@ module Dotenv
8
10
  module Variable
9
11
  class << self
10
12
  VARIABLE = /
11
- (\\)? # is it escaped with a backslash?
12
- (\$) # literal $
13
- ( # collect braces with var for sub
14
- \{? # allow brace wrapping
15
- ([A-Z0-9_]+) # match the variable
16
- \}? # closing brace
17
- )
13
+ (\\)? # is it escaped with a backslash?
14
+ (\$) # literal $
15
+ \{? # allow brace wrapping
16
+ ([A-Z0-9_]+) # match the variable
17
+ \}? # closing brace
18
18
  /xi
19
19
 
20
20
  def call(value, env)
21
- # Process embedded variables
22
- value.scan(VARIABLE).each do |parts|
23
- if parts.first == '\\'
24
- # Variable is escaped, don't replace it.
25
- replace = parts[1...-1].join("")
21
+ value.gsub(VARIABLE) do |variable|
22
+ match = $LAST_MATCH_INFO
23
+
24
+ if match[1] == '\\'
25
+ variable[1..-1]
26
26
  else
27
- # Replace it with the value from the environment
28
- replace = env.fetch(parts.last) { ENV[parts.last] }
27
+ env.fetch(match[3]) { ENV[match[3]] }
29
28
  end
30
-
31
- value = value.sub(parts[0...-1].join(""), replace || "")
32
29
  end
33
-
34
- value
35
30
  end
36
31
  end
37
32
  end
@@ -1,3 +1,3 @@
1
1
  module Dotenv
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
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.0
4
+ version: 2.0.1
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-03-05 00:00:00.000000000 Z
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake