scash 0.2.1 → 0.2.2

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: 7d252fda83f48f053eb75f9513f7e7153eeeeb1c
4
- data.tar.gz: 66fe967c829bf8eecf540b5c002991b65ff1a1c2
3
+ metadata.gz: ba5430bd40c724b9b715ab5eaec27f26e13863fb
4
+ data.tar.gz: 5c37740a7bcffa842b8a4a10e03bbbe375079d27
5
5
  SHA512:
6
- metadata.gz: ab08cb3cd24b8add4ec104953cfc4708a1e39acc2618c6c5d77d7c17dfe91133478a536e22c491fb2e15e474e6c8ac3b2fdbbe7784bdbaaab8ac2f83098500a2
7
- data.tar.gz: 38851b5a215f84ccc3c3009099e7f379322da9132c4a5695a8375cc659077c903045bedbb9580f1504739c2576f68d77e6d3b2207933e529d5f3f6862c351b30
6
+ metadata.gz: bb73697989ffd56aad60c8dbbeee2295eb494ab76fc39901f51e11f25f887e03cf953ca9b3f55976511071fd8b9898843e686d4f513741d30282328ac81f26f4
7
+ data.tar.gz: 902810c7daa58981028fe98db2d554a70d23bae3f58e392b1d221e04e55d37c5c585bd2370b7ecde8a336091de8cd508c7ec27b0e403f91d1455e09fabe1a0fe
data/lib/scash/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Scash
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/lib/scash.rb CHANGED
@@ -62,9 +62,10 @@ class Scash
62
62
  @stack.any?
63
63
  end
64
64
 
65
- def build_hash(index = 0)
66
- @stack[index..-1].inject(@klass.new) do |hash, variables|
67
- variables = variables.reject{|key, value| value.nil? && @stack.last.key?(key) }
65
+ def build_hash(stack_index = 0)
66
+ @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| value.nil? && !last && @stack.last.key?(key) }
68
69
  variables.merge hash
69
70
  end
70
71
  end
data/test/test_scash.rb CHANGED
@@ -155,13 +155,13 @@ describe Scash do
155
155
  assert_equal 1337, scash[:initial_a]
156
156
  assert_equal nil, scash[:initial_b]
157
157
 
158
- scash.define_global_variables :a => "global a", :b => "global b"
158
+ scash.define_global_variables :a => "global a", :b => "global b", :c => nil
159
159
  scash.define_global_variables :initial_a => "new a", :initial_b => "new b"
160
160
 
161
- assert_equal [1, "global b", 1337, "new b"], scash.values
161
+ assert_equal({"a"=>1, "b"=>"global b", "c"=>nil, "initial_a"=>1337, "initial_b"=>"new b"}, scash.to_hash)
162
162
 
163
163
  scash.with(:a => "a", :b => nil, :c => nil) do
164
- assert_equal ["a", "global b", 1337, "new b", nil], scash.values # NOTE: only 1 nil value (b)
164
+ assert_equal({"a" => "a", "b" => "global b", "c" => nil, "initial_a" => 1337, "initial_b" => "new b"}, scash.to_hash)
165
165
  assert_equal "a", scash[:a]
166
166
  assert_equal "global b", scash[:b]
167
167
  assert_equal nil, scash[:c]
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.2.1
4
+ version: 0.2.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: 2014-02-12 00:00:00.000000000 Z
11
+ date: 2014-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport