totally_lazy 0.1.24 → 0.1.25

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
- MDYzZWI5MTUyYTE0ZDkwNjc4YWUzYzRkYTJhMTRiZmRiNjkyMjczNQ==
4
+ NTg4NmIzMmQ3NDlhYmU5ZWY1MzY2MjlmNTNkZjJhOTFmMWJjNDViMw==
5
5
  data.tar.gz: !binary |-
6
- YmY4ZmI5OTIwNTk2ODNmYTA2OGU5Yjc3YmIyZjM1MjJiMThmMjE1ZA==
6
+ ZjZjZjFjY2NiNzQ4ZWI0NjVjOTczMzE3NTQ5YWI5ZTJmNTU2MDY0Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWQ0MGNkM2RmYjhmZDkxOWM1MDM3ZDg2Y2E1ZjI4ZTNiNmQxODM1MzlhY2Vh
10
- OTM5M2IyYmM5M2JjNGIxM2VjNDk3YmNkNWJlMzJmMGVjN2I1NWUwZDc1OGEz
11
- MDBlNWRhNzY4M2ZmODViYThjYjI2YjNlNTAyMzg3ZmQ2YzU0NjU=
9
+ ZjhhY2YzNTY2ZWMyZmQyZDA0OWU5NmM0NjMxZWE3OGFiNGNjOTZiMzdlN2Vm
10
+ OWNmZDU4NjI2MGQ0MWQyNjI3YTExZmY2NGQyODhlZDhlN2RkNzVmZTY5OGVj
11
+ N2I1YzVlODVjMWJkYmRiYTliYTU5NDE0Yjk0ZWM2M2Q3NDFmOTE=
12
12
  data.tar.gz: !binary |-
13
- ODIwNjgyZTQzMWE3MmM2OWViY2I0MTMxODkzNjBkZjcwODMwNmZiNDRjOTM4
14
- Y2UwODQ4ZmZkZTRlYTg2MjIwYWE5MmU1OWRlNTVjNGU3MDZmZTI1YTE5ZDQ5
15
- MjQxOTBiMjczYTYyODhiMGZiZTNlNTNjZDk4NGIxNmRkY2UxMmU=
13
+ MjcwMTY3OWIxNjBlNjk5ZTY1YTAxODM1ZWI1MzVlYmJjZGQ1ZDk0Mzg0YWQ0
14
+ MGQ4ZWI2OTkyMDA4YWUwYThlZWY2YmMwNjhjYzljZDEyNGQ0ZjgxOGY5Y2Qz
15
+ ZTZiMjZkMzBhODcyZjk1NzQ1ZGZhNGEwMmZiOTQ1YTVhZWE4M2U=
@@ -113,6 +113,12 @@ class Some < Option
113
113
  get
114
114
  end
115
115
 
116
+ def get_or_raise(error)
117
+ get
118
+ end
119
+
120
+ alias get_or_throw get_or_raise
121
+
116
122
  def enumerator
117
123
  Enumerator.new { |y|
118
124
  y << @value
@@ -185,6 +191,11 @@ class None < Option
185
191
  nil
186
192
  end
187
193
 
194
+ def get_or_raise(error)
195
+ raise error
196
+ end
197
+
198
+ alias get_or_throw get_or_raise
188
199
  def enumerator
189
200
  Enumerator.new { |y|
190
201
  raise StopIteration.new
data/spec/option_spec.rb CHANGED
@@ -93,6 +93,11 @@ describe 'Option' do
93
93
  expect(option(nil).get_or_nil).to eq(nil)
94
94
  end
95
95
 
96
+ it 'should support get_or_raise' do
97
+ expect(some("bob").get_or_raise(RuntimeError.new)).to eq("bob")
98
+ expect{none.get_or_raise(RuntimeError.new)}.to raise_error(RuntimeError)
99
+ end
100
+
96
101
  it 'should raise exception if you try to use both lambda and block' do
97
102
  expect { some(1).exists?(->(a) { a == 1 }) { |b| b == 2 } }.to raise_error(RuntimeError)
98
103
  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.24
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raymond Barlow