l43_core 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/lib/l43/core/as_result.rb +31 -0
- data/lib/l43/core/result.rb +10 -3
- data/lib/l43/core/version.rb +1 -1
- data/lib/l43/core.rb +2 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b964ad4c7819f22e58ec71b9768521105318d9bdcc42d9d860e399bd9864c491
|
|
4
|
+
data.tar.gz: e6399e1a021ca7b549a0c41589e8e200891269e3099fe36a6a6cfd755c4e8ac7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 31d4957c4b081d12d22e3b8236f91bfeed7b93dc99941374d22ae421dd58aacdf2807ec7e7f70a1285be685714bcb53fab409f6dada9ca4125d5fd2a399de849
|
|
7
|
+
data.tar.gz: ea5c0da5bac00c239e95c74f213cac1f88e321e78227bce9e7ef6bed7d079b25ca764d5d09d723cea00bcb51039a4f2264dd0768cdf82ba6a3eb66f7be40a403
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'result'
|
|
4
|
+
module L43
|
|
5
|
+
module Core
|
|
6
|
+
module AsResult
|
|
7
|
+
def self.extended(from)
|
|
8
|
+
from.include self
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def as_result(&blk)
|
|
12
|
+
Result.ok(blk.())
|
|
13
|
+
rescue StandardError => se
|
|
14
|
+
Result.error(se.message)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def as_result_fn(&blk)
|
|
18
|
+
-> (*a, **k, &b) do
|
|
19
|
+
as_result { blk.(*a, **k, &b) }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def defresult(name, &blk)
|
|
24
|
+
define_method name do |*a, **k, &b|
|
|
25
|
+
as_result { blk.(*a, **k, &b) }
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
data/lib/l43/core/result.rb
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'l43/core'
|
|
4
3
|
require 'l43/errors'
|
|
4
|
+
require_relative 'result/constructors'
|
|
5
|
+
|
|
5
6
|
module L43
|
|
6
7
|
module Core
|
|
7
|
-
require_all __FILE__
|
|
8
8
|
class Result
|
|
9
9
|
extend Constructors
|
|
10
10
|
|
|
11
|
+
def ==(other)
|
|
12
|
+
return false unless self.class === other
|
|
13
|
+
|
|
14
|
+
to_h == other.to_h
|
|
15
|
+
end
|
|
16
|
+
|
|
11
17
|
def deconstruct(*)
|
|
12
18
|
if @ok
|
|
13
19
|
[:ok, @value]
|
|
@@ -16,13 +22,14 @@ module L43
|
|
|
16
22
|
end
|
|
17
23
|
end
|
|
18
24
|
|
|
19
|
-
def
|
|
25
|
+
def to_h(*)
|
|
20
26
|
if @ok
|
|
21
27
|
{ok: @value}
|
|
22
28
|
else
|
|
23
29
|
{error: @message}
|
|
24
30
|
end
|
|
25
31
|
end
|
|
32
|
+
alias_method :deconstruct_keys, :to_h
|
|
26
33
|
|
|
27
34
|
def error? = !@ok
|
|
28
35
|
|
data/lib/l43/core/version.rb
CHANGED
data/lib/l43/core.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: l43_core
|
|
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
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-12-
|
|
10
|
+
date: 2025-12-10 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: ostruct
|
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
|
33
33
|
files:
|
|
34
34
|
- lib/l43.rb
|
|
35
35
|
- lib/l43/core.rb
|
|
36
|
+
- lib/l43/core/as_result.rb
|
|
36
37
|
- lib/l43/core/forwarder.rb
|
|
37
38
|
- lib/l43/core/none.rb
|
|
38
39
|
- lib/l43/core/result.rb
|
|
@@ -58,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
58
59
|
- !ruby/object:Gem::Version
|
|
59
60
|
version: '0'
|
|
60
61
|
requirements: []
|
|
61
|
-
rubygems_version:
|
|
62
|
+
rubygems_version: 4.0.1
|
|
62
63
|
specification_version: 4
|
|
63
64
|
summary: Core Functionality for L43 Ruby Tool
|
|
64
65
|
test_files: []
|