lab42_result 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/lab42/result.rb +2 -2
- data/lib/lab42/result/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 750477a65983be7bc572b456f0655833cc71fcd56a5ee0ec4ceb7a474611ea2b
|
4
|
+
data.tar.gz: 857690234b894bfc357c5dfddd167c8ad3f4f66096192e25bafe0a0d07488cf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c7c7a15c3f80d3ceebd8284aace83bea7cc6e622b9b7f05d0a6c6bef385440e28a3f6895ecc3a815a049a4949474479ef700285ab132ee6316546874aff4df0
|
7
|
+
data.tar.gz: e27d27f6b56da1ac24af9a70adc5a6b0e317f883a2fcd586113ba443014a26d1380dfb6325c462602de2f35301689668e9dea7ac11b9c8c9c13ada433798def0
|
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
|
2
|
+
[](http://badge.fury.io/rb/lab42_result)
|
3
|
+
|
1
4
|
# Lab42::Result
|
2
5
|
|
3
6
|
A result encapsulation class, like the `Either` type in Haskell.
|
@@ -36,6 +39,10 @@ Example: And will not raise any error
|
|
36
39
|
expect( ok.raise! ).to eq(42)
|
37
40
|
```
|
38
41
|
|
42
|
+
And the same holds for `raise!` with a replacement Exception
|
43
|
+
```ruby
|
44
|
+
expect( ok.raise!(ArgumentError) ).to eq(42)
|
45
|
+
```
|
39
46
|
#### If Error
|
40
47
|
|
41
48
|
Example: It's h(error)
|
@@ -56,6 +63,11 @@ Example: And will certainly raise this time
|
|
56
63
|
expect{ error.raise! }.to raise_error(RuntimeError, "oh no!")
|
57
64
|
```
|
58
65
|
|
66
|
+
And as often times you will match on an error case only and raise a custom exception the following shortcut comes in handy
|
67
|
+
```ruby
|
68
|
+
expect{ error.raise!(KeyError) }.to raise_error(KeyError, "oh no!")
|
69
|
+
```
|
70
|
+
|
59
71
|
#### Capturing Exceptions
|
60
72
|
|
61
73
|
If you have a piece of code like this:
|
data/lib/lab42/result.rb
CHANGED
data/lib/lab42/result/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab42_result
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|