decoding 0.2.5 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91611249210837a0a3b5140bd19bd53d5862bf4ab7f56249797da3e9348c5712
4
- data.tar.gz: 518d2eee3ff13717a2170b2c008d297a7c60986886e3281ef0b5d883e7b077b8
3
+ metadata.gz: 5d613b53b493863ecae1fcbc778f5684acbbc628ad51f88fca0953889cd138d0
4
+ data.tar.gz: cfc4039a5bfcf182c174b0d1f037d2cbd3b610fa746904906a2209b680fb4cad
5
5
  SHA512:
6
- metadata.gz: 01d88efba9c04b704763945e87c70a18e437a64313b944382eac83fd795fa293bb20618d92c513babfd17f6a1c51efdb2c039fa2aab7d914608a8115ef30501c
7
- data.tar.gz: a02ca210632cdb66dd15e0f0b14aae449b43aace345988a38a94abd626f87c1f37bd5b66dfdd2d29202ff0ac2ce850012b18d522844d31239839d73c66626cf4
6
+ metadata.gz: cbe2df98d6a2b6b9588cc5ecfe5543cae21575488a09d99768f10791fdb66332f8cda35483b6e61045a8bbdb5949f900cdd69ab94cfb602e456fb05f5dbfa14e
7
+ data.tar.gz: e0eaddb3e027ba796f126aa500564507481847c196d139b16a51c390cb28990706be3d959bde8700857abbf2c18fc69765f79c03cd7cd16cbfd5e7a7be03be92
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.6]
4
+
5
+ * Add `Decoding::Result#unwrap!`
6
+
3
7
  ## [0.2.5]
4
8
 
5
9
  * Report all error messages in the `any` decoder
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Decoding
4
+ # Raised when calling {Result#unwrap!} on an `Err` value.
5
+ class UnwrapError < StandardError; end
6
+
4
7
  # A result represent the outcome of some computation that can succeed or fail.
5
8
  # The results are represented with two subclasses of `Result`: `Ok` and `Err`.
6
9
  # Each hold a single result value.
@@ -83,6 +86,14 @@ module Decoding
83
86
  # @return [Object]
84
87
  def unwrap(default_value) = default_value
85
88
 
89
+ # Extract the value out of a `Result` value. In case of an `Ok`, this
90
+ # returns the result's value. In case of an `Err`, a {UnwrapError} is
91
+ # raised with the error value as its message.
92
+ #
93
+ # @raise [Decoding::UnwrapError] if the result is an `Err` value.
94
+ # @return [Object]
95
+ def unwrap! = raise(UnwrapError, value.to_s)
96
+
86
97
  # Extract the error value out of a `Result` value. In case of an `Err`, this
87
98
  # returns the result's value. In case of an `Ok`, the given `default_value`
88
99
  # is returned.
@@ -142,6 +153,7 @@ module Decoding
142
153
 
143
154
  def ok? = true
144
155
  def unwrap(_) = value
156
+ def unwrap! = value
145
157
  def map = self.class.new(yield value)
146
158
 
147
159
  def and(other)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Decoding
4
- VERSION = "0.2.5"
4
+ VERSION = "0.2.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decoding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arjan van der Gaag