canfig 0.0.10 → 0.0.11

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
  SHA256:
3
- metadata.gz: 70fda774961e755691e8a4783071ce7298b694933c4db7b2227b8563c1afeae7
4
- data.tar.gz: 87b8c4825bf0e9b3e8d03a97c5e2f3c0643e67cca4703f48eea4e44411304959
3
+ metadata.gz: ba430bd04920933ac504636144cb797457e51446c1850c02ce8ba76a2fab1136
4
+ data.tar.gz: 9b38d00d36ab5928c606a5aa869cb26597276743d9433f558b079dd8487ce2ec
5
5
  SHA512:
6
- metadata.gz: 4ad137615641ae7ca8c67716720f34c3e4068e92117887eb1f9fe786aa33175da0457d128236477fef4052391106b276ce4b8e278fd8825879e2139ea3d0972f
7
- data.tar.gz: 2811ee9abc222199f3fdba1b5398f4e938891faf756f24080c7514e6c853668ea56c47b73847b04922d72f59bac3262f5479ba69d7da040a106d674fe5f7a124
6
+ metadata.gz: acf50db63b8d815cb835fc8ae8213e009040aecb68f17d1c09e760ef5fe10087af3eb5c9db91507385fc62617c1bc146b6bc4113addde3e803b5c5fd072c5414
7
+ data.tar.gz: d97d1a93681dfe5c13ef6ea893eb2817cf5a6484a18b77ef40b2ea2da99fd12b2f54823c441f78d2db848e017091f0600e42b61dd20fa80e701549032890edac
@@ -39,7 +39,7 @@ module Canfig
39
39
  def env(key, default=nil, &block)
40
40
  @state[key] ||= begin
41
41
  val = ENV.fetch(key.to_s.underscore.upcase, default, &block)
42
- val && ENV.key?(val) ? env(val, default, &block) : val
42
+ val && ENV.key?(val.to_s) ? env(val, default, &block) : val
43
43
  end
44
44
  end
45
45
 
@@ -2,9 +2,12 @@ module Canfig
2
2
  class EnvConfig < OpenConfig
3
3
  attr_reader :namespace
4
4
 
5
- def initialize(namespace=nil, **options, &block)
5
+ def initialize(namespace=nil, **attributes, &block)
6
6
  @namespace = namespace ? "#{namespace.to_s.underscore.upcase.gsub(/_$/, '')}_" : namespace
7
- super(**options, &block)
7
+ super(*attributes.keys, &block)
8
+ attributes.each do |key,val|
9
+ env(key, val)
10
+ end
8
11
  end
9
12
 
10
13
  def get(key, default=nil, &block)
@@ -12,9 +15,12 @@ module Canfig
12
15
  end
13
16
 
14
17
  def env(key, default=nil, &block)
15
- key = key.to_s.underscore.upcase
16
- key = key.gsub(/^#{namespace}/, '') if namespace
17
- super("#{namespace}#{key}", default, &block)
18
+ @state[key.to_sym] ||= begin
19
+ key = key.to_s.underscore.upcase
20
+ key = key.gsub(/^#{namespace}/, '') if namespace
21
+ val = ENV.fetch("#{namespace}#{key}", default, &block)
22
+ val && ENV.key?(val.to_s) ? env(val, default, &block) : val
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -1,3 +1,3 @@
1
1
  module Canfig
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.11'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec