totally_lazy 0.1.61 → 0.1.62

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2U1YmI5YTgyMzllMDcwODE3MjU3NWEzZTc5NDExNmY0ZjA0OGNiYQ==
4
+ NGIyOWM0MTc0ZTdjZTY4YTM5OTljMWMzNDQyNGQ4MDMyZGNiMWI5YQ==
5
5
  data.tar.gz: !binary |-
6
- MGVmMzdiYzkyNDkyYTgzOTgxYWVkOTZmOWYwNzZiZDg1MDJiNWVmYg==
6
+ ZGJhYjQxZTZjZWUyZjU1MDc4NGNkMzljYmFmMjAyZjZjNzJmYjQwOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGMwNzk5ODBmMmJmZGRiMjYwNWU0MzZiMjM4OGU2OWU1ZDUwNDAyYjQ4NDc5
10
- YmVmZDYzN2NlMWE4ZjQ5NGQxMDM4YWQ0MTg4MTY1NDA2Yzg2ZjdmM2UwNzMz
11
- YTNhMjRhMWEwNzcxN2E0ZDEwMWVkMWRmOTYwNzgzZDYwZGNlOTE=
9
+ NDU3MDAxZTQ2NTJlYzlmMzg5OTM3ZDllM2I1N2Q5MDJjYjBiZTcyYzU4YzQ3
10
+ YWQ5ZDNhZjI2NGM1NGEwZDliNDhhMTA1OThkNGExMTIxNzQyNTU2ZjYyYTMx
11
+ NmM1Nzg5ZGU3MzM1ZjExMGUyMDQ5ZjM0OTdmODE2ZTk2YmFhMGQ=
12
12
  data.tar.gz: !binary |-
13
- NmRhOWUxOTVjYWRmN2FiM2EzNzI0OTQ0NWNjOWQzYTdjN2U5ZDQ3NTFmNzJi
14
- Yzg0MDgzYWM4NjQxNGQ0Nzc1MDdhYmJmZDdlOTY5MDlhOTJlOTQwNTliNjkx
15
- YWI4ZTE0NzU0NTVjNzdlNjE2MTVhM2ExYzZhZjU2MzZjZjIzOGE=
13
+ ODFkNzFhMmYzM2NlZmVkYzAwM2RhZmYyODYwMjAzODQ3YzA3NjI1ODRjMDMy
14
+ ZjU5NzMyMTI5YzBiNjViY2U1Yjg5MDliMjAwY2U4MjA4M2RhY2UyODMxMGI2
15
+ ZTU3MWNiNjQzZjAwYzdlMTdmODkzODk4NDVjYzU4ZmJjOGViMWY=
@@ -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.61
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-03 00:00:00.000000000 Z
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