rudash 2.8.1 → 2.8.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
  SHA256:
3
- metadata.gz: e987273a8b6ffa1757fdb51262efc6cbbac87163547016e584cfc59a10baffb8
4
- data.tar.gz: 436525000120d10dca368e60634d2adf942dea647ca24d1774fc7fa49568bd94
3
+ metadata.gz: c10d55f0e8a0c9fa3172f01030876b2094501ee6dec705d6b97c09de1b2870fe
4
+ data.tar.gz: 47c4324b5f508c47222dafdff4ea24dd2511d5bbce0d6d8599b4d130df621d5e
5
5
  SHA512:
6
- metadata.gz: 2681e573738db3534f6d7bc2bfeab947403bcbe5fefabd47f3af8071e8d8c135bc290c5bf81d838785ba2bdf15b5bff0e6f7ef629117088f3aac065fb95165d9
7
- data.tar.gz: e26add9c41040bfe7f51ffc21b4317d2c54065543b1d83f56e431d2f53cf6af065d64ee2004169213ecd3892936d96f40caf643918f2cd0db12f376fafa3e57b
6
+ metadata.gz: aac039a0e05f5fd2ddb67eee5a997acdac8274495cca9f1a074e9418720798d4dd48f531dbb4c00f1c6a4ea4b37e89ba76c9751fdab0ecae15359e7bcd127b59
7
+ data.tar.gz: 18f0778caae5e1fb1b3386f648061c415ceecb7d17a655e9401ce08bb5735b06cfd3622fb5f580e527318da6ab06cede06d9b875d0e7cba8ac7bf64bd3191c0b
data/lib/rudash/filter.rb CHANGED
@@ -17,15 +17,23 @@ module Rudash
17
17
 
18
18
  if collection.is_a?(Array)
19
19
  begin
20
- return collection.select.with_index { |x, idx| filter[x, idx] }
20
+ return collection.select.with_index { |x, idx| filter.(x, idx) }
21
21
  rescue ArgumentError => e
22
- return collection.select { |x| filter[x] }
22
+ begin
23
+ return collection.select { |x| filter.(x) }
24
+ rescue ArgumentError => e
25
+ return collection.select { filter.() }
26
+ end
23
27
  end
24
28
  elsif collection.is_a?(Hash)
25
29
  begin
26
- return collection.select { |k, v| filter[v, k] }
30
+ return collection.select { |k, v| filter.(v, k) }
27
31
  rescue ArgumentError => e
28
- return collection.select { |k, v| filter[v] }
32
+ begin
33
+ return collection.select { |k, v| filter.(v) }
34
+ rescue ArgumentError => e
35
+ return collection.select { filter.() }
36
+ end
29
37
  end
30
38
  else
31
39
  return []
data/lib/rudash/flip.rb CHANGED
@@ -4,7 +4,7 @@ module Rudash
4
4
  flipped_proc = -> (*args) {
5
5
  reveresed_args = args.reverse
6
6
 
7
- a_proc[*reveresed_args]
7
+ a_proc.(*reveresed_args)
8
8
  }
9
9
  end
10
10
  end
data/lib/rudash/map.rb CHANGED
@@ -12,15 +12,23 @@ module Rudash
12
12
 
13
13
  if col.is_a?(Array)
14
14
  begin
15
- return col.map.with_index { |value, index| mapper_proc[value, index] }
15
+ return col.map.with_index { |value, index| mapper_proc.(value, index) }
16
16
  rescue ArgumentError => e
17
- return col.map { |value| mapper_proc[value] }
17
+ begin
18
+ return col.map { |value| mapper_proc.(value) }
19
+ rescue ArgumentError => e
20
+ return col.map { mapper_proc.() }
21
+ end
18
22
  end
19
23
  elsif col.is_a?(Hash)
20
24
  begin
21
- return col.map { |k,v| mapper_proc[v, k] }
25
+ return col.map { |k,v| mapper_proc.(v, k) }
22
26
  rescue ArgumentError => e
23
- return col.map { |k,v| mapper_proc[v] }
27
+ begin
28
+ return col.map { |k,v| mapper_proc.(v) }
29
+ rescue ArgumentError => e
30
+ return col.map { mapper_proc.() }
31
+ end
24
32
  end
25
33
  else
26
34
  return []
data/lib/rudash/negate.rb CHANGED
@@ -4,7 +4,7 @@ module Rudash
4
4
  case a_proc
5
5
  when Proc
6
6
  negate_proc = -> (*args) {
7
- !a_proc[*args]
7
+ !a_proc.(*args)
8
8
  }
9
9
  else
10
10
  raise 'Expected a Proc'
data/lib/rudash/reduce.rb CHANGED
@@ -11,24 +11,24 @@ module Rudash
11
11
  return col.reduce { |acc, current|
12
12
  if col.is_a?(Hash)
13
13
  begin
14
- reducer[acc, current[1], current[0]]
14
+ reducer.(acc, current[1], current[0])
15
15
  rescue ArgumentError => e
16
- reducer[acc, current[1]]
16
+ reducer.(acc, current[1])
17
17
  end
18
18
  else
19
- reducer[acc, current]
19
+ reducer.(acc, current)
20
20
  end
21
21
  }
22
22
  when 2
23
23
  return col.reduce(initial_state) { |acc, current|
24
24
  if col.is_a?(Hash)
25
25
  begin
26
- reducer[acc, current[1], current[0]]
26
+ reducer.(acc, current[1], current[0])
27
27
  rescue ArgumentError => e
28
- reducer[acc, current[1]]
28
+ reducer.(acc, current[1])
29
29
  end
30
30
  else
31
- reducer[acc, current]
31
+ reducer.(acc, current)
32
32
  end
33
33
  }
34
34
  else
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.8.1
4
+ version: 2.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Islam Attrash