canfig 0.0.7 → 0.0.8
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 +14 -3
- data/lib/canfig/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28a747df13cf5c6c99fa96a201cb5f300b707a4642a63e5a65a943582a1fdde5
|
4
|
+
data.tar.gz: c917be14d97451e7615943952729ce00cc03b322c62536249a9a5859c88c63d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cf03ffeb05d41a42ef388d42013000cc62402befb390b1c188ac8a0acdda9c3e04fea5c63d47dd103258cedc5d36c9ce0d31ef14c079abbbd4842f4d5520589
|
7
|
+
data.tar.gz: 006e3e970b3aec9905abaa038bfca1f470f8b80ce6f8f2c743a729ebbf956d3a08425708d9aa0b486da58b6ea44178c69219c860edf40226bd999606d771aa1d
|
data/lib/canfig.rb
CHANGED
data/lib/canfig/config.rb
CHANGED
@@ -36,13 +36,24 @@ module Canfig
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
def env(key, default=nil, &block)
|
40
|
+
val = ENV.fetch(key.to_s.underscore.upcase, default, &block)
|
41
|
+
val && ENV.key?(val) ? env(val, default, &block) : val
|
42
|
+
end
|
43
|
+
|
44
|
+
def clear(key)
|
45
|
+
save_state! do
|
46
|
+
@state[key] = nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
39
50
|
def []=(key, val)
|
40
51
|
set key, val
|
41
52
|
end
|
42
53
|
|
43
|
-
def get(key)
|
54
|
+
def get(key, default=nil, &block)
|
44
55
|
raise NoMethodError, "undefined method `#{key.to_s}' for #{self.to_s}" unless allowed?(key)
|
45
|
-
@state[key]
|
56
|
+
@state[key] ||= env(key, default, &block)
|
46
57
|
end
|
47
58
|
|
48
59
|
def [](key)
|
@@ -99,7 +110,7 @@ module Canfig
|
|
99
110
|
opt = meth.to_s.gsub(/=/,'').to_sym
|
100
111
|
return set(opt, args.first) if allowed?(opt)
|
101
112
|
else
|
102
|
-
return
|
113
|
+
return get(meth, *args, &block) if allowed?(meth)
|
103
114
|
end
|
104
115
|
|
105
116
|
super
|
data/lib/canfig/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rebec
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -76,7 +76,7 @@ files:
|
|
76
76
|
homepage: http://github.com/markrebec/canfig
|
77
77
|
licenses: []
|
78
78
|
metadata: {}
|
79
|
-
post_install_message:
|
79
|
+
post_install_message:
|
80
80
|
rdoc_options: []
|
81
81
|
require_paths:
|
82
82
|
- lib
|
@@ -91,9 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
|
-
|
95
|
-
|
96
|
-
signing_key:
|
94
|
+
rubygems_version: 3.1.2
|
95
|
+
signing_key:
|
97
96
|
specification_version: 4
|
98
97
|
summary: Dead simple canned configuration for gems or whatever
|
99
98
|
test_files:
|