errgonomic 0.3.0 → 0.4.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/flake.lock +4 -4
- data/flake.nix +1 -1
- data/gemset.nix +250 -94
- data/lib/errgonomic/option.rb +16 -3
- data/lib/errgonomic/rails/active_record_delegate_optional.rb +22 -0
- data/lib/errgonomic/rails/active_record_optional.rb +99 -0
- data/lib/errgonomic/rails.rb +48 -0
- data/lib/errgonomic/result.rb +37 -2
- data/lib/errgonomic/version.rb +1 -1
- data/lib/errgonomic.rb +9 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ce0ba951582d18b1935b615405df415fd0a4658036e79d533a62114f567ac67
|
|
4
|
+
data.tar.gz: c1384cc807884b08dfa6a391e64d52d6c443fb0799d1d2a05c0652fbe02f9831
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 747b1c025133999635f5c57cf651bf07f5febbc5d0a40193a020817f828d8ef40c6172c5e35a51e3e9fb7888a38c5f530e311a3506a7efd464a1e89485a5db1b
|
|
7
|
+
data.tar.gz: 9197e12c33e9af759acabb3ecd3cceea208a5212e565d6408c534d2ef6c765f6578be8571100a3b76ea8e40afb924e62a366cda91d50bea7ed195ec4f84b5dfe
|
data/flake.lock
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
"nodes": {
|
|
3
3
|
"nixpkgs": {
|
|
4
4
|
"locked": {
|
|
5
|
-
"lastModified":
|
|
6
|
-
"narHash": "sha256-
|
|
5
|
+
"lastModified": 1751741127,
|
|
6
|
+
"narHash": "sha256-t75Shs76NgxjZSgvvZZ9qOmz5zuBE8buUaYD28BMTxg=",
|
|
7
7
|
"owner": "nixos",
|
|
8
8
|
"repo": "nixpkgs",
|
|
9
|
-
"rev": "
|
|
9
|
+
"rev": "29e290002bfff26af1db6f64d070698019460302",
|
|
10
10
|
"type": "github"
|
|
11
11
|
},
|
|
12
12
|
"original": {
|
|
13
13
|
"owner": "nixos",
|
|
14
|
-
"ref": "nixos-
|
|
14
|
+
"ref": "nixos-25.05",
|
|
15
15
|
"repo": "nixpkgs",
|
|
16
16
|
"type": "github"
|
|
17
17
|
}
|
data/flake.nix
CHANGED
data/gemset.nix
CHANGED
|
@@ -1,16 +1,49 @@
|
|
|
1
1
|
{
|
|
2
|
+
activemodel = {
|
|
3
|
+
dependencies = ["activesupport"];
|
|
4
|
+
groups = ["default" "development"];
|
|
5
|
+
platforms = [];
|
|
6
|
+
source = {
|
|
7
|
+
remotes = ["https://rubygems.org"];
|
|
8
|
+
sha256 = "0v35y2jzqlfy1wnrzlzj2cxylhnz09vykaa1l2dnkq7sl5zzpq8a";
|
|
9
|
+
type = "gem";
|
|
10
|
+
};
|
|
11
|
+
version = "8.0.2";
|
|
12
|
+
};
|
|
13
|
+
activerecord = {
|
|
14
|
+
dependencies = ["activemodel" "activesupport" "timeout"];
|
|
15
|
+
groups = ["development"];
|
|
16
|
+
platforms = [];
|
|
17
|
+
source = {
|
|
18
|
+
remotes = ["https://rubygems.org"];
|
|
19
|
+
sha256 = "02nrya34qviawdkssyahb3mg08kqdc461b320a6ikr245jwp0d3r";
|
|
20
|
+
type = "gem";
|
|
21
|
+
};
|
|
22
|
+
version = "8.0.2";
|
|
23
|
+
};
|
|
24
|
+
activesupport = {
|
|
25
|
+
dependencies = ["base64" "benchmark" "bigdecimal" "concurrent-ruby" "connection_pool" "drb" "i18n" "logger" "minitest" "securerandom" "tzinfo" "uri"];
|
|
26
|
+
groups = ["default" "development"];
|
|
27
|
+
platforms = [];
|
|
28
|
+
source = {
|
|
29
|
+
remotes = ["https://rubygems.org"];
|
|
30
|
+
sha256 = "0pm40y64wfc50a9sj87kxvil2102rmpdcbv82zf0r40vlgdwsrc5";
|
|
31
|
+
type = "gem";
|
|
32
|
+
};
|
|
33
|
+
version = "8.0.2";
|
|
34
|
+
};
|
|
2
35
|
ast = {
|
|
3
|
-
groups = ["default"];
|
|
36
|
+
groups = ["default" "development"];
|
|
4
37
|
platforms = [];
|
|
5
38
|
source = {
|
|
6
39
|
remotes = ["https://rubygems.org"];
|
|
7
|
-
sha256 = "
|
|
40
|
+
sha256 = "10yknjyn0728gjn6b5syynvrvrwm66bhssbxq8mkhshxghaiailm";
|
|
8
41
|
type = "gem";
|
|
9
42
|
};
|
|
10
|
-
version = "2.4.
|
|
43
|
+
version = "2.4.3";
|
|
11
44
|
};
|
|
12
45
|
backport = {
|
|
13
|
-
groups = ["default"];
|
|
46
|
+
groups = ["default" "development"];
|
|
14
47
|
platforms = [];
|
|
15
48
|
source = {
|
|
16
49
|
remotes = ["https://rubygems.org"];
|
|
@@ -19,18 +52,38 @@
|
|
|
19
52
|
};
|
|
20
53
|
version = "1.2.0";
|
|
21
54
|
};
|
|
55
|
+
base64 = {
|
|
56
|
+
groups = ["default" "development"];
|
|
57
|
+
platforms = [];
|
|
58
|
+
source = {
|
|
59
|
+
remotes = ["https://rubygems.org"];
|
|
60
|
+
sha256 = "0yx9yn47a8lkfcjmigk79fykxvr80r4m1i35q82sxzynpbm7lcr7";
|
|
61
|
+
type = "gem";
|
|
62
|
+
};
|
|
63
|
+
version = "0.3.0";
|
|
64
|
+
};
|
|
22
65
|
benchmark = {
|
|
23
|
-
groups = ["default"];
|
|
66
|
+
groups = ["default" "development"];
|
|
24
67
|
platforms = [];
|
|
25
68
|
source = {
|
|
26
69
|
remotes = ["https://rubygems.org"];
|
|
27
|
-
sha256 = "
|
|
70
|
+
sha256 = "1kicilpma5l0lwayqjb5577bm0hbjndj2gh150xz09xsgc1l1vyl";
|
|
28
71
|
type = "gem";
|
|
29
72
|
};
|
|
30
|
-
version = "0.4.
|
|
73
|
+
version = "0.4.1";
|
|
74
|
+
};
|
|
75
|
+
bigdecimal = {
|
|
76
|
+
groups = ["default" "development"];
|
|
77
|
+
platforms = [];
|
|
78
|
+
source = {
|
|
79
|
+
remotes = ["https://rubygems.org"];
|
|
80
|
+
sha256 = "1p2szbr4jdvmwaaj2kxlbv1rp0m6ycbgfyp0kjkkkswmniv5y21r";
|
|
81
|
+
type = "gem";
|
|
82
|
+
};
|
|
83
|
+
version = "3.2.2";
|
|
31
84
|
};
|
|
32
85
|
concurrent-ruby = {
|
|
33
|
-
groups = ["default"];
|
|
86
|
+
groups = ["default" "development"];
|
|
34
87
|
platforms = [];
|
|
35
88
|
source = {
|
|
36
89
|
remotes = ["https://rubygems.org"];
|
|
@@ -39,15 +92,35 @@
|
|
|
39
92
|
};
|
|
40
93
|
version = "1.3.5";
|
|
41
94
|
};
|
|
95
|
+
connection_pool = {
|
|
96
|
+
groups = ["default" "development"];
|
|
97
|
+
platforms = [];
|
|
98
|
+
source = {
|
|
99
|
+
remotes = ["https://rubygems.org"];
|
|
100
|
+
sha256 = "0nrhsk7b3sjqbyl1cah6ibf1kvi3v93a7wf4637d355hp614mmyg";
|
|
101
|
+
type = "gem";
|
|
102
|
+
};
|
|
103
|
+
version = "2.5.3";
|
|
104
|
+
};
|
|
42
105
|
diff-lcs = {
|
|
43
|
-
groups = ["default"];
|
|
106
|
+
groups = ["default" "development"];
|
|
107
|
+
platforms = [];
|
|
108
|
+
source = {
|
|
109
|
+
remotes = ["https://rubygems.org"];
|
|
110
|
+
sha256 = "0qlrj2qyysc9avzlr4zs1py3x684hqm61n4czrsk1pyllz5x5q4s";
|
|
111
|
+
type = "gem";
|
|
112
|
+
};
|
|
113
|
+
version = "1.6.2";
|
|
114
|
+
};
|
|
115
|
+
drb = {
|
|
116
|
+
groups = ["default" "development"];
|
|
44
117
|
platforms = [];
|
|
45
118
|
source = {
|
|
46
119
|
remotes = ["https://rubygems.org"];
|
|
47
|
-
sha256 = "
|
|
120
|
+
sha256 = "0wrkl7yiix268s2md1h6wh91311w95ikd8fy8m5gx589npyxc00b";
|
|
48
121
|
type = "gem";
|
|
49
122
|
};
|
|
50
|
-
version = "
|
|
123
|
+
version = "2.2.3";
|
|
51
124
|
};
|
|
52
125
|
errgonomic = {
|
|
53
126
|
dependencies = ["concurrent-ruby"];
|
|
@@ -57,31 +130,42 @@
|
|
|
57
130
|
path = ./.;
|
|
58
131
|
type = "path";
|
|
59
132
|
};
|
|
60
|
-
version = "0.
|
|
133
|
+
version = "0.4.0";
|
|
134
|
+
};
|
|
135
|
+
i18n = {
|
|
136
|
+
dependencies = ["concurrent-ruby"];
|
|
137
|
+
groups = ["default" "development"];
|
|
138
|
+
platforms = [];
|
|
139
|
+
source = {
|
|
140
|
+
remotes = ["https://rubygems.org"];
|
|
141
|
+
sha256 = "03sx3ahz1v5kbqjwxj48msw3maplpp2iyzs22l4jrzrqh4zmgfnf";
|
|
142
|
+
type = "gem";
|
|
143
|
+
};
|
|
144
|
+
version = "1.14.7";
|
|
61
145
|
};
|
|
62
146
|
jaro_winkler = {
|
|
63
|
-
groups = ["default"];
|
|
147
|
+
groups = ["default" "development"];
|
|
64
148
|
platforms = [];
|
|
65
149
|
source = {
|
|
66
150
|
remotes = ["https://rubygems.org"];
|
|
67
|
-
sha256 = "
|
|
151
|
+
sha256 = "14xkw4lb6wwvbcwqkf6ds116sridk9c8yz6y3caw07vzpwdvcmn0";
|
|
68
152
|
type = "gem";
|
|
69
153
|
};
|
|
70
|
-
version = "1.6.
|
|
154
|
+
version = "1.6.1";
|
|
71
155
|
};
|
|
72
156
|
json = {
|
|
73
|
-
groups = ["default"];
|
|
157
|
+
groups = ["default" "development"];
|
|
74
158
|
platforms = [];
|
|
75
159
|
source = {
|
|
76
160
|
remotes = ["https://rubygems.org"];
|
|
77
|
-
sha256 = "
|
|
161
|
+
sha256 = "1x5b8ipv6g0z44wgc45039k04smsyf95h2m5m67mqq35sa5a955s";
|
|
78
162
|
type = "gem";
|
|
79
163
|
};
|
|
80
|
-
version = "2.
|
|
164
|
+
version = "2.12.2";
|
|
81
165
|
};
|
|
82
166
|
kramdown = {
|
|
83
167
|
dependencies = ["rexml"];
|
|
84
|
-
groups = ["default"];
|
|
168
|
+
groups = ["default" "development"];
|
|
85
169
|
platforms = [];
|
|
86
170
|
source = {
|
|
87
171
|
remotes = ["https://rubygems.org"];
|
|
@@ -92,7 +176,7 @@
|
|
|
92
176
|
};
|
|
93
177
|
kramdown-parser-gfm = {
|
|
94
178
|
dependencies = ["kramdown"];
|
|
95
|
-
groups = ["default"];
|
|
179
|
+
groups = ["default" "development"];
|
|
96
180
|
platforms = [];
|
|
97
181
|
source = {
|
|
98
182
|
remotes = ["https://rubygems.org"];
|
|
@@ -102,58 +186,68 @@
|
|
|
102
186
|
version = "1.1.0";
|
|
103
187
|
};
|
|
104
188
|
language_server-protocol = {
|
|
105
|
-
groups = ["default"];
|
|
189
|
+
groups = ["default" "development"];
|
|
106
190
|
platforms = [];
|
|
107
191
|
source = {
|
|
108
192
|
remotes = ["https://rubygems.org"];
|
|
109
|
-
sha256 = "
|
|
193
|
+
sha256 = "1k0311vah76kg5m6zr7wmkwyk5p2f9d9hyckjpn3xgr83ajkj7px";
|
|
110
194
|
type = "gem";
|
|
111
195
|
};
|
|
112
|
-
version = "3.17.0.
|
|
196
|
+
version = "3.17.0.5";
|
|
197
|
+
};
|
|
198
|
+
lint_roller = {
|
|
199
|
+
groups = ["default" "development"];
|
|
200
|
+
platforms = [];
|
|
201
|
+
source = {
|
|
202
|
+
remotes = ["https://rubygems.org"];
|
|
203
|
+
sha256 = "11yc0d84hsnlvx8cpk4cbj6a4dz9pk0r1k29p0n1fz9acddq831c";
|
|
204
|
+
type = "gem";
|
|
205
|
+
};
|
|
206
|
+
version = "1.1.0";
|
|
113
207
|
};
|
|
114
208
|
logger = {
|
|
115
|
-
groups = ["default"];
|
|
209
|
+
groups = ["default" "development"];
|
|
116
210
|
platforms = [];
|
|
117
211
|
source = {
|
|
118
212
|
remotes = ["https://rubygems.org"];
|
|
119
|
-
sha256 = "
|
|
213
|
+
sha256 = "00q2zznygpbls8asz5knjvvj2brr3ghmqxgr83xnrdj4rk3xwvhr";
|
|
120
214
|
type = "gem";
|
|
121
215
|
};
|
|
122
|
-
version = "1.
|
|
216
|
+
version = "1.7.0";
|
|
123
217
|
};
|
|
124
218
|
mini_portile2 = {
|
|
125
|
-
groups = ["default"];
|
|
219
|
+
groups = ["default" "development"];
|
|
126
220
|
platforms = [];
|
|
127
221
|
source = {
|
|
128
222
|
remotes = ["https://rubygems.org"];
|
|
129
|
-
sha256 = "
|
|
223
|
+
sha256 = "12f2830x7pq3kj0v8nz0zjvaw02sv01bqs1zwdrc04704kwcgmqc";
|
|
130
224
|
type = "gem";
|
|
131
225
|
};
|
|
132
|
-
version = "2.8.
|
|
226
|
+
version = "2.8.9";
|
|
133
227
|
};
|
|
134
228
|
minitest = {
|
|
135
|
-
groups = ["
|
|
229
|
+
groups = ["development"];
|
|
136
230
|
platforms = [];
|
|
137
231
|
source = {
|
|
138
232
|
remotes = ["https://rubygems.org"];
|
|
139
|
-
sha256 = "
|
|
233
|
+
sha256 = "0mn7q9yzrwinvfvkyjiz548a4rmcwbmz2fn9nyzh4j1snin6q6rr";
|
|
140
234
|
type = "gem";
|
|
141
235
|
};
|
|
142
|
-
version = "5.25.
|
|
236
|
+
version = "5.25.5";
|
|
143
237
|
};
|
|
144
238
|
nokogiri = {
|
|
145
239
|
dependencies = ["mini_portile2" "racc"];
|
|
146
|
-
groups = ["default"];
|
|
240
|
+
groups = ["default" "development"];
|
|
147
241
|
platforms = [];
|
|
148
242
|
source = {
|
|
149
243
|
remotes = ["https://rubygems.org"];
|
|
150
|
-
sha256 = "
|
|
244
|
+
sha256 = "0rb306hbky6cxfyc8vrwpvl40fdapjvhsk62h08gg9wwbn3n8x4c";
|
|
151
245
|
type = "gem";
|
|
152
246
|
};
|
|
153
|
-
version = "1.18.
|
|
247
|
+
version = "1.18.8";
|
|
154
248
|
};
|
|
155
249
|
observer = {
|
|
156
|
-
groups = ["default"];
|
|
250
|
+
groups = ["default" "development"];
|
|
157
251
|
platforms = [];
|
|
158
252
|
source = {
|
|
159
253
|
remotes = ["https://rubygems.org"];
|
|
@@ -163,38 +257,48 @@
|
|
|
163
257
|
version = "0.1.2";
|
|
164
258
|
};
|
|
165
259
|
ostruct = {
|
|
166
|
-
groups = ["default"];
|
|
260
|
+
groups = ["default" "development"];
|
|
167
261
|
platforms = [];
|
|
168
262
|
source = {
|
|
169
263
|
remotes = ["https://rubygems.org"];
|
|
170
|
-
sha256 = "
|
|
264
|
+
sha256 = "1h6gazp5837xbz1aqvq9x0a5ffpw32nhvknn931a4074k6i04wvd";
|
|
171
265
|
type = "gem";
|
|
172
266
|
};
|
|
173
|
-
version = "0.6.
|
|
267
|
+
version = "0.6.2";
|
|
174
268
|
};
|
|
175
269
|
parallel = {
|
|
176
|
-
groups = ["default"];
|
|
270
|
+
groups = ["default" "development"];
|
|
177
271
|
platforms = [];
|
|
178
272
|
source = {
|
|
179
273
|
remotes = ["https://rubygems.org"];
|
|
180
|
-
sha256 = "
|
|
274
|
+
sha256 = "0c719bfgcszqvk9z47w2p8j2wkz5y35k48ywwas5yxbbh3hm3haa";
|
|
181
275
|
type = "gem";
|
|
182
276
|
};
|
|
183
|
-
version = "1.
|
|
277
|
+
version = "1.27.0";
|
|
184
278
|
};
|
|
185
279
|
parser = {
|
|
186
280
|
dependencies = ["ast" "racc"];
|
|
187
|
-
groups = ["default"];
|
|
281
|
+
groups = ["default" "development"];
|
|
282
|
+
platforms = [];
|
|
283
|
+
source = {
|
|
284
|
+
remotes = ["https://rubygems.org"];
|
|
285
|
+
sha256 = "0i9w8msil4snx5w11ix9b0wf52vjc3r49khy3ddgl1xk890kcxi4";
|
|
286
|
+
type = "gem";
|
|
287
|
+
};
|
|
288
|
+
version = "3.3.8.0";
|
|
289
|
+
};
|
|
290
|
+
prism = {
|
|
291
|
+
groups = ["default" "development"];
|
|
188
292
|
platforms = [];
|
|
189
293
|
source = {
|
|
190
294
|
remotes = ["https://rubygems.org"];
|
|
191
|
-
sha256 = "
|
|
295
|
+
sha256 = "0gkhpdjib9zi9i27vd9djrxiwjia03cijmd6q8yj2q1ix403w3nw";
|
|
192
296
|
type = "gem";
|
|
193
297
|
};
|
|
194
|
-
version = "
|
|
298
|
+
version = "1.4.0";
|
|
195
299
|
};
|
|
196
300
|
racc = {
|
|
197
|
-
groups = ["default"];
|
|
301
|
+
groups = ["default" "development"];
|
|
198
302
|
platforms = [];
|
|
199
303
|
source = {
|
|
200
304
|
remotes = ["https://rubygems.org"];
|
|
@@ -204,7 +308,7 @@
|
|
|
204
308
|
version = "1.8.1";
|
|
205
309
|
};
|
|
206
310
|
rainbow = {
|
|
207
|
-
groups = ["default"];
|
|
311
|
+
groups = ["default" "development"];
|
|
208
312
|
platforms = [];
|
|
209
313
|
source = {
|
|
210
314
|
remotes = ["https://rubygems.org"];
|
|
@@ -214,28 +318,28 @@
|
|
|
214
318
|
version = "3.1.1";
|
|
215
319
|
};
|
|
216
320
|
rake = {
|
|
217
|
-
groups = ["
|
|
321
|
+
groups = ["development"];
|
|
218
322
|
platforms = [];
|
|
219
323
|
source = {
|
|
220
324
|
remotes = ["https://rubygems.org"];
|
|
221
|
-
sha256 = "
|
|
325
|
+
sha256 = "14s4jdcs1a4saam9qmzbsa2bsh85rj9zfxny5z315x3gg0nhkxcn";
|
|
222
326
|
type = "gem";
|
|
223
327
|
};
|
|
224
|
-
version = "13.
|
|
328
|
+
version = "13.3.0";
|
|
225
329
|
};
|
|
226
330
|
rbs = {
|
|
227
331
|
dependencies = ["logger"];
|
|
228
|
-
groups = ["default"];
|
|
332
|
+
groups = ["default" "development"];
|
|
229
333
|
platforms = [];
|
|
230
334
|
source = {
|
|
231
335
|
remotes = ["https://rubygems.org"];
|
|
232
|
-
sha256 = "
|
|
336
|
+
sha256 = "1mx533jn2nv29xc5faw9g5xj9qbdaiwl9wv2byv98bgw6gqwhhlf";
|
|
233
337
|
type = "gem";
|
|
234
338
|
};
|
|
235
|
-
version = "3.
|
|
339
|
+
version = "3.9.4";
|
|
236
340
|
};
|
|
237
341
|
regexp_parser = {
|
|
238
|
-
groups = ["default"];
|
|
342
|
+
groups = ["default" "development"];
|
|
239
343
|
platforms = [];
|
|
240
344
|
source = {
|
|
241
345
|
remotes = ["https://rubygems.org"];
|
|
@@ -246,7 +350,7 @@
|
|
|
246
350
|
};
|
|
247
351
|
reverse_markdown = {
|
|
248
352
|
dependencies = ["nokogiri"];
|
|
249
|
-
groups = ["default"];
|
|
353
|
+
groups = ["default" "development"];
|
|
250
354
|
platforms = [];
|
|
251
355
|
source = {
|
|
252
356
|
remotes = ["https://rubygems.org"];
|
|
@@ -256,7 +360,7 @@
|
|
|
256
360
|
version = "3.0.0";
|
|
257
361
|
};
|
|
258
362
|
rexml = {
|
|
259
|
-
groups = ["default"];
|
|
363
|
+
groups = ["default" "development"];
|
|
260
364
|
platforms = [];
|
|
261
365
|
source = {
|
|
262
366
|
remotes = ["https://rubygems.org"];
|
|
@@ -267,93 +371,93 @@
|
|
|
267
371
|
};
|
|
268
372
|
rspec = {
|
|
269
373
|
dependencies = ["rspec-core" "rspec-expectations" "rspec-mocks"];
|
|
270
|
-
groups = ["
|
|
374
|
+
groups = ["development"];
|
|
271
375
|
platforms = [];
|
|
272
376
|
source = {
|
|
273
377
|
remotes = ["https://rubygems.org"];
|
|
274
|
-
sha256 = "
|
|
378
|
+
sha256 = "0h11wynaki22a40rfq3ahcs4r36jdpz9acbb3m5dkf0mm67sbydr";
|
|
275
379
|
type = "gem";
|
|
276
380
|
};
|
|
277
|
-
version = "3.13.
|
|
381
|
+
version = "3.13.1";
|
|
278
382
|
};
|
|
279
383
|
rspec-core = {
|
|
280
384
|
dependencies = ["rspec-support"];
|
|
281
|
-
groups = ["default"];
|
|
385
|
+
groups = ["default" "development"];
|
|
282
386
|
platforms = [];
|
|
283
387
|
source = {
|
|
284
388
|
remotes = ["https://rubygems.org"];
|
|
285
|
-
sha256 = "
|
|
389
|
+
sha256 = "18sgga9zjrd5579m9rpb78l7yn9a0bjzwz51z5kiq4y6jwl6hgxb";
|
|
286
390
|
type = "gem";
|
|
287
391
|
};
|
|
288
|
-
version = "3.13.
|
|
392
|
+
version = "3.13.5";
|
|
289
393
|
};
|
|
290
394
|
rspec-expectations = {
|
|
291
395
|
dependencies = ["diff-lcs" "rspec-support"];
|
|
292
|
-
groups = ["default"];
|
|
396
|
+
groups = ["default" "development"];
|
|
293
397
|
platforms = [];
|
|
294
398
|
source = {
|
|
295
399
|
remotes = ["https://rubygems.org"];
|
|
296
|
-
sha256 = "
|
|
400
|
+
sha256 = "0dl8npj0jfpy31bxi6syc7jymyd861q277sfr6jawq2hv6hx791k";
|
|
297
401
|
type = "gem";
|
|
298
402
|
};
|
|
299
|
-
version = "3.13.
|
|
403
|
+
version = "3.13.5";
|
|
300
404
|
};
|
|
301
405
|
rspec-mocks = {
|
|
302
406
|
dependencies = ["diff-lcs" "rspec-support"];
|
|
303
|
-
groups = ["default"];
|
|
407
|
+
groups = ["default" "development"];
|
|
304
408
|
platforms = [];
|
|
305
409
|
source = {
|
|
306
410
|
remotes = ["https://rubygems.org"];
|
|
307
|
-
sha256 = "
|
|
411
|
+
sha256 = "10gajm8iscl7gb8q926hyna83bw3fx2zb4sqdzjrznjs51pqlcz4";
|
|
308
412
|
type = "gem";
|
|
309
413
|
};
|
|
310
|
-
version = "3.13.
|
|
414
|
+
version = "3.13.5";
|
|
311
415
|
};
|
|
312
416
|
rspec-support = {
|
|
313
|
-
groups = ["default"];
|
|
417
|
+
groups = ["default" "development"];
|
|
314
418
|
platforms = [];
|
|
315
419
|
source = {
|
|
316
420
|
remotes = ["https://rubygems.org"];
|
|
317
|
-
sha256 = "
|
|
421
|
+
sha256 = "1xx3f4mgr84jz07fifd3r68hm6giqy91hqyzawmi0s59yqa1hjqq";
|
|
318
422
|
type = "gem";
|
|
319
423
|
};
|
|
320
|
-
version = "3.13.
|
|
424
|
+
version = "3.13.4";
|
|
321
425
|
};
|
|
322
426
|
rubocop = {
|
|
323
|
-
dependencies = ["json" "language_server-protocol" "parallel" "parser" "rainbow" "regexp_parser" "rubocop-ast" "ruby-progressbar" "unicode-display_width"];
|
|
324
|
-
groups = ["
|
|
427
|
+
dependencies = ["json" "language_server-protocol" "lint_roller" "parallel" "parser" "rainbow" "regexp_parser" "rubocop-ast" "ruby-progressbar" "unicode-display_width"];
|
|
428
|
+
groups = ["development"];
|
|
325
429
|
platforms = [];
|
|
326
430
|
source = {
|
|
327
431
|
remotes = ["https://rubygems.org"];
|
|
328
|
-
sha256 = "
|
|
432
|
+
sha256 = "1h3b1pl0wawm9w6jad2w333xijjxykvzflc8hzkd6kzb2bwscx4b";
|
|
329
433
|
type = "gem";
|
|
330
434
|
};
|
|
331
|
-
version = "1.
|
|
435
|
+
version = "1.78.0";
|
|
332
436
|
};
|
|
333
437
|
rubocop-ast = {
|
|
334
|
-
dependencies = ["parser"];
|
|
335
|
-
groups = ["default"];
|
|
438
|
+
dependencies = ["parser" "prism"];
|
|
439
|
+
groups = ["default" "development"];
|
|
336
440
|
platforms = [];
|
|
337
441
|
source = {
|
|
338
442
|
remotes = ["https://rubygems.org"];
|
|
339
|
-
sha256 = "
|
|
443
|
+
sha256 = "0gis8w51k5dsmzzlppvwwznqyfd73fa3zcrpl1xihzy1mm4jw14l";
|
|
340
444
|
type = "gem";
|
|
341
445
|
};
|
|
342
|
-
version = "1.
|
|
446
|
+
version = "1.45.1";
|
|
343
447
|
};
|
|
344
448
|
rubocop-yard = {
|
|
345
|
-
dependencies = ["rubocop" "yard"];
|
|
449
|
+
dependencies = ["lint_roller" "rubocop" "yard"];
|
|
346
450
|
groups = ["development"];
|
|
347
451
|
platforms = [];
|
|
348
452
|
source = {
|
|
349
453
|
remotes = ["https://rubygems.org"];
|
|
350
|
-
sha256 = "
|
|
454
|
+
sha256 = "0k1pcbc7hahfchbivf8gn38rxxxv8p30vvnzihlr0sf3rdrzz4ai";
|
|
351
455
|
type = "gem";
|
|
352
456
|
};
|
|
353
|
-
version = "0.
|
|
457
|
+
version = "1.0.0";
|
|
354
458
|
};
|
|
355
459
|
ruby-progressbar = {
|
|
356
|
-
groups = ["default"];
|
|
460
|
+
groups = ["default" "development"];
|
|
357
461
|
platforms = [];
|
|
358
462
|
source = {
|
|
359
463
|
remotes = ["https://rubygems.org"];
|
|
@@ -362,19 +466,40 @@
|
|
|
362
466
|
};
|
|
363
467
|
version = "1.13.0";
|
|
364
468
|
};
|
|
469
|
+
securerandom = {
|
|
470
|
+
groups = ["default" "development"];
|
|
471
|
+
platforms = [];
|
|
472
|
+
source = {
|
|
473
|
+
remotes = ["https://rubygems.org"];
|
|
474
|
+
sha256 = "1cd0iriqfsf1z91qg271sm88xjnfd92b832z49p1nd542ka96lfc";
|
|
475
|
+
type = "gem";
|
|
476
|
+
};
|
|
477
|
+
version = "0.4.1";
|
|
478
|
+
};
|
|
365
479
|
solargraph = {
|
|
366
|
-
dependencies = ["backport" "benchmark" "diff-lcs" "jaro_winkler" "kramdown" "kramdown-parser-gfm" "logger" "observer" "ostruct" "parser" "rbs" "reverse_markdown" "rubocop" "thor" "tilt" "yard" "yard-solargraph"];
|
|
367
|
-
groups = ["
|
|
480
|
+
dependencies = ["backport" "benchmark" "diff-lcs" "jaro_winkler" "kramdown" "kramdown-parser-gfm" "logger" "observer" "ostruct" "parser" "prism" "rbs" "reverse_markdown" "rubocop" "thor" "tilt" "yard" "yard-solargraph"];
|
|
481
|
+
groups = ["development"];
|
|
482
|
+
platforms = [];
|
|
483
|
+
source = {
|
|
484
|
+
remotes = ["https://rubygems.org"];
|
|
485
|
+
sha256 = "1jf8d19j32f3h99acmx9h4g5qaykxzb25fqp028g2bvqvl8k7r2r";
|
|
486
|
+
type = "gem";
|
|
487
|
+
};
|
|
488
|
+
version = "0.56.0";
|
|
489
|
+
};
|
|
490
|
+
sqlite3 = {
|
|
491
|
+
dependencies = ["mini_portile2"];
|
|
492
|
+
groups = ["development"];
|
|
368
493
|
platforms = [];
|
|
369
494
|
source = {
|
|
370
495
|
remotes = ["https://rubygems.org"];
|
|
371
|
-
sha256 = "
|
|
496
|
+
sha256 = "1xf9pm1pvrny4by0sy7s9hlpz2kwij5p9gys77fwd87zqpgpcqs4";
|
|
372
497
|
type = "gem";
|
|
373
498
|
};
|
|
374
|
-
version = "
|
|
499
|
+
version = "2.7.2";
|
|
375
500
|
};
|
|
376
501
|
thor = {
|
|
377
|
-
groups = ["default"];
|
|
502
|
+
groups = ["default" "development"];
|
|
378
503
|
platforms = [];
|
|
379
504
|
source = {
|
|
380
505
|
remotes = ["https://rubygems.org"];
|
|
@@ -384,18 +509,39 @@
|
|
|
384
509
|
version = "1.3.2";
|
|
385
510
|
};
|
|
386
511
|
tilt = {
|
|
387
|
-
groups = ["default"];
|
|
512
|
+
groups = ["default" "development"];
|
|
388
513
|
platforms = [];
|
|
389
514
|
source = {
|
|
390
515
|
remotes = ["https://rubygems.org"];
|
|
391
|
-
sha256 = "
|
|
516
|
+
sha256 = "0w27v04d7rnxjr3f65w1m7xyvr6ch6szjj2v5wv1wz6z5ax9pa9m";
|
|
392
517
|
type = "gem";
|
|
393
518
|
};
|
|
394
|
-
version = "2.6.
|
|
519
|
+
version = "2.6.1";
|
|
520
|
+
};
|
|
521
|
+
timeout = {
|
|
522
|
+
groups = ["default" "development"];
|
|
523
|
+
platforms = [];
|
|
524
|
+
source = {
|
|
525
|
+
remotes = ["https://rubygems.org"];
|
|
526
|
+
sha256 = "03p31w5ghqfsbz5mcjzvwgkw3h9lbvbknqvrdliy8pxmn9wz02cm";
|
|
527
|
+
type = "gem";
|
|
528
|
+
};
|
|
529
|
+
version = "0.4.3";
|
|
530
|
+
};
|
|
531
|
+
tzinfo = {
|
|
532
|
+
dependencies = ["concurrent-ruby"];
|
|
533
|
+
groups = ["default" "development"];
|
|
534
|
+
platforms = [];
|
|
535
|
+
source = {
|
|
536
|
+
remotes = ["https://rubygems.org"];
|
|
537
|
+
sha256 = "16w2g84dzaf3z13gxyzlzbf748kylk5bdgg3n1ipvkvvqy685bwd";
|
|
538
|
+
type = "gem";
|
|
539
|
+
};
|
|
540
|
+
version = "2.0.6";
|
|
395
541
|
};
|
|
396
542
|
unicode-display_width = {
|
|
397
543
|
dependencies = ["unicode-emoji"];
|
|
398
|
-
groups = ["default"];
|
|
544
|
+
groups = ["default" "development"];
|
|
399
545
|
platforms = [];
|
|
400
546
|
source = {
|
|
401
547
|
remotes = ["https://rubygems.org"];
|
|
@@ -405,7 +551,7 @@
|
|
|
405
551
|
version = "3.1.4";
|
|
406
552
|
};
|
|
407
553
|
unicode-emoji = {
|
|
408
|
-
groups = ["default"];
|
|
554
|
+
groups = ["default" "development"];
|
|
409
555
|
platforms = [];
|
|
410
556
|
source = {
|
|
411
557
|
remotes = ["https://rubygems.org"];
|
|
@@ -414,6 +560,16 @@
|
|
|
414
560
|
};
|
|
415
561
|
version = "4.0.4";
|
|
416
562
|
};
|
|
563
|
+
uri = {
|
|
564
|
+
groups = ["default" "development"];
|
|
565
|
+
platforms = [];
|
|
566
|
+
source = {
|
|
567
|
+
remotes = ["https://rubygems.org"];
|
|
568
|
+
sha256 = "04bhfvc25b07jaiaf62yrach7khhr5jlr5bx6nygg8pf11329wp9";
|
|
569
|
+
type = "gem";
|
|
570
|
+
};
|
|
571
|
+
version = "1.0.3";
|
|
572
|
+
};
|
|
417
573
|
yard = {
|
|
418
574
|
groups = ["development"];
|
|
419
575
|
platforms = [];
|
|
@@ -437,7 +593,7 @@
|
|
|
437
593
|
};
|
|
438
594
|
yard-solargraph = {
|
|
439
595
|
dependencies = ["yard"];
|
|
440
|
-
groups = ["default"];
|
|
596
|
+
groups = ["default" "development"];
|
|
441
597
|
platforms = [];
|
|
442
598
|
source = {
|
|
443
599
|
remotes = ["https://rubygems.org"];
|
data/lib/errgonomic/option.rb
CHANGED
|
@@ -5,6 +5,10 @@ module Errgonomic
|
|
|
5
5
|
# The base class for all options. Some and None are subclasses.
|
|
6
6
|
#
|
|
7
7
|
class Any
|
|
8
|
+
# def method_missing(_name, *_args)
|
|
9
|
+
# raise 'do it right noob'
|
|
10
|
+
# end
|
|
11
|
+
|
|
8
12
|
# An option of the same type with an equal inner value is equal.
|
|
9
13
|
#
|
|
10
14
|
# Because we're going to monkey patch this into other libraries Rails, we
|
|
@@ -98,7 +102,7 @@ module Errgonomic
|
|
|
98
102
|
# message
|
|
99
103
|
# @example
|
|
100
104
|
# Some(1).expect!("msg") # => 1
|
|
101
|
-
# None().expect!("
|
|
105
|
+
# None().expect!("here's why this failed") # => raise Errgonomic::ExpectError, "here's why this failed"
|
|
102
106
|
def expect!(msg)
|
|
103
107
|
raise Errgonomic::ExpectError, msg if none?
|
|
104
108
|
|
|
@@ -115,6 +119,16 @@ module Errgonomic
|
|
|
115
119
|
value
|
|
116
120
|
end
|
|
117
121
|
|
|
122
|
+
# # returns the inner value if present, else returns the default value
|
|
123
|
+
# # @example
|
|
124
|
+
# # Some(1).unwrap_or(2) # => 1
|
|
125
|
+
# # None().unwrap_or(2) # => 2
|
|
126
|
+
# def unwrap_or_default
|
|
127
|
+
# self.class.respond_to?(:default) or raise
|
|
128
|
+
# return self.class.default if none?
|
|
129
|
+
# value
|
|
130
|
+
# end
|
|
131
|
+
|
|
118
132
|
# returns the inner value if present, else returns the result of the
|
|
119
133
|
# provided block
|
|
120
134
|
# @example
|
|
@@ -302,6 +316,7 @@ module Errgonomic
|
|
|
302
316
|
# Some(2).zip_with(Some(3)) { |a, b| a + b } # => Some(5)
|
|
303
317
|
def zip_with(other, &block)
|
|
304
318
|
return None() unless some? && other.some?
|
|
319
|
+
|
|
305
320
|
other = block.call(value, other.value)
|
|
306
321
|
Some(other)
|
|
307
322
|
end
|
|
@@ -314,8 +329,6 @@ module Errgonomic
|
|
|
314
329
|
# take
|
|
315
330
|
# take_if
|
|
316
331
|
# replace
|
|
317
|
-
# zip
|
|
318
|
-
# zip_with
|
|
319
332
|
end
|
|
320
333
|
|
|
321
334
|
# Represent a value
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Errgonomic
|
|
2
|
+
module Rails
|
|
3
|
+
module ActiveRecordDelegateOptional
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
class_methods do
|
|
7
|
+
def delegate_optional(*methods, to: nil, prefix: nil, private: nil)
|
|
8
|
+
return if to.nil?
|
|
9
|
+
|
|
10
|
+
methods.each do |method_name|
|
|
11
|
+
prefixed_method_name = prefix == true ? "#{to}_#{method_name}" : method_name
|
|
12
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
|
13
|
+
def #{prefixed_method_name}
|
|
14
|
+
#{to}.map { |obj| obj.send(:#{method_name}) }
|
|
15
|
+
end
|
|
16
|
+
RUBY
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Errgonomic
|
|
4
|
+
module Rails
|
|
5
|
+
# Concern to make ActiveRecord optional attributes and associations return an Option.
|
|
6
|
+
#
|
|
7
|
+
module ActiveRecordOptional
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
|
|
10
|
+
included do
|
|
11
|
+
# ::Rails.logger.debug('ActiveRecordOptional')
|
|
12
|
+
optional_associations = reflect_on_all_associations(:belongs_to)
|
|
13
|
+
.select { |r| r.options[:optional] }
|
|
14
|
+
.map(&:name)
|
|
15
|
+
optional_attributes = column_names
|
|
16
|
+
.select { |n| column_for_attribute(n).null }
|
|
17
|
+
@errgonomic_optionals = (optional_attributes + optional_associations)
|
|
18
|
+
@errgonomic_optionals.each do |name|
|
|
19
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
|
20
|
+
def #{name}
|
|
21
|
+
raise "stack too deep" if caller.length > 1024
|
|
22
|
+
val = super
|
|
23
|
+
val.nil? ? Errgonomic::Option::None.new : Errgonomic::Option::Some.new(val)
|
|
24
|
+
end
|
|
25
|
+
RUBY
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class_methods do
|
|
30
|
+
def errgonomic_optionals
|
|
31
|
+
@errgonomic_optionals
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# do we need this since we alias present below?
|
|
39
|
+
class SomeValidator < ActiveModel::EachValidator
|
|
40
|
+
def validate_each(record, attribute, value)
|
|
41
|
+
record.errors.add(attribute, 'is invalid') unless value.some?
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
module Errgonomic
|
|
46
|
+
module Option
|
|
47
|
+
class Any
|
|
48
|
+
alias some? present?
|
|
49
|
+
alias none? blank?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class Some
|
|
53
|
+
delegate :marked_for_destruction?, to: :value
|
|
54
|
+
delegate :persisted?, to: :value
|
|
55
|
+
delegate :touch_later, to: :value
|
|
56
|
+
|
|
57
|
+
def to_s
|
|
58
|
+
raise "Attempted to convert Some to String, please use Option API to safely work with internal value -- #{value}"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
class None
|
|
63
|
+
def nil?
|
|
64
|
+
true
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def to_s
|
|
68
|
+
raise 'Cannot convert None to String - please use Option API to safely work with internal value'
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
module ActiveRecordOptionShim
|
|
75
|
+
def type_cast(value)
|
|
76
|
+
case value
|
|
77
|
+
when Errgonomic::Option::Some
|
|
78
|
+
super(value.unwrap!)
|
|
79
|
+
when Errgonomic::Option::None
|
|
80
|
+
super(nil)
|
|
81
|
+
else
|
|
82
|
+
super
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
ActiveRecord::ConnectionAdapters::Quoting.prepend(ActiveRecordOptionShim)
|
|
88
|
+
|
|
89
|
+
class NilClass
|
|
90
|
+
def to_option
|
|
91
|
+
None()
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class Object
|
|
96
|
+
def to_option
|
|
97
|
+
Some(self)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require_relative 'option'
|
|
2
|
+
require_relative 'rails/active_record_optional'
|
|
3
|
+
require_relative 'rails/active_record_delegate_optional'
|
|
4
|
+
|
|
5
|
+
module Errgonomic
|
|
6
|
+
# Slightly more convenient access to the setup functions:
|
|
7
|
+
# Errgonomic::Rails.setup_before and Errgonomic::Rails.setup_after
|
|
8
|
+
module Rails
|
|
9
|
+
# We provide helper class methods, like `delegate_optional`,
|
|
10
|
+
# which need to be included into ActiveRecord::Base before any models are
|
|
11
|
+
# evaluated.
|
|
12
|
+
def self.setup_before
|
|
13
|
+
ActiveRecord::Base.include(Errgonomic::Rails::ActiveRecordDelegateOptional)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Wrapping optional associations requires that we include the module after
|
|
17
|
+
# the class is first evaluated, so that it can define its associations for
|
|
18
|
+
# later reflection.
|
|
19
|
+
def self.setup_after
|
|
20
|
+
Zeitwerk::Loader.eager_load_all
|
|
21
|
+
setupable = defined?(ApplicationRecord) ? ApplicationRecord : ActiveRecord::Base
|
|
22
|
+
setupable.descendants.each do |model|
|
|
23
|
+
next unless begin
|
|
24
|
+
model.table_exists?
|
|
25
|
+
rescue StandardError
|
|
26
|
+
false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
model.include Errgonomic::Rails::ActiveRecordOptional
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Hook into Rails with a Railtie
|
|
35
|
+
class Railtie < ::Rails::Railtie
|
|
36
|
+
initializer 'errgonomic.setup_before' do
|
|
37
|
+
Errgonomic::Rails.setup_before
|
|
38
|
+
end
|
|
39
|
+
config.after_initialize do
|
|
40
|
+
ActiveSupport.on_load(:after_initialize) do
|
|
41
|
+
Errgonomic::Rails.setup_after
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
config.to_prepare do
|
|
45
|
+
Errgonomic::Rails.setup_after
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/errgonomic/result.rb
CHANGED
|
@@ -77,9 +77,9 @@ module Errgonomic
|
|
|
77
77
|
#
|
|
78
78
|
# @example
|
|
79
79
|
# Ok(1).unwrap! # => 1
|
|
80
|
-
# Err(:c).unwrap! # => raise Errgonomic::UnwrapError
|
|
80
|
+
# Err(:c).unwrap! # => raise Errgonomic::UnwrapError.new("value is an Err", :c)
|
|
81
81
|
def unwrap!
|
|
82
|
-
raise Errgonomic::UnwrapError
|
|
82
|
+
raise Errgonomic::UnwrapError.new('value is an Err', @value) unless ok?
|
|
83
83
|
|
|
84
84
|
@value
|
|
85
85
|
end
|
|
@@ -175,6 +175,8 @@ module Errgonomic
|
|
|
175
175
|
# Sorry about that, hopefully it helps your tests. Better than ambiguous
|
|
176
176
|
# downstream "undefined method" errors, probably.
|
|
177
177
|
#
|
|
178
|
+
# TODO yield the Err
|
|
179
|
+
#
|
|
178
180
|
# @param block [Proc]
|
|
179
181
|
#
|
|
180
182
|
# @example
|
|
@@ -219,6 +221,39 @@ module Errgonomic
|
|
|
219
221
|
|
|
220
222
|
block.call(self)
|
|
221
223
|
end
|
|
224
|
+
|
|
225
|
+
# Calls the function with the inner error value, if Err, but returns the
|
|
226
|
+
# original Result.
|
|
227
|
+
#
|
|
228
|
+
# @example
|
|
229
|
+
# tapped = false
|
|
230
|
+
# Ok(1).tap_err { |err| tapped = err } # => Ok(1)
|
|
231
|
+
# tapped # => false
|
|
232
|
+
# Err(:nope).tap_err { |err| tapped = err } # => Err(:nope)
|
|
233
|
+
# tapped # => :nope
|
|
234
|
+
def tap_err(&block)
|
|
235
|
+
block.call(value) if err?
|
|
236
|
+
self
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# Calls the function with the inner ok value, if Ok, while returning the
|
|
240
|
+
# original Result.
|
|
241
|
+
def tap_ok(&block)
|
|
242
|
+
block.call(value) if ok?
|
|
243
|
+
self
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# Map the Ok(a) to an Ok(b), preserving the Err
|
|
247
|
+
#
|
|
248
|
+
# @example
|
|
249
|
+
# Err(:broken).map { |_val| :nominal } # => Err(:broken)
|
|
250
|
+
# Ok(:plausible).map { |_val| :success } # => Ok(:success)
|
|
251
|
+
def map(&block)
|
|
252
|
+
return self if err?
|
|
253
|
+
|
|
254
|
+
@value = block.call(value)
|
|
255
|
+
self
|
|
256
|
+
end
|
|
222
257
|
end
|
|
223
258
|
|
|
224
259
|
# The Ok variant.
|
data/lib/errgonomic/version.rb
CHANGED
data/lib/errgonomic.rb
CHANGED
|
@@ -12,6 +12,9 @@ require_relative 'errgonomic/type'
|
|
|
12
12
|
require_relative 'errgonomic/option'
|
|
13
13
|
require_relative 'errgonomic/result'
|
|
14
14
|
|
|
15
|
+
# Rails fu
|
|
16
|
+
require_relative 'errgonomic/rails' if defined?(Rails::Railtie)
|
|
17
|
+
|
|
15
18
|
# Errgonomic adds opinionated abstractions to handle errors in a way that blends
|
|
16
19
|
# Rust and Ruby ergonomics. This library leans on Rails conventions for some
|
|
17
20
|
# presence-related methods; when in doubt, make those feel like Rails. It also
|
|
@@ -24,7 +27,12 @@ module Errgonomic
|
|
|
24
27
|
|
|
25
28
|
class TypeMismatchError < Error; end
|
|
26
29
|
|
|
27
|
-
class UnwrapError < Error
|
|
30
|
+
class UnwrapError < Error
|
|
31
|
+
def initialize(msg, value)
|
|
32
|
+
super(msg)
|
|
33
|
+
@value = value
|
|
34
|
+
end
|
|
35
|
+
end
|
|
28
36
|
|
|
29
37
|
class ExpectError < Error; end
|
|
30
38
|
|
metadata
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: errgonomic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Zadrozny
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
10
|
date: 1980-01-01 00:00:00.000000000 Z
|
|
@@ -78,6 +77,9 @@ files:
|
|
|
78
77
|
- lib/errgonomic/core_ext/blank.rb
|
|
79
78
|
- lib/errgonomic/option.rb
|
|
80
79
|
- lib/errgonomic/presence.rb
|
|
80
|
+
- lib/errgonomic/rails.rb
|
|
81
|
+
- lib/errgonomic/rails/active_record_delegate_optional.rb
|
|
82
|
+
- lib/errgonomic/rails/active_record_optional.rb
|
|
81
83
|
- lib/errgonomic/result.rb
|
|
82
84
|
- lib/errgonomic/type.rb
|
|
83
85
|
- lib/errgonomic/version.rb
|
|
@@ -88,7 +90,6 @@ licenses:
|
|
|
88
90
|
metadata:
|
|
89
91
|
homepage_uri: https://omc.io/
|
|
90
92
|
source_code_uri: https://github.com/omc/errgonomic
|
|
91
|
-
post_install_message:
|
|
92
93
|
rdoc_options: []
|
|
93
94
|
require_paths:
|
|
94
95
|
- lib
|
|
@@ -103,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
103
104
|
- !ruby/object:Gem::Version
|
|
104
105
|
version: '0'
|
|
105
106
|
requirements: []
|
|
106
|
-
rubygems_version: 3.
|
|
107
|
-
signing_key:
|
|
107
|
+
rubygems_version: 3.6.6
|
|
108
108
|
specification_version: 4
|
|
109
109
|
summary: Opinionated, ergonomic error handling for Ruby, inspired by Rails and Rust.
|
|
110
110
|
test_files: []
|