canfig 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canfig/config.rb +5 -3
- data/lib/canfig/env_config.rb +2 -2
- data/lib/canfig/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70fda774961e755691e8a4783071ce7298b694933c4db7b2227b8563c1afeae7
|
4
|
+
data.tar.gz: 87b8c4825bf0e9b3e8d03a97c5e2f3c0643e67cca4703f48eea4e44411304959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ad137615641ae7ca8c67716720f34c3e4068e92117887eb1f9fe786aa33175da0457d128236477fef4052391106b276ce4b8e278fd8825879e2139ea3d0972f
|
7
|
+
data.tar.gz: 2811ee9abc222199f3fdba1b5398f4e938891faf756f24080c7514e6c853668ea56c47b73847b04922d72f59bac3262f5479ba69d7da040a106d674fe5f7a124
|
data/lib/canfig/config.rb
CHANGED
@@ -37,8 +37,10 @@ module Canfig
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def env(key, default=nil, &block)
|
40
|
-
|
41
|
-
|
40
|
+
@state[key] ||= begin
|
41
|
+
val = ENV.fetch(key.to_s.underscore.upcase, default, &block)
|
42
|
+
val && ENV.key?(val) ? env(val, default, &block) : val
|
43
|
+
end
|
42
44
|
end
|
43
45
|
|
44
46
|
def clear(*keys)
|
@@ -53,7 +55,7 @@ module Canfig
|
|
53
55
|
|
54
56
|
def get(key, default=nil, &block)
|
55
57
|
raise NoMethodError, "undefined method `#{key.to_s}' for #{self.to_s}" unless allowed?(key)
|
56
|
-
@state[key]
|
58
|
+
@state[key] || (block_given? ? yield : default)
|
57
59
|
end
|
58
60
|
|
59
61
|
def [](key)
|
data/lib/canfig/env_config.rb
CHANGED
@@ -7,8 +7,8 @@ module Canfig
|
|
7
7
|
super(**options, &block)
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
|
10
|
+
def get(key, default=nil, &block)
|
11
|
+
super || env(key, default, &block)
|
12
12
|
end
|
13
13
|
|
14
14
|
def env(key, default=nil, &block)
|
data/lib/canfig/version.rb
CHANGED