totally_lazy 0.1.29 → 0.1.30

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
- NTY1MTJjY2YzODk1NWFlZjI0Y2VjYzYyNzEyZWI0NTFlMjU5ZmI2NQ==
4
+ ZTQ2YmVkZDgxNGZlNzM3M2JkMzZmMmEyM2NhNTgwZGRlMGExMDE2Mw==
5
5
  data.tar.gz: !binary |-
6
- NGE3YmJlNTg4NGRiY2I3YmFkYmUxODU3N2U2ODBiNzc3ZTlhN2Q2YQ==
6
+ NjMzYTViMTYzMzNmNGRkMTg1ZGQyM2E5ODc2M2E3Zjg3ZmZkZWJmMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Njg1ZTY4MjM5ZTcwNzc0YTI4NzMzZDNkYWQ5MjY2NmJiMDZiZTRiYjZjOGUy
10
- ZjQzMGM2YWY4NDZmN2ZhNWJmMGI2YzU2OGNhMTc4Njg1MTFmZDFjYjFmYWU0
11
- NjEyMWVjMmI3NTRmNDliMzgxMTI4NmQyOTg1YzcyYjY0NDNjNTc=
9
+ MmY4Njg5Mzc0NThhMjI1OWNmMmU4ODY3YmU2ODY1MTlmZjlhMWNkZDcyOWMw
10
+ ZjQ4NDNlYjY1NWM2ZTQyNGJhMjYxMzA5NDMzMjQzODI0ZDlmZTZlYTk4NTBm
11
+ ZGVhYmQ5YzdjMTg3NDgyZWI3NzkyMmZiNWFjYTgyOWUwM2VjMTU=
12
12
  data.tar.gz: !binary |-
13
- NTU2OTllZjkzZmRhZmI5NDZkNjg3ZmY5NWExYWVlMzk3MDJlNTdlODZlZDFh
14
- M2Y5MGZmYTRjZGY4OGFkMDg2ODFlNGY5MWE0ZmExZDljMDQ1NGYyZjBhYTgy
15
- MGQyOGFmNGRiNGJlYWZmMjZiMGY5MzkyOWNmOWI2ZWJhNzhlODY=
13
+ NTI4YmJlNmIwMGE3YTZkZGIxODEzZjE4MmYwMDk2NmViYzJmOTVmNzRkYTVj
14
+ YmNmZTcwNDhmYTAwZGI0NjU1ZTJlNzRmYWQ5YTAzMThjNjk2NDU4NWViMmVk
15
+ MjJmZDIzYTMyMWFhYmZmZDNhZDcyZDQxMjBjYTZjM2U3NTVlNWM=
@@ -34,6 +34,10 @@ class Either
34
34
  def self.right(value)
35
35
  Right.new(value)
36
36
  end
37
+
38
+ def flatten
39
+ flat_map(identity)
40
+ end
37
41
  end
38
42
 
39
43
  class Left < Either
@@ -35,6 +35,11 @@ describe 'Either' do
35
35
  expect(left(2).flat_map { right(5) }).to eq(left(2))
36
36
  end
37
37
 
38
+ it 'should support flatten' do
39
+ expect(right(left(ZeroDivisionError.new)).flatten).to eq(left(ZeroDivisionError.new))
40
+ expect(right(right(1)).flatten).to eq(right(1))
41
+ end
42
+
38
43
  it 'should raise exception if you try to use both lambda and block' do
39
44
  expect { right(1).map(add(2)) { |a| a+2 } }.to raise_error(RuntimeError)
40
45
  expect { right(1).map_left(add(2)) { |a| a+2 } }.to raise_error(RuntimeError)
@@ -42,5 +47,4 @@ describe 'Either' do
42
47
  expect { right(10).flat_map(divide(2)) { |a| a/2 } }.to raise_error(RuntimeError)
43
48
  expect { left(10).flat_map(divide(2)) { |a| a/2 } }.to raise_error(RuntimeError)
44
49
  end
45
-
46
50
  end
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.29
4
+ version: 0.1.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raymond Barlow