modalsupport 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/modalsupport/recursive_map.rb +6 -1
- data/modalsupport.gemspec +1 -1
- data/test/test_recursive_map.rb +22 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.1
|
data/modalsupport.gemspec
CHANGED
data/test/test_recursive_map.rb
CHANGED
@@ -5,9 +5,20 @@ class TestRecursiveMap < Test::Unit::TestCase
|
|
5
5
|
context "recursive_map" do
|
6
6
|
|
7
7
|
setup do
|
8
|
+
require 'yaml'
|
8
9
|
@value_doubler = lambda{|v| v.kind_of?(Numeric) ? v*2 : v}
|
9
10
|
@hash_to_array = lambda{|v| v.kind_of?(Hash) ? v.to_a : v}
|
10
11
|
@array_to_string = lambda{|v| v.kind_of?(Array) ? v.inspect : v}
|
12
|
+
@string_to_cont_and_double = lambda{|v|
|
13
|
+
case v
|
14
|
+
when String
|
15
|
+
YAML.load(v)
|
16
|
+
when Numeric
|
17
|
+
v*2
|
18
|
+
else
|
19
|
+
v
|
20
|
+
end
|
21
|
+
}
|
11
22
|
end
|
12
23
|
|
13
24
|
should "process values in containers" do
|
@@ -68,7 +79,17 @@ class TestRecursiveMap < Test::Unit::TestCase
|
|
68
79
|
)
|
69
80
|
end
|
70
81
|
end
|
71
|
-
|
82
|
+
|
83
|
+
should "recursively process elements transformed to a container" do
|
84
|
+
assert_equal(
|
85
|
+
[222, 444],
|
86
|
+
ModalSupport.recursive_map("[111, 222]", &@string_to_cont_and_double)
|
87
|
+
)
|
88
|
+
assert_equal(
|
89
|
+
[222, 444, [2, 4, 6]],
|
90
|
+
ModalSupport.recursive_map("[111, 222, [1, 2, 3]]", &@string_to_cont_and_double)
|
91
|
+
)
|
92
|
+
end
|
72
93
|
|
73
94
|
end
|
74
95
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modalsupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 61
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 1
|
10
|
+
version: 0.8.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Javier Goizueta
|