totally_lazy 0.1.61 → 0.1.62
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/option.rb +8 -0
- data/spec/totally_lazy/option_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGIyOWM0MTc0ZTdjZTY4YTM5OTljMWMzNDQyNGQ4MDMyZGNiMWI5YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGJhYjQxZTZjZWUyZjU1MDc4NGNkMzljYmFmMjAyZjZjNzJmYjQwOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDU3MDAxZTQ2NTJlYzlmMzg5OTM3ZDllM2I1N2Q5MDJjYjBiZTcyYzU4YzQ3
|
10
|
+
YWQ5ZDNhZjI2NGM1NGEwZDliNDhhMTA1OThkNGExMTIxNzQyNTU2ZjYyYTMx
|
11
|
+
NmM1Nzg5ZGU3MzM1ZjExMGUyMDQ5ZjM0OTdmODE2ZTk2YmFhMGQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODFkNzFhMmYzM2NlZmVkYzAwM2RhZmYyODYwMjAzODQ3YzA3NjI1ODRjMDMy
|
14
|
+
ZjU5NzMyMTI5YzBiNjViY2U1Yjg5MDliMjAwY2U4MjA4M2RhY2UyODMxMGI2
|
15
|
+
ZTU3MWNiNjQzZjAwYzdlMTdmODkzODk4NDVjYzU4ZmJjOGViMWY=
|
data/lib/totally_lazy/option.rb
CHANGED
@@ -120,6 +120,10 @@ class Some < Option
|
|
120
120
|
|
121
121
|
alias get_or_throw get_or_raise
|
122
122
|
|
123
|
+
def to_either(left)
|
124
|
+
right(value)
|
125
|
+
end
|
126
|
+
|
123
127
|
def enumerator
|
124
128
|
Enumerator.new { |y|
|
125
129
|
y << @value
|
@@ -203,6 +207,10 @@ class None < Option
|
|
203
207
|
}
|
204
208
|
end
|
205
209
|
|
210
|
+
def to_either(value)
|
211
|
+
left(value)
|
212
|
+
end
|
213
|
+
|
206
214
|
def <=>(other)
|
207
215
|
other == NONE
|
208
216
|
end
|
@@ -97,6 +97,14 @@ describe 'Option' do
|
|
97
97
|
expect{none.get_or_raise(RuntimeError.new)}.to raise_error(RuntimeError)
|
98
98
|
end
|
99
99
|
|
100
|
+
it 'should support converting some to_either as right' do
|
101
|
+
expect(some('all good').to_either('borked')).to eq(right('all good'))
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should support converting none to_either as left' do
|
105
|
+
expect(none.to_either('borked')).to eq(left('borked'))
|
106
|
+
end
|
107
|
+
|
100
108
|
it 'should raise exception if you try to use both lambda and block' do
|
101
109
|
expect { some(1).exists?(->(a) { a == 1 }) { |b| b == 2 } }.to raise_error(RuntimeError)
|
102
110
|
expect { none.exists?(->(a) { a == 1 }) { |b| b == 2 } }.to raise_error(RuntimeError)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: totally_lazy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.62
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raymond Barlow
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-03-
|
12
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby-edge
|