totally_lazy 0.1.23 → 0.1.24

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
- ZjQ0ZWZiYjdhYjFkODdjOTU3M2IzMTQ0MGY0YmYxMzUwMjI0OWQ0Ng==
4
+ MDYzZWI5MTUyYTE0ZDkwNjc4YWUzYzRkYTJhMTRiZmRiNjkyMjczNQ==
5
5
  data.tar.gz: !binary |-
6
- Mzg2NzRhNzgwZDYzODE4M2M4ZmY4OTZlOWRkMjViNDNlY2M2NjA4OQ==
6
+ YmY4ZmI5OTIwNTk2ODNmYTA2OGU5Yjc3YmIyZjM1MjJiMThmMjE1ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2M0MWVjYTEzOWFmZWI4MWQzNjFiMWI5MjkzNjY0NjkyYzMwYmE3MzM2YjNk
10
- ZTgyOGU1MGY5NGQwNzk5ZTViMzFlZjc0NDE4YTIwNDg3ZjgwMjNiNzQwYTU5
11
- NTc5NDBiNjM3MTdhZDM2MzQ2ODA4YzdjOWMyZDMwOWJkNTM0MGY=
9
+ YWQ0MGNkM2RmYjhmZDkxOWM1MDM3ZDg2Y2E1ZjI4ZTNiNmQxODM1MzlhY2Vh
10
+ OTM5M2IyYmM5M2JjNGIxM2VjNDk3YmNkNWJlMzJmMGVjN2I1NWUwZDc1OGEz
11
+ MDBlNWRhNzY4M2ZmODViYThjYjI2YjNlNTAyMzg3ZmQ2YzU0NjU=
12
12
  data.tar.gz: !binary |-
13
- ZjE3ZTJmMzg1NzViZjY0ZGNiMmJlNGU2MDIwZjY4MDJlY2NjYjBkM2U4YjNh
14
- MDQ2ZWU5YmQ1ZjkwYTEzNDYzYWE0YjQ5MzYxZDdjNGZmMWJmZmU5NzdkMDNl
15
- NGI1YjQ5YWIxMDZmYWNlMzFhYjdjZGY4ZGM0MTBjZDQwYzMyNmI=
13
+ ODIwNjgyZTQzMWE3MmM2OWViY2I0MTMxODkzNjBkZjcwODMwNmZiNDRjOTM4
14
+ Y2UwODQ4ZmZkZTRlYTg2MjIwYWE5MmU1OWRlNTVjNGU3MDZmZTI1YTE5ZDQ5
15
+ MjQxOTBiMjczYTYyODhiMGZiZTNlNTNjZDk4NGIxNmRkY2UxMmU=
@@ -109,6 +109,10 @@ class Some < Option
109
109
 
110
110
  alias or_else get_or_else
111
111
 
112
+ def get_or_nil
113
+ get
114
+ end
115
+
112
116
  def enumerator
113
117
  Enumerator.new { |y|
114
118
  y << @value
@@ -177,6 +181,10 @@ class None < Option
177
181
 
178
182
  alias or_else get_or_else
179
183
 
184
+ def get_or_nil
185
+ nil
186
+ end
187
+
180
188
  def enumerator
181
189
  Enumerator.new { |y|
182
190
  raise StopIteration.new
@@ -83,7 +83,6 @@ class Sequence
83
83
  left.zip(right)
84
84
  end
85
85
 
86
-
87
86
  def self.sequence(*items)
88
87
  if items.first.nil?
89
88
  empty
data/spec/option_spec.rb CHANGED
@@ -70,7 +70,7 @@ describe 'Option' do
70
70
  end
71
71
 
72
72
  it 'should support get_or_else with value (aka or_else)' do
73
- expect(Option::some(1).get_or_else(2)).to eq(1)
73
+ expect(some(1).get_or_else(2)).to eq(1)
74
74
  expect(some(1).or_else(2)).to eq(1)
75
75
  expect(none.get_or_else(2)).to eq(2)
76
76
  expect(option(1).get_or_else(2)).to eq(1)
@@ -86,6 +86,13 @@ describe 'Option' do
86
86
  expect { option(nil).get_or_else(call_raises(RuntimeError.new)) }.to raise_error(RuntimeError)
87
87
  end
88
88
 
89
+ it 'should support get_or_nil' do
90
+ expect(some(1).get_or_nil).to eq(1)
91
+ expect(none.get_or_nil).to eq(nil)
92
+ expect(option(1).get_or_nil).to eq(1)
93
+ expect(option(nil).get_or_nil).to eq(nil)
94
+ end
95
+
89
96
  it 'should raise exception if you try to use both lambda and block' do
90
97
  expect { some(1).exists?(->(a) { a == 1 }) { |b| b == 2 } }.to raise_error(RuntimeError)
91
98
  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.23
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raymond Barlow