monad-oxide 0.13.0 → 0.14.0
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/lib/result.rb +22 -0
- data/lib/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: 1f4a3e02d264fe9a27b7e48c58865eacf77db7a083d75d4c6383aa76243d65a9
|
|
4
|
+
data.tar.gz: f422c2b96a295fa4bcfee050d494c43f8ee721dac43d8e609321cfecf2f0020c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c146c13f5d0a6867ec4cd0426c2a765c611c6c71b83bb12a5872ef2adc0fea4fb9845b46c9925d0a731722420d1c603afbbb0e72c3890405790c66c9474e249
|
|
7
|
+
data.tar.gz: 0732a70394523cfde5269d72ec6581ff7695bce800aea1cdd86e1c78574b81d419aaa8a38fb2dfde7b5e988673493f03261294b48e18ca37e6c1f22bdbd1c67a
|
data/lib/result.rb
CHANGED
|
@@ -58,6 +58,28 @@ module MonadOxide
|
|
|
58
58
|
# protected :new
|
|
59
59
|
# end
|
|
60
60
|
|
|
61
|
+
class << self
|
|
62
|
+
|
|
63
|
+
##
|
|
64
|
+
# Convenience for executing arbitrary code and coercing it to a Result.
|
|
65
|
+
# Any exceptions raised coerce it into an Err, and the return value is the
|
|
66
|
+
# value for the Ok.
|
|
67
|
+
# @param f [Proc<Result<A>>] The function to call. Could be a block
|
|
68
|
+
# instead. Takes no arguments and could return any [Object].
|
|
69
|
+
# @yield Will yield a block that takes no arguments A and returns a
|
|
70
|
+
# [Object]. Same as `f' parameter.
|
|
71
|
+
# @return [MonadOxide::Result<A, E>] An Ok if there are no exceptions
|
|
72
|
+
# raised, and an Err with the exception if any exception is raised.
|
|
73
|
+
def try(f=nil, &block)
|
|
74
|
+
begin
|
|
75
|
+
MonadOxide.ok((f || block).call())
|
|
76
|
+
rescue => e
|
|
77
|
+
MonadOxide.err(e)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
61
83
|
def initialize(data)
|
|
62
84
|
raise NoMethodError.new('Do not use Result directly. See Ok and Err.')
|
|
63
85
|
end
|
data/lib/version.rb
CHANGED
|
@@ -3,5 +3,5 @@ module MonadOxide
|
|
|
3
3
|
# This version is locked to 0.x.0 because semver is a lie and this project
|
|
4
4
|
# uses CICD to push new versions. Any commits that appear on main will result
|
|
5
5
|
# in a new version of the gem created and published.
|
|
6
|
-
VERSION='0.
|
|
6
|
+
VERSION='0.14.0'
|
|
7
7
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: monad-oxide
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Logan Barnett
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: org-ruby
|