configatron 4.4.0 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ === 4.4.1
2
+
3
+ * Make lock!/unlock! support blocks
4
+
1
5
  === 4.4.0
2
6
 
3
7
  * [backwards-incompatible] Make temp preserve locking state across invocations
data/README.md CHANGED
@@ -191,6 +191,14 @@ configatron.current.time = Configatron::Dynamic.new {Time.now}
191
191
 
192
192
  Each time you call `configatron.current.time` it will return a new value to you. While this seems a bit useless, it is pretty useful if you have ever changing configurations.
193
193
 
194
+ ### Reseting Configurations
195
+
196
+ In some testing scenarios, it can be helpful to restore Configatron to its default state. This can be done with:
197
+
198
+ ```ruby
199
+ configatron.reset!
200
+ ```
201
+
194
202
  ### Checking keys
195
203
 
196
204
  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.
@@ -52,12 +52,32 @@ class Configatron::RootStore < BasicObject
52
52
  @locked
53
53
  end
54
54
 
55
- def lock!
56
- @locked = true
55
+ def lock!(&blk)
56
+ if blk
57
+ orig = @locked
58
+ begin
59
+ @locked = true
60
+ blk.call
61
+ ensure
62
+ @locked = orig
63
+ end
64
+ else
65
+ @locked = true
66
+ end
57
67
  end
58
68
 
59
- def unlock!
60
- @locked = false
69
+ def unlock!(&blk)
70
+ if blk
71
+ orig = @locked
72
+ begin
73
+ @locked = false
74
+ blk.call
75
+ ensure
76
+ @locked = orig
77
+ end
78
+ else
79
+ @locked = false
80
+ end
61
81
  end
62
82
 
63
83
  def_delegator :@store, :to_s
@@ -1,3 +1,3 @@
1
1
  class Configatron
2
- VERSION = "4.4.0"
2
+ VERSION = "4.4.1"
3
3
  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.4.0
4
+ version: 4.4.1
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-11-24 00:00:00.000000000 Z
12
+ date: 2014-12-04 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: 3757414852321725562
141
+ hash: 630343520399706403
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: 3757414852321725562
150
+ hash: 630343520399706403
151
151
  requirements: []
152
152
  rubyforge_project:
153
153
  rubygems_version: 1.8.25