configatron 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ade0eaacbaca6d1751e811972975ce00ccd7336e
4
- data.tar.gz: 37087c12805c28940771cf27746b1c1858c115a0
3
+ metadata.gz: e6c93e7ecc847458d9417c053fa4a93fba83b616
4
+ data.tar.gz: f8f87d9a27a7a0e9af621dc109dbf17a1b664054
5
5
  SHA512:
6
- metadata.gz: 901770f4fa820125723c7b4631cad49b74da6e0b4c0f44ff7f1dda511f172b7da947ae6e630dca94f3c7d0fb9a4282cf688d5bc01f76a94d654ad5e0ee4c4992
7
- data.tar.gz: 9c6c28a946279c0cff614b99ce8a676f9c71039a7c9b70cbd4256b2c4d9ac8d6aeb7ab15728efd0777a94fca20bfd1312a703ab219d5638d2004f8024bc8a313
6
+ metadata.gz: 75cca363649f725091cfbe1b4e5d846d9a5a23b479a83163fd5e647be097353ae6cbbeae78a3bef5277d101cc837e9a88ab569d83f7c132f61ac1bf6b2fc20e8
7
+ data.tar.gz: 3e7f64f6a99e29280a6981b4188dd887f33998d6c785cf3e458f6ea039d3aac3fcc44cd9a2482111f1ed445e6d40c530881fe428f95ccf2b3ef06f3526f06784
data/History.txt CHANGED
@@ -1,4 +1,8 @@
1
- === 4.0.0 (WIP)
1
+ === 4.0.1
2
+
3
+ * Fix #inspect and #to_s methods on KernelStore to pass through to Store
4
+
5
+ === 4.0.0
2
6
 
3
7
  This is largely a restructuring of existing functionality, making it
4
8
  simpler and more consistent. The tests have also been fully
data/README.md CHANGED
@@ -66,7 +66,7 @@ Notice how our other configuration parameters haven't changed? Cool, eh?
66
66
 
67
67
  ### Hash/YAML
68
68
 
69
- You can configure Configatron from a hash as well (this is really only useful in testing or for data driven configuration, it's not recommended for actual configuration):
69
+ You can configure Configatron from a hash as well (this is particularly useful if you'd like to have configuration files):
70
70
 
71
71
  ```ruby
72
72
  configatron.configure_from_hash(email: {pop: {address: 'pop.example.com', port: 110}}, smtp: {address: 'smtp.example.com'})
@@ -76,10 +76,6 @@ configatron.email.pop.port # => 110
76
76
  # and so on...
77
77
  ```
78
78
 
79
- #### YAML
80
-
81
- YAML is terrible and should be driven from the face of the Earth. Because of this Configatron V3 does not support it. Sorry.
82
-
83
79
  ### Namespaces
84
80
 
85
81
  The question that should be on your lips is what I need to have namespaced configuration parameters. It's easy! Configatron allows you to create namespaces.
@@ -119,7 +115,7 @@ end
119
115
 
120
116
  ### Temp Configurations
121
117
 
122
- Sometimes in testing, or other situations, you want to temporarily change some settings. You can do this with the `temp` method:
118
+ Sometimes in testing, or other situations, you want to temporarily change some settings. You can do this with the `temp` method (only available on the top-level configatron `RootStore`):
123
119
 
124
120
  ```ruby
125
121
  configatron.one = 1
@@ -191,15 +187,7 @@ Each time you call `configatron.current.time` it will return a new value to you.
191
187
 
192
188
  ### nil
193
189
 
194
- Even if parameters haven't been set, you can still call them, but you'll get a `Configatron::Store` object back. The `Configatron::Store` class, however, will respond true to `.nil?` or `.blank?` if there are no parameters configured on it.
195
-
196
- ```ruby
197
- configatron.i.dont.exist.nil? # => true
198
- configatron.i.dont.exist.blank? # => true
199
- configatron.i.dont.exist # => Configatron::Store
200
- ```
201
-
202
- You can use `.has_key?` to determine if a key already exists.
190
+ Even if parameters haven't been set, you can still call them, but you'll get a `Configatron::Store` object back. You can use `.has_key?` to determine if a key already exists.
203
191
 
204
192
  ```ruby
205
193
  configatron.i.dont.has_key?(:exist) # => false
@@ -218,16 +206,14 @@ configatron.a.b.c! # => raise Configratron::UndefinedKeyError
218
206
 
219
207
  ### Kernel
220
208
 
221
- The `configatron` "helper" method is store in the `Kernel` module. Some people didn't like that in the V2 of Configatron, so in V3, while that hasn't changed, you don't have to use it.
222
-
223
- Instead of requiring `configatron` simply require `configatron/core`, but then you'll have to set up your own `Configatron::Store` object.
209
+ The `configatron` "helper" method is stored in the `Kernel` module. You can opt-out of this global monkey-patching by requiring `configatron/core` rather than `configatron`. You'll have to set up your own `Configatron::RootStore` object.
224
210
 
225
211
  Example:
226
212
 
227
213
  ```ruby
228
214
  require 'configatron/core'
229
215
 
230
- store = Configatron::Store.new
216
+ store = Configatron::RootStore.new
231
217
  store.foo = 'FOO'
232
218
 
233
219
  store.to_h #= {foo: 'FOO'}
@@ -2,6 +2,7 @@
2
2
  # operate on the entire configatron hierarchy.
3
3
  class Configatron::RootStore
4
4
  include Singleton
5
+ extend ::Forwardable
5
6
 
6
7
  attr_reader :store
7
8
 
@@ -49,4 +50,7 @@ class Configatron::RootStore
49
50
  def unlock!
50
51
  @locked = false
51
52
  end
53
+
54
+ def_delegator :@store, :to_s
55
+ def_delegator :@store, :inspect
52
56
  end
@@ -58,11 +58,6 @@ class Configatron
58
58
  end
59
59
  end
60
60
 
61
- # Needed to allow 'puts'ing of a configatron.
62
- def to_ary
63
- raise NoMethodError
64
- end
65
-
66
61
  def to_s
67
62
  @name
68
63
  end
@@ -90,6 +85,11 @@ class Configatron
90
85
  end
91
86
 
92
87
  def method_missing(name, *args, &block)
88
+ # Needed to allow 'puts'ing of a configatron.
89
+ if name == :to_ary
90
+ raise NoMethodError.new("Called :to_ary")
91
+ end
92
+
93
93
  # In case of Configatron bugs, prevent method_missing infinite
94
94
  # loops.
95
95
  if @method_missing
@@ -1,3 +1,3 @@
1
1
  class Configatron
2
- VERSION = "4.0.0"
2
+ VERSION = "4.0.1"
3
3
  end
@@ -73,4 +73,11 @@ class Critic::Functional::ConfigatronTest < Critic::Functional::Test
73
73
  assert_equal(name, 'configatron.foo.bar.baz')
74
74
  end
75
75
  end
76
+
77
+ describe 'puts' do
78
+ it 'does not cause an exception' do
79
+ puts @kernel
80
+ puts @kernel.hi
81
+ end
82
+ end
76
83
  end
@@ -1,14 +1,14 @@
1
1
  require_relative '../_lib'
2
2
 
3
- class Critic::Unit::KernelTest < Critic::Unit::Test
3
+ class Critic::Unit::RootTest < Critic::Unit::Test
4
4
  before do
5
- @kernel = Configatron::RootStore.new
5
+ @root = Configatron::RootStore.new
6
6
  end
7
7
 
8
8
  describe 'delegation' do
9
9
  it 'passes on to Configatron::Store' do
10
- @kernel.a.b.c.d = 'D'
11
- assert_equal('D', @kernel.a.b.c.d)
10
+ @root.a.b.c.d = 'D'
11
+ assert_equal('D', @root.a.b.c.d)
12
12
  end
13
13
  end
14
14
 
@@ -17,4 +17,21 @@ class Critic::Unit::KernelTest < Critic::Unit::Test
17
17
  assert_equal(true, configatron.kind_of?(Configatron::RootStore))
18
18
  end
19
19
  end
20
+
21
+ describe 'inspect' do
22
+ it 'delegates to store' do
23
+ @root.a.b.c.d = 'D'
24
+ @root.a.b.e = 'E'
25
+ assert_equal('configatron.a.b.c.d = "D"
26
+ configatron.a.b.e = "E"', @root.inspect)
27
+ end
28
+ end
29
+
30
+ describe 'to_s' do
31
+ it 'delegates to store' do
32
+ @root.a.b.c.d = 'D'
33
+ @root.a.b = 'D'
34
+ assert_equal('configatron', @root.to_s)
35
+ end
36
+ end
20
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configatron
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Bates