rudash 2.9.0 → 2.9.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.rb +0 -2
- data/lib/rudash/filter.rb +3 -0
- data/lib/rudash/flip.rb +4 -0
- data/lib/rudash/map.rb +4 -1
- data/lib/rudash/negate.rb +7 -8
- data/lib/rudash/reduce.rb +4 -1
- data/lib/rudash/reject.rb +3 -2
- data/lib/rudash/update.rb +4 -0
- data/lib/utils/index.rb +4 -0
- metadata +1 -2
- data/lib/rudash/is_proc.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82271921675a8d420c4e1dd198c0e07f6438a323040ac28f6cb07042e776ad3c
|
4
|
+
data.tar.gz: 66901b07176af3319fce0a930752d03e1d761652cccc47a7f1d7be300af45676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4087dbb48f61d30663fe2f25b18866bd2b1dcd8c1878692243330fe0cdcf6708dabdddd7ab07d892f221d7084d51d78f68076a92e5450d8ba98ae7067e477050
|
7
|
+
data.tar.gz: d8c6597e919c2e3d9a5e3e148adbc5a2b1bcbef14cac0113f5a391e05a545d1dbd188f0b15176ee4ead8acd42e084ca03964bf3983b283925ec96b4601ac91ea
|
data/lib/rudash.rb
CHANGED
@@ -20,7 +20,6 @@ require_relative './rudash/is_array.rb'
|
|
20
20
|
require_relative './rudash/is_equal.rb'
|
21
21
|
require_relative './rudash/is_hash.rb'
|
22
22
|
require_relative './rudash/is_empty.rb'
|
23
|
-
require_relative './rudash/is_proc.rb'
|
24
23
|
require_relative './rudash/reverse.rb'
|
25
24
|
require_relative './rudash/curry.rb'
|
26
25
|
require_relative './rudash/is_number.rb'
|
@@ -72,7 +71,6 @@ class R_
|
|
72
71
|
extend Rudash::IsEqual
|
73
72
|
extend Rudash::IsHash
|
74
73
|
extend Rudash::IsEmpty
|
75
|
-
extend Rudash::IsProc
|
76
74
|
extend Rudash::Reverse
|
77
75
|
extend Rudash::Curry
|
78
76
|
extend Rudash::IsNumber
|
data/lib/rudash/filter.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative '../utils/index.rb'
|
1
2
|
require_relative '../utils/subset_deep_match.rb'
|
2
3
|
|
3
4
|
module Rudash
|
@@ -9,6 +10,8 @@ module Rudash
|
|
9
10
|
slice_matcher = Rudash::SubsetDeepMatch.subset_deep_match?.(filter)
|
10
11
|
return self.filter(collection, slice_matcher)
|
11
12
|
end
|
13
|
+
|
14
|
+
return [] if !Rudash::Utils.is_function?(filter)
|
12
15
|
|
13
16
|
if collection.is_a?(Array)
|
14
17
|
begin
|
data/lib/rudash/flip.rb
CHANGED
data/lib/rudash/map.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
require_relative '../utils/index.rb'
|
2
|
+
|
1
3
|
module Rudash
|
2
4
|
module Map
|
3
5
|
def map(collection, *rest_args)
|
4
6
|
mapper_proc = self.head(rest_args) || self.method(:identity)
|
5
|
-
|
6
7
|
col = collection.is_a?(String) ? collection.split('') : collection
|
8
|
+
|
9
|
+
return self.map(collection, -> () { nil }) if !Rudash::Utils.is_function?(mapper_proc)
|
7
10
|
|
8
11
|
if col.is_a?(Array)
|
9
12
|
begin
|
data/lib/rudash/negate.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
+
require_relative '../utils/index.rb'
|
2
|
+
|
1
3
|
module Rudash
|
2
4
|
module Negate
|
3
5
|
def negate(a_proc)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
else
|
10
|
-
raise 'Expected a Proc'
|
11
|
-
end
|
6
|
+
raise 'Expected a Proc/Method' if !Rudash::Utils.is_function?(a_proc)
|
7
|
+
|
8
|
+
negate_proc = -> (*args) {
|
9
|
+
!a_proc.(*args)
|
10
|
+
}
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
data/lib/rudash/reduce.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
require_relative '../utils/index.rb'
|
2
|
+
|
1
3
|
module Rudash
|
2
4
|
module Reduce
|
3
5
|
def reduce(collection, *rest_args)
|
4
6
|
reducer = rest_args[0]
|
5
7
|
initial_state = rest_args[1]
|
6
|
-
|
7
8
|
col = collection.is_a?(String) ? collection.split('') : collection
|
9
|
+
|
10
|
+
return self.reduce(collection, -> (acc, current) { nil }) if !Rudash::Utils.is_function?(reducer)
|
8
11
|
|
9
12
|
case rest_args.size
|
10
13
|
when 1
|
data/lib/rudash/reject.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
+
require_relative '../utils/index.rb'
|
1
2
|
require_relative '../utils/subset_deep_match.rb'
|
2
3
|
|
3
4
|
module Rudash
|
4
5
|
module Reject
|
5
6
|
def reject(collection, *rest_args)
|
6
|
-
filter = self.head(rest_args) || self.method(:identity)
|
7
|
+
filter = self.head(rest_args) || self.method(:identity)
|
7
8
|
|
8
9
|
if filter.is_a?(Hash)
|
9
10
|
slice_matcher = Rudash::SubsetDeepMatch.subset_deep_match?.(filter)
|
10
11
|
return self.filter(collection, self.negate(slice_matcher))
|
11
|
-
elsif
|
12
|
+
elsif Rudash::Utils.is_function?(filter)
|
12
13
|
return self.filter(collection, self.negate(filter))
|
13
14
|
else
|
14
15
|
return []
|
data/lib/rudash/update.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
require_relative '../utils/index.rb'
|
2
|
+
|
1
3
|
module Rudash
|
2
4
|
module Update
|
3
5
|
def update(object, path, *rest_args)
|
4
6
|
updater = self.head(rest_args) || self.method(:identity)
|
7
|
+
return object if !Rudash::Utils.is_function?(updater)
|
8
|
+
|
5
9
|
current_value = self.get(object, path)
|
6
10
|
self.set(object, path, updater.(current_value))
|
7
11
|
object
|
data/lib/utils/index.rb
CHANGED
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.9.
|
4
|
+
version: 2.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Islam Attrash
|
@@ -42,7 +42,6 @@ files:
|
|
42
42
|
- lib/rudash/is_hash.rb
|
43
43
|
- lib/rudash/is_nil.rb
|
44
44
|
- lib/rudash/is_number.rb
|
45
|
-
- lib/rudash/is_proc.rb
|
46
45
|
- lib/rudash/is_string.rb
|
47
46
|
- lib/rudash/join.rb
|
48
47
|
- lib/rudash/keys.rb
|