totally_lazy 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/lib/option.rb +4 -0
  3. data/spec/option_spec.rb +5 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGUwZmNlOWE1NDZiMmM1MTkyNGZiMTk3ZDkyZWRjYWI2MjU2MTAzOQ==
4
+ NjVkZmRmNmMyNzlkYmY4ODlhYjhlMzFlN2FlMDQ0ZjIyOWE3M2ZiNg==
5
5
  data.tar.gz: !binary |-
6
- ZmMyNmM3MjBjM2UyYWM3N2U4ZjZjYTJmYzdhY2QzMjZmZGE4ZTBjOQ==
6
+ OWI2NWQzMmFiODVjZjg1ZGI0NGQzN2JhNmY4MWU5MWQ3Y2NkYjdjYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZmIyYTI0NTM3ZTA3MThjNzMyMDdmYmY2MjBhZmZiN2JiZDJmZjFjYmJiNWZh
10
- ODEyODNmZmZjNGUxNjhlMmJkNDVkYjdkNjcyMmU2MDhhM2I5ZWMyMjhmNWM5
11
- NTZiZWVkYmVkN2EyMDk2M2ZlZWUwYzU1MjljMzJiYWJlZTQyOWE=
9
+ MGI4MzBiOTlmZWEyYjgzZTBhODgwYTMyNzFjMTJiMzQyY2M2ZmJmNDFhNGI0
10
+ ODAyYzIyMjhkMjRmNTBjZmY0N2IyNWRlYTFjM2M3NDhmODkwN2IyMDI2NDJm
11
+ YmE5NWM4MDdkNzY5NGE4YTNlYTI5ZDUwNTE3Mjg3ZTgwYzQ1NGI=
12
12
  data.tar.gz: !binary |-
13
- MThiYWVkMTExMWM4NDI3NGExZmRlMDk1NjJlNzg4NWQyYTNiZDViODYzMmEz
14
- ZjAyNGRlZDViMDM4NWMwYzcwYjI1MTZjZGMzYzhlODkwNGQ4MGUzM2NkMWU2
15
- ZGZmYmMyMmEwNTlhNzQ2ZjkxNjg4NzY3NmQyZjFhZTdkMzQ0ODc=
13
+ ZTQwNmZhZTRhZTliOTRmZjJkMjkxNTE4ZjQ5NGVjNWZlMzFiYTcyZWUxYzg5
14
+ OWM1MTM5NTkxMTk0NjUwNWE1YThiOWY1OTI2OWRiNjQ3YzA3MTRkN2JhMzZi
15
+ NzkyM2RkYTcyYmE2MWJiY2U2Njc4NjJjZWExNWZjMjM0MzcyYzQ=
data/lib/option.rb CHANGED
@@ -60,6 +60,10 @@ module Option
60
60
 
61
61
  alias fold_left fold
62
62
 
63
+ def flatten
64
+ flat_map(identity)
65
+ end
66
+
63
67
  def is_empty?
64
68
  false
65
69
  end
data/spec/option_spec.rb CHANGED
@@ -52,6 +52,11 @@ describe 'Option' do
52
52
  expect(none.flat_map(some(4))).to eq(none)
53
53
  end
54
54
 
55
+ it 'should support flatten' do
56
+ expect(some(some(1)).flatten).to eq(some(1))
57
+ expect(some(none).flatten).to eq(none)
58
+ end
59
+
55
60
  it 'should raise exception if you try to use both lambda and block' do
56
61
  expect { some(1).exists?(->(a) { a == 1 }) { |b| b == 2 } }.to raise_error(RuntimeError)
57
62
  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.19
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raymond Barlow