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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 325e086a529a793fd0ea5c35847862fd6b636e73ac769a598a938f8ea2acbf41
4
- data.tar.gz: 980081b20061f2fa099901253e530f49d98e2afa4ee6cf98de85894c8cbe34ee
3
+ metadata.gz: 28a747df13cf5c6c99fa96a201cb5f300b707a4642a63e5a65a943582a1fdde5
4
+ data.tar.gz: c917be14d97451e7615943952729ce00cc03b322c62536249a9a5859c88c63d0
5
5
  SHA512:
6
- metadata.gz: fa2134a5165c1a1d9cba3644eb6302d917e899b0c9043954dc830d9f69ef2f1d039f8949db5f661aecba96b867951049054054d58fdc237b791fe268698a5b0d
7
- data.tar.gz: b3d9cb5f625734681ae24f48eafbe12460f57cd2b4977081899a37ef82cc2f45ce33059de2b8f8b80d1b840b292197c72448cec118df4dad1b10f133b980ac2d
6
+ metadata.gz: 4cf03ffeb05d41a42ef388d42013000cc62402befb390b1c188ac8a0acdda9c3e04fea5c63d47dd103258cedc5d36c9ce0d31ef14c079abbbd4842f4d5520589
7
+ data.tar.gz: 006e3e970b3aec9905abaa038bfca1f470f8b80ce6f8f2c743a729ebbf956d3a08425708d9aa0b486da58b6ea44178c69219c860edf40226bd999606d771aa1d
@@ -1,5 +1,6 @@
1
1
  require 'active_support/core_ext/array/extract_options'
2
2
  require 'active_support/core_ext/hash/keys'
3
+ require 'active_support/inflector'
3
4
  require 'canfig/version'
4
5
  require 'canfig/yaml'
5
6
  require 'canfig/config'
@@ -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 @state[meth] if allowed?(meth)
113
+ return get(meth, *args, &block) if allowed?(meth)
103
114
  end
104
115
 
105
116
  super
@@ -1,3 +1,3 @@
1
1
  module Canfig
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
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.7
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: 2019-03-02 00:00:00.000000000 Z
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
- rubyforge_project:
95
- rubygems_version: 2.7.7
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: