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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac304ebb2e93011c388f160fe27b4373ea974ed0cebd69db708fae496f62fb8a
4
- data.tar.gz: e020fe5ab2d6d3eb6b68f4a1aacfc99bc6bfea56bed39ca81749b6b5114703c7
3
+ metadata.gz: b336f27996bcb36b58f5a598755be3bd844f47420149b922bf8cc8b445bbf31b
4
+ data.tar.gz: 1ae1eaf5fe6ba29b29c8410ab699969f90a9fd5d2a08a8187f5e24b274556af5
5
5
  SHA512:
6
- metadata.gz: b8a04cb55a0dedcc788683fd6d40403422e1139d4a96910a28d8e473ea4c088b9826740d59e9c9b7cf33545b0f2c5983177c60bdaf94eb5de2afb6f595ab0ae2
7
- data.tar.gz: 03825a7e60bcfd1436e960f7258c65537518a2265b7d24d2ed8943fd0e4cbbdd886571dae28c8d193dd5f3a0b11dfe317f61dd934647956d9a8769760b5b1a17
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
- if filter.arity == 1
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
- if filter.arity == 1
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
- return mapper_proc.arity == 1 ?
15
- col.map { |value| mapper_proc[value] } :
16
- col.map.with_index { |value, index| mapper_proc[value, index] }
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
- return mapper_proc.arity == 1 ?
20
- col.map { |k,v| mapper_proc[v] } :
21
- col.map { |k,v| mapper_proc[v, k] }
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
- reducer.arity == 2 ?
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
- reducer.arity == 2 ?
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudash
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Islam Attrash