dynamic_ruby 1.0.0 → 1.1.0

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.
data/lib/dynamic_ruby.rb CHANGED
@@ -9,12 +9,15 @@ def dynamic(bindings={}, &block)
9
9
  end
10
10
  Thread.current[name] = val
11
11
  end
12
- block.call
13
- bindings.each do |name, val|
14
- if defined[name]
15
- Thread.current[name] = defined[name]
16
- else
17
- Thread.current[name] = nil
12
+ begin
13
+ block.call
14
+ ensure
15
+ bindings.each do |name, val|
16
+ if defined[name]
17
+ Thread.current[name] = defined[name]
18
+ else
19
+ Thread.current[name] = nil
20
+ end
18
21
  end
19
22
  end
20
23
  end
@@ -42,4 +42,16 @@ describe "dynamic scope" do
42
42
  thr.join
43
43
  result.must_equal "right"
44
44
  end
45
+
46
+ it "should clear setting within an exception" do
47
+ result = nil
48
+ exfun = lambda { raise "do not set", dynamic[:name] }
49
+ proc do
50
+ dynamic name: "john" do
51
+ exfun.call
52
+ end
53
+ end.must_raise(TypeError)
54
+ result = dynamic[:name]
55
+ result.must_be_nil
56
+ end
45
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.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: 2013-05-20 00:00:00.000000000 Z
12
+ date: 2013-05-21 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A thin wrapper around ruby for easy use of dynamic scope in your rubies
15
15
  email: juergenbickert@gmail.com
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
40
  version: '0'
41
41
  requirements: []
42
42
  rubyforge_project:
43
- rubygems_version: 1.8.15
43
+ rubygems_version: 1.8.25
44
44
  signing_key:
45
45
  specification_version: 3
46
46
  summary: A library which correctly implements dynamic scope for ruby.