configatron 4.2.1 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 4.3.0
2
+
3
+ * [backwards-incompatible] Make nil into a valid config value
4
+ * [backwards-incompatible] Make temp clean up after itself when an exception is thrown
5
+
1
6
  === 4.2.1
2
7
 
3
8
  * Fix a bug with deep cloning which caused temping to break for nested settings
@@ -30,8 +30,12 @@ class Configatron::RootStore < BasicObject
30
30
 
31
31
  def temp(&block)
32
32
  temp_start
33
- yield
34
- temp_end
33
+
34
+ begin
35
+ yield
36
+ ensure
37
+ temp_end
38
+ end
35
39
  end
36
40
 
37
41
  def temp_start
@@ -28,8 +28,10 @@ class Configatron
28
28
  end
29
29
 
30
30
  def fetch(key, default_value = nil, &block)
31
- val = @attributes[key.to_sym]
32
- if val == nil
31
+ key = key.to_sym
32
+ if key?(key)
33
+ val = @attributes[key]
34
+ else
33
35
  if block
34
36
  val = block.call
35
37
  elsif default_value
@@ -1,3 +1,3 @@
1
1
  class Configatron
2
- VERSION = "4.2.1"
2
+ VERSION = "4.3.0"
3
3
  end
@@ -35,6 +35,19 @@ class Critic::Functional::ConfigatronTest < Critic::Functional::Test
35
35
  assert_equal('original', @kernel.foo.bar)
36
36
  end
37
37
 
38
+ it 'cleans up after an exception' do
39
+ @kernel.foo.bar = 'original'
40
+
41
+ assert_raises(RuntimeError) do
42
+ @kernel.temp do
43
+ @kernel.foo.bar = 'temp'
44
+ raise RuntimeError.new('error')
45
+ end
46
+ end
47
+
48
+ assert_equal('original', @kernel.foo.bar)
49
+ end
50
+
38
51
  describe 'start/end' do
39
52
  it 'allows for temporary setting of values' do
40
53
  assert_equal('A', @kernel.a)
@@ -116,4 +129,11 @@ class Critic::Functional::ConfigatronTest < Critic::Functional::Test
116
129
  assert_equal(expected_hash, @kernel.to_hash)
117
130
  end
118
131
  end
132
+
133
+ describe 'nil value' do
134
+ it 'remembers a nil value' do
135
+ @kernel.a = nil
136
+ assert_equal(nil, @kernel.a)
137
+ end
138
+ end
119
139
  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.2.1
4
+ version: 4.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-26 00:00:00.000000000 Z
12
+ date: 2014-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -138,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  segments:
140
140
  - 0
141
- hash: -3339507519042551569
141
+ hash: -4412635049792496814
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  none: false
144
144
  requirements:
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  segments:
149
149
  - 0
150
- hash: -3339507519042551569
150
+ hash: -4412635049792496814
151
151
  requirements: []
152
152
  rubyforge_project:
153
153
  rubygems_version: 1.8.25