totally_lazy 0.1.44 → 0.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/totally_lazy/predicates.rb +4 -5
- data/spec/totally_lazy/either_spec.rb +2 -2
- data/spec/totally_lazy/predicates_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjhhYmY1NzQzYTQ3MGI3NDM5OGI3ODFkNGYzY2Y4YjFkMzQwYjZkNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWVlYmZkOTA1YmE0ZmI0YWQzMDQ2MWJmOTM3ZGVhM2JmMTMyODhhMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWRmZmFhMjMyMDdlYTk1N2MxYzAxNDI3NTE0MTQzNTMwNzMyODcyZmM2OGVh
|
10
|
+
ZWFlMjFhMmYyYzJiYjU2M2Y0YTNlYzI5NjY3ZGQzNTFkNGY3OWVkYjVjOThm
|
11
|
+
YTIyZDBlN2EyZmZmNzdlNWY3MDAzZTZiMDllMzBhZGE5YjRiZmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjhiYzIxYzAxMDZhZTUyYWE5MWU4MWFkODBhNzI0MjkyYmNhZTE0MDIzZWQ0
|
14
|
+
OWJkOGVlOTA3Yzk0MzE2MjZjZGI3Y2RlYzNlZDg4NDlkNGE5MGJjZGVmYjll
|
15
|
+
ZTUxNTM5ZTc4MWE5YmVlMTIzZjg1MTMzM2RjODM5NzJjODA5NTY=
|
@@ -4,21 +4,20 @@ module Predicates
|
|
4
4
|
-> (bool) { !pred.(bool) }
|
5
5
|
end
|
6
6
|
|
7
|
-
def is_left
|
7
|
+
def is_left
|
8
8
|
-> (either) { either.is_left? }
|
9
9
|
end
|
10
10
|
|
11
|
-
def is_right
|
11
|
+
def is_right
|
12
12
|
-> (either) { either.is_right? }
|
13
13
|
end
|
14
14
|
|
15
|
-
def matches
|
15
|
+
def matches(regex)
|
16
16
|
->(value) { !regex.match(value).nil? }
|
17
17
|
end
|
18
18
|
|
19
19
|
def equal_to?(that)
|
20
20
|
->(this) { this == that }
|
21
21
|
end
|
22
|
-
alias is
|
23
|
-
|
22
|
+
alias is equal_to?
|
24
23
|
end
|
@@ -18,8 +18,8 @@ describe 'Either' do
|
|
18
18
|
|
19
19
|
it 'can be used in filter and map' do
|
20
20
|
eithers = sequence(left('error'), right(3))
|
21
|
-
expect(eithers.filter(is_left
|
22
|
-
expect(eithers.filter(is_right
|
21
|
+
expect(eithers.filter(is_left).map(get_left)).to eq(sequence('error'))
|
22
|
+
expect(eithers.filter(is_right).map(get_right)).to eq(sequence(3))
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should support map' do
|
@@ -2,13 +2,13 @@ require_relative '../spec_helper'
|
|
2
2
|
|
3
3
|
describe 'Predicates' do
|
4
4
|
it 'should allow regex matching' do
|
5
|
-
expect(sequence('Stacy').find(matches
|
6
|
-
expect(sequence('Raymond').find(matches
|
5
|
+
expect(sequence('Stacy').find(matches(/Stac/))).to eq(some('Stacy'))
|
6
|
+
expect(sequence('Raymond').find(matches(/NotAwesome/))).to eq(none)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should allow is' do
|
10
|
-
expect(sequence('Stuff').find(is
|
10
|
+
expect(sequence('Stuff').find(is('Stuff'))).to eq(some('Stuff'))
|
11
11
|
expect(sequence('Stuff').find(equal_to?('Stuff'))).to eq(some('Stuff'))
|
12
|
-
expect(sequence('Stuff').find(is
|
12
|
+
expect(sequence('Stuff').find(is('Nothing'))).to eq(none)
|
13
13
|
end
|
14
14
|
end
|