rudash 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rudash/filter.rb +6 -6
- data/lib/rudash/map.rb +10 -7
- data/lib/rudash/reduce.rb +8 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b336f27996bcb36b58f5a598755be3bd844f47420149b922bf8cc8b445bbf31b
|
4
|
+
data.tar.gz: 1ae1eaf5fe6ba29b29c8410ab699969f90a9fd5d2a08a8187f5e24b274556af5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1da384b4cd9739c915b66ece7e005dafd9ddd6ea78acc3e4fe27e4ef7ded7dd3b994282c09b6a68338c9e8e42da6905cf1bfe4501e5eb3088ec74c61f8b58298
|
7
|
+
data.tar.gz: fffac7f39596c84bdf4e554646d10b938af2f7a420f43f110599bb2060b3117e6a240ea64cd44b19e6b890bcfbb13aa64942560f702da84b2c4113360a110cce
|
data/lib/rudash/filter.rb
CHANGED
@@ -28,16 +28,16 @@ module Filter
|
|
28
28
|
|
29
29
|
return filtered_arr
|
30
30
|
elsif collection.is_a?(Array)
|
31
|
-
|
32
|
-
return collection.select { |x| filter[x] }
|
33
|
-
else
|
31
|
+
begin
|
34
32
|
return collection.select.with_index { |x, idx| filter[x, idx] }
|
33
|
+
rescue ArgumentError => e
|
34
|
+
return collection.select { |x| filter[x] }
|
35
35
|
end
|
36
36
|
elsif collection.is_a?(Hash)
|
37
|
-
|
38
|
-
return collection.select { |k, v| filter[v] }
|
39
|
-
else
|
37
|
+
begin
|
40
38
|
return collection.select { |k, v| filter[v, k] }
|
39
|
+
rescue ArgumentError => e
|
40
|
+
return collection.select { |k, v| filter[v] }
|
41
41
|
end
|
42
42
|
else
|
43
43
|
return []
|
data/lib/rudash/map.rb
CHANGED
@@ -11,14 +11,17 @@ module Map
|
|
11
11
|
col = collection.is_a?(String) ? collection.split('') : collection
|
12
12
|
|
13
13
|
if col.is_a?(Array)
|
14
|
-
|
15
|
-
col.map { |value| mapper_proc[value] }
|
16
|
-
|
17
|
-
|
14
|
+
begin
|
15
|
+
return col.map.with_index { |value, index| mapper_proc[value, index] }
|
16
|
+
rescue ArgumentError => e
|
17
|
+
return col.map { |value| mapper_proc[value] }
|
18
|
+
end
|
18
19
|
elsif col.is_a?(Hash)
|
19
|
-
|
20
|
-
col.map { |k,v| mapper_proc[v] }
|
21
|
-
|
20
|
+
begin
|
21
|
+
return col.map { |k,v| mapper_proc[v, k] }
|
22
|
+
rescue ArgumentError => e
|
23
|
+
return col.map { |k,v| mapper_proc[v] }
|
24
|
+
end
|
22
25
|
else
|
23
26
|
return []
|
24
27
|
end
|
data/lib/rudash/reduce.rb
CHANGED
@@ -9,9 +9,11 @@ module Reduce
|
|
9
9
|
when 1
|
10
10
|
return col.reduce { |acc, current|
|
11
11
|
if col.is_a?(Hash)
|
12
|
-
|
13
|
-
reducer[acc, current[1]] :
|
12
|
+
begin
|
14
13
|
reducer[acc, current[1], current[0]]
|
14
|
+
rescue ArgumentError => e
|
15
|
+
reducer[acc, current[1]]
|
16
|
+
end
|
15
17
|
else
|
16
18
|
reducer[acc, current]
|
17
19
|
end
|
@@ -19,9 +21,11 @@ module Reduce
|
|
19
21
|
when 2
|
20
22
|
return col.reduce(initial_state) { |acc, current|
|
21
23
|
if col.is_a?(Hash)
|
22
|
-
|
23
|
-
reducer[acc, current[1]] :
|
24
|
+
begin
|
24
25
|
reducer[acc, current[1], current[0]]
|
26
|
+
rescue ArgumentError => e
|
27
|
+
reducer[acc, current[1]]
|
28
|
+
end
|
25
29
|
else
|
26
30
|
reducer[acc, current]
|
27
31
|
end
|