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 +4 -4
- data/lib/scash/version.rb +1 -1
- data/lib/scash.rb +4 -3
- data/test/test_scash.rb +3 -3
- 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: ba5430bd40c724b9b715ab5eaec27f26e13863fb
|
4
|
+
data.tar.gz: 5c37740a7bcffa842b8a4a10e03bbbe375079d27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb73697989ffd56aad60c8dbbeee2295eb494ab76fc39901f51e11f25f887e03cf953ca9b3f55976511071fd8b9898843e686d4f513741d30282328ac81f26f4
|
7
|
+
data.tar.gz: 902810c7daa58981028fe98db2d554a70d23bae3f58e392b1d221e04e55d37c5c585bd2370b7ecde8a336091de8cd508c7ec27b0e403f91d1455e09fabe1a0fe
|
data/lib/scash/version.rb
CHANGED
data/lib/scash.rb
CHANGED
@@ -62,9 +62,10 @@ class Scash
|
|
62
62
|
@stack.any?
|
63
63
|
end
|
64
64
|
|
65
|
-
def build_hash(
|
66
|
-
@stack[
|
67
|
-
|
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
|
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
|
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.
|
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-
|
11
|
+
date: 2014-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|