canfig 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canfig.rb +1 -0
- data/lib/canfig/config.rb +3 -4
- data/lib/canfig/env_config.rb +20 -0
- data/lib/canfig/open_config.rb +1 -1
- data/lib/canfig/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb0af652bc6aced0a5a7be703c93267bbef555c28f821c565c9c5b14f93b6d20
|
4
|
+
data.tar.gz: cb3541d3ca774f5f7a331f75238ecef6231b62be3776b50ae52cac3b12182c6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aab3a3c345efea85b20c75e8aec11ccd62baab19e8dcfa5b5870406a2731e6894311a21273b10cfea3476f037185b300e862e027a19bf8314fbb9300054d2b78
|
7
|
+
data.tar.gz: ebc54005799b649dbecc527bd30f6bbad0149ad4fc022b2998323b0fe6b7888df12ffc1050a9884caee2ee14e30093f315408ed08e657b4e3a8dc657e3449459
|
data/lib/canfig.rb
CHANGED
data/lib/canfig/config.rb
CHANGED
@@ -41,9 +41,9 @@ module Canfig
|
|
41
41
|
val && ENV.key?(val) ? env(val, default, &block) : val
|
42
42
|
end
|
43
43
|
|
44
|
-
def clear(
|
44
|
+
def clear(*keys)
|
45
45
|
save_state! do
|
46
|
-
@state[key] = nil
|
46
|
+
keys.each { |key| @state[key] = nil }
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -118,8 +118,7 @@ module Canfig
|
|
118
118
|
|
119
119
|
protected
|
120
120
|
|
121
|
-
def initialize(*args, &block)
|
122
|
-
options = args.extract_options!
|
121
|
+
def initialize(*args, **options, &block)
|
123
122
|
@allowed = (args.map(&:to_sym) + options.symbolize_keys.keys).uniq
|
124
123
|
@state = {}
|
125
124
|
enable_state_saves!
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Canfig
|
2
|
+
class EnvConfig < OpenConfig
|
3
|
+
attr_reader :namespace
|
4
|
+
|
5
|
+
def initialize(namespace=nil, **options, &block)
|
6
|
+
@namespace = namespace ? "#{namespace.to_s.underscore.upcase.gsub(/_$/, '')}_" : namespace
|
7
|
+
super(**options, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
def set(key, val)
|
11
|
+
raise NotImplementedError, "You cannot set values on a Canfig::EnvConfig"
|
12
|
+
end
|
13
|
+
|
14
|
+
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
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/canfig/open_config.rb
CHANGED
data/lib/canfig/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rebec
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/canfig.rb
|
63
63
|
- lib/canfig/class.rb
|
64
64
|
- lib/canfig/config.rb
|
65
|
+
- lib/canfig/env_config.rb
|
65
66
|
- lib/canfig/instance.rb
|
66
67
|
- lib/canfig/module.rb
|
67
68
|
- lib/canfig/open_config.rb
|