scash 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 570eef32d6464578fcb182f5b2a2cb480c9c6160
4
- data.tar.gz: 60f4308b7368944b2c123ffb0e579fdd57b9da96
3
+ metadata.gz: 0bffa41de0ca678f84bac31ff66ebb2f48530aa0
4
+ data.tar.gz: 0efbb1eb55d831f2a7c0b3cc360c4c5829b96028
5
5
  SHA512:
6
- metadata.gz: 7fbdb1a988fcd3eb8984ff8cb78f852b13f804d0b0c9d123751e468911c93f0fd500ef78438b1f97ae272f3c9b05f4e36ec2be6834a4bf6439250bb9e1482cc5
7
- data.tar.gz: a8bfcae6af2ffd8bc621c6b3b8f1d1baa0035acb92905104f28a7000472d42f493f7510fa331bd1aff3a6e76944bce4f6bca1483e7bc8e07b075a8fefeb7c763
6
+ metadata.gz: 0ad99565ef44a2dd563f5ffc913bea426d47f7e7745fe429062dbb6e7ed58c35b87936435800b1bac13ddc3a4819f52373b57d428a569860243422b846fcf771
7
+ data.tar.gz: 58df8c537d1285e48d262a99c161b8f59c94adf784a82927a732fd3a5995c8f209509dc40d0dcedda5652304f013dd734a21869203338f9c20596cadcaf4ffbc
data/lib/scash/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Scash
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/lib/scash.rb CHANGED
@@ -48,6 +48,7 @@ class Scash
48
48
  end
49
49
 
50
50
  def define_global_variables(variables)
51
+ @stack.each{|hash|variables.keys.each{|key| hash.delete(key)}}
51
52
  global_variables.merge! convert(variables)
52
53
  build!
53
54
  end
@@ -64,8 +65,6 @@ class Scash
64
65
 
65
66
  def build_hash(stack_index = 0)
66
67
  @stack[stack_index..-1].each_with_index.inject(@klass.new) do |hash, (variables, index)|
67
- last = stack_index + index == @stack.size-1
68
- variables = variables.reject{|key, value| variables[key].nil? && !last && @stack.last.key?(key) }
69
68
  variables.merge hash
70
69
  end
71
70
  end
data/test/test_scash.rb CHANGED
@@ -147,39 +147,7 @@ describe Scash do
147
147
  assert_equal 1337, scash[:result]
148
148
  end
149
149
 
150
- it "overwrite a nil value with same name" do
151
- # initial values can never be overwritten with a global-variable, except nil values
152
- scash = Scash.new(:initial_a => 1337, :initial_b => nil)
153
- scash.with({:a => 1, :b => nil}) do
154
- assert_equal [1337, nil, 1, nil], scash.values
155
- assert_equal 1337, scash[:initial_a]
156
- assert_equal nil, scash[:initial_b]
157
-
158
- scash.define_global_variables :a => "global a", :b => "global b", :c => nil
159
- scash.define_global_variables :initial_a => "new a", :initial_b => "new b"
160
-
161
- assert_equal({"a"=>1, "b"=>"global b", "c"=>nil, "initial_a"=>1337, "initial_b"=>"new b"}, scash.to_hash)
162
-
163
- scash.with(:a => "a", :b => nil, :c => nil) do
164
- assert_equal({"a" => "a", "b" => "global b", "c" => nil, "initial_a" => 1337, "initial_b" => "new b"}, scash.to_hash)
165
- assert_equal "a", scash[:a]
166
- assert_equal "global b", scash[:b]
167
- assert_equal nil, scash[:c]
168
- end
169
-
170
- assert_equal 1, scash[:a]
171
- assert_equal "global b", scash[:b]
172
- assert_equal 1337, scash[:initial_a]
173
- assert_equal "new b", scash[:initial_b]
174
- end
175
- assert_equal "global a", scash[:a]
176
- assert_equal "global b", scash[:b]
177
-
178
- assert_equal 1337, scash[:initial_a]
179
- assert_equal "new b", scash[:initial_b]
180
- end
181
-
182
- it "overwrites a global variable with same name" do
150
+ it "overwrites earlier defined variables with same name" do
183
151
  scash = Scash.new
184
152
  scash.with({:a => 1}) do
185
153
  scash.define_global_variables :result => 1337
@@ -190,7 +158,7 @@ describe Scash do
190
158
  assert_equal 2, scash[:b]
191
159
  scash.define_global_variables :result => "foo"
192
160
  scash.define_global_variables :b => "bar"
193
- assert_equal 2, scash[:b]
161
+ assert_equal "bar", scash[:b]
194
162
  assert_equal "foo", scash[:result]
195
163
  end
196
164
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephan Kaag