scash 0.0.1 → 0.0.2

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: 5d5852ea574973ae0911cf7b51d436df065a2207
4
- data.tar.gz: 7bc8af7f2db1631e4707f6cc26d04a0d1a327962
3
+ metadata.gz: 4368b14aef03b028fd85e147f0669ed52a194294
4
+ data.tar.gz: 50b880cc63ade47c109d15b6f105867706cab9f9
5
5
  SHA512:
6
- metadata.gz: 600ea20af229037c5ae282ba6ef85142958af0252455312123cdbc5fcb6bb53c93174ea8bbf78d3d60a177d533bc0f2ce509569ef1b091cc09b2334737204981
7
- data.tar.gz: ae8ee2e7d3513b0898ba9046dcca3a3bdc2695282bb0f26bbaf7cf3f4a8f4a795e2c6060b074f7b572bc92f900be7cc033d840f9aa90c406f41d3e609a5a110e
6
+ metadata.gz: 0899546f2f5a9ba2dab051271fe5ca3b0cf8972c9e33593cb77e56f39fc8d95b75255e6abec973781ae584a96c8fe0a26a2bc182983001fa60a91129f8e00c29
7
+ data.tar.gz: 70635b989e42c2dd3e27159e180a3bc1416fc0515929ee2b32b8bca1ab7f3d5621d64d9fe91b4684a2335f7474ef6d254c001581c9d51143fc4add81d77b71b2
@@ -48,6 +48,16 @@ class Scash
48
48
  end
49
49
 
50
50
  def define_global_variables(variables)
51
+ variables.each do |key, value|
52
+ delete_key(key)
53
+ end
54
+
51
55
  @stack.push variables.with_indifferent_access
52
56
  end
57
+
58
+ private
59
+
60
+ def delete_key(key)
61
+ @stack.each{|hash|hash.delete(key)}
62
+ end
53
63
  end
@@ -1,3 +1,3 @@
1
1
  class Scash
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -114,6 +114,22 @@ class TestScash < Minitest::Test
114
114
  assert_nil scash[:b]
115
115
  assert_equal 1337, scash[:result]
116
116
  end
117
+
118
+ it "should overwrite a global variable with same name" do
119
+ scash = Scash.new
120
+ scash.with({:a => 1}) do
121
+ scash.define_global_variables :result => 1337
122
+ assert_equal 1337, scash[:result]
123
+
124
+ scash.with({:b => 2}) do
125
+ assert_equal 1337, scash[:result]
126
+ scash.define_global_variables :result => "foo"
127
+ assert_equal "foo", scash[:result]
128
+ end
129
+
130
+ assert_equal "foo", scash[:result]
131
+ end
132
+ end
117
133
  end
118
134
 
119
135
  describe "behave like a hash" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephan Kaag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-31 00:00:00.000000000 Z
11
+ date: 2013-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport