scash 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scash.rb +10 -0
- data/lib/scash/version.rb +1 -1
- data/test/test_scash.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4368b14aef03b028fd85e147f0669ed52a194294
|
4
|
+
data.tar.gz: 50b880cc63ade47c109d15b6f105867706cab9f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0899546f2f5a9ba2dab051271fe5ca3b0cf8972c9e33593cb77e56f39fc8d95b75255e6abec973781ae584a96c8fe0a26a2bc182983001fa60a91129f8e00c29
|
7
|
+
data.tar.gz: 70635b989e42c2dd3e27159e180a3bc1416fc0515929ee2b32b8bca1ab7f3d5621d64d9fe91b4684a2335f7474ef6d254c001581c9d51143fc4add81d77b71b2
|
data/lib/scash.rb
CHANGED
@@ -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
|
data/lib/scash/version.rb
CHANGED
data/test/test_scash.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|