dynamic_vars 1.0.0 → 1.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.
data/README.rdoc CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Dynamic variable gem inspired by (http://chneukirchen.org/blog/archive/2005/04/dynamic-variables-in-ruby.html)
4
4
 
5
+ TODO:
6
+
7
+ Examples....
8
+
5
9
  == Contributing to dynamic_vars
6
10
 
7
11
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -0,0 +1,60 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dynamic_vars}
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Rob Di Marco"]
12
+ s.date = %q{2011-02-25}
13
+ s.description = %q{Dynamic Variables library to allow for conditional setting of variables in a scope}
14
+ s.email = %q{rob@innovationontherun.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "dynamic_vars.gemspec",
28
+ "lib/dynamic_vars.rb",
29
+ "test/helper.rb",
30
+ "test/test_dynamic_vars.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/robdimarco/dynamic_vars}
33
+ s.licenses = ["MIT"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.5.2}
36
+ s.summary = %q{Dynamic Variables library to allow for conditional setting of variables in a scope}
37
+ s.test_files = [
38
+ "test/helper.rb",
39
+ "test/test_dynamic_vars.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
48
+ s.add_development_dependency(%q<rcov>, [">= 0"])
49
+ else
50
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
52
+ s.add_dependency(%q<rcov>, [">= 0"])
53
+ end
54
+ else
55
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
57
+ s.add_dependency(%q<rcov>, [">= 0"])
58
+ end
59
+ end
60
+
data/lib/dynamic_vars.rb CHANGED
@@ -55,8 +55,11 @@ module DynamicVars
55
55
  save[key] = self[key]
56
56
  self[key] = value
57
57
  }
58
- block.call
59
- variables.update save
58
+ begin
59
+ block.call
60
+ ensure
61
+ variables.update save
62
+ end
60
63
  end
61
64
 
62
65
  def method_missing(name, *args)
@@ -1,6 +1,7 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestDynamicVars < Test::Unit::TestCase
4
+
4
5
  def test_01_variable
5
6
  DynamicVars.variable :foo
6
7
  assert_nil DynamicVars[:foo]
@@ -93,4 +94,21 @@ class TestDynamicVars < Test::Unit::TestCase
93
94
  assert_equal :a, DynamicVars.threaded_a
94
95
  assert_equal :b, DynamicVars.threaded_b
95
96
  end
97
+
98
+ def test_07_handle_raised_exception_in_scope
99
+ DynamicVars.variable :seven=> :seven
100
+ assert_equal :seven, DynamicVars.seven
101
+
102
+ begin
103
+ DynamicVars.let(:seven => 7) do
104
+ assert_equal 7, DynamicVars.seven
105
+ raise "Testing"
106
+ end
107
+ fail "Should have a raising"
108
+ rescue
109
+ # Should be here
110
+ end
111
+
112
+ assert_equal :seven, DynamicVars.seven
113
+ end
96
114
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_vars
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rob Di Marco
@@ -81,6 +81,7 @@ files:
81
81
  - README.rdoc
82
82
  - Rakefile
83
83
  - VERSION
84
+ - dynamic_vars.gemspec
84
85
  - lib/dynamic_vars.rb
85
86
  - test/helper.rb
86
87
  - test/test_dynamic_vars.rb