dotenv 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dotenv/substitutions/variable.rb +13 -18
- 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: e9e86533dc0be0761ac61ea33755fc7a717790e4
|
4
|
+
data.tar.gz: bb416f9f7c9bd513aeef7e7ec10c08fe3605bc0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
(\\)?
|
12
|
-
(\$)
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
value.gsub(VARIABLE) do |variable|
|
22
|
+
match = $LAST_MATCH_INFO
|
23
|
+
|
24
|
+
if match[1] == '\\'
|
25
|
+
variable[1..-1]
|
26
26
|
else
|
27
|
-
|
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
|
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.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
|
11
|
+
date: 2015-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|