bcdd-result 0.9.0 → 0.10.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.
data/sig/bcdd/result.rbs CHANGED
@@ -1,16 +1,12 @@
1
- module BCDD
2
- class Result
3
- VERSION: String
4
- end
5
- end
6
-
7
1
  class BCDD::Result
8
2
  private attr_accessor unknown: bool
3
+ private attr_writer transitions: Hash[Symbol, untyped]
9
4
  private attr_reader type_checker: BCDD::Result::Contract::TypeChecker
10
5
 
11
6
  attr_reader data: BCDD::Result::Data
12
7
  attr_reader subject: untyped
13
8
  attr_reader halted: bool
9
+ attr_reader transitions: Hash[Symbol, untyped]
14
10
 
15
11
  def self.config: -> BCDD::Result::Config
16
12
  def self.configuration: { (BCDD::Result::Config) -> void } -> BCDD::Result::Config
@@ -55,7 +51,10 @@ class BCDD::Result
55
51
 
56
52
  def kind: -> Symbol
57
53
  def known: (Proc) -> untyped
58
- def call_subject_method: (Symbol, untyped) -> BCDD::Result
54
+ def call_and_then_subject_method: (Symbol, untyped) -> BCDD::Result
55
+ def call_and_then_subject_method!: (untyped, untyped) -> BCDD::Result
56
+ def call_and_then_block: (untyped) -> BCDD::Result
57
+ def call_and_then_block!: (untyped) -> BCDD::Result
59
58
  def ensure_result_object: (untyped, origin: Symbol) -> BCDD::Result
60
59
  end
61
60
 
@@ -79,7 +78,6 @@ class BCDD::Result
79
78
  def self.Failure: (Symbol type, ?untyped value) -> BCDD::Result::Failure
80
79
  end
81
80
 
82
-
83
81
  class BCDD::Result
84
82
  class Failure < BCDD::Result
85
83
  module Methods
@@ -99,511 +97,3 @@ class BCDD::Result
99
97
 
100
98
  def self.Success: (Symbol type, ?untyped value) -> BCDD::Result::Success
101
99
  end
102
-
103
- class BCDD::Result
104
- module Mixin
105
- module Factory
106
- def self.module!: -> Module
107
- end
108
-
109
- module Methods
110
- def Success: (Symbol type, ?untyped value) -> BCDD::Result::Success
111
-
112
- def Failure: (Symbol type, ?untyped value) -> BCDD::Result::Failure
113
-
114
- private
115
-
116
- def _ResultAs: (singleton(BCDD::Result), Symbol, untyped, ?halted: bool) -> untyped
117
- end
118
-
119
- module Addons
120
- module Continuable
121
- include BCDD::Result::Mixin::Methods
122
-
123
- private
124
-
125
- def Continue: (untyped) -> BCDD::Result::Success
126
- end
127
-
128
- OPTIONS: Hash[Symbol, Module]
129
-
130
- def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
131
- end
132
- end
133
-
134
- def self.mixin: (?config: Hash[Symbol, Hash[Symbol, bool]]) -> Module
135
-
136
- def self.mixin_module: -> singleton(BCDD::Result::Mixin)
137
-
138
- def self.result_factory: -> singleton(BCDD::Result)
139
- end
140
-
141
- class BCDD::Result
142
- class Data
143
- attr_reader kind: Symbol
144
- attr_reader type: Symbol
145
- attr_reader value: untyped
146
- attr_reader to_h: Hash[Symbol, untyped]
147
- attr_reader to_a: [Symbol, Symbol, untyped]
148
-
149
- def initialize: (Symbol, Symbol, untyped) -> void
150
-
151
- def inspect: -> String
152
-
153
- alias to_ary to_a
154
- alias to_hash to_h
155
- end
156
- end
157
-
158
- class BCDD::Result
159
- class Error < StandardError
160
- def self.build: (**untyped) -> BCDD::Result::Error
161
-
162
- class NotImplemented < BCDD::Result::Error
163
- end
164
-
165
- class MissingTypeArgument < BCDD::Result::Error
166
- end
167
-
168
- class UnexpectedOutcome < BCDD::Result::Error
169
- def self.build: (outcome: untyped, origin: Symbol, ?expected: String)
170
- -> BCDD::Result::Error::UnexpectedOutcome
171
- end
172
-
173
- class InvalidResultSubject < BCDD::Result::Error
174
- def self.build: (given_result: BCDD::Result, expected_subject: untyped)
175
- -> BCDD::Result::Error::InvalidResultSubject
176
- end
177
-
178
- class InvalidSubjectMethodArity < BCDD::Result::Error
179
- def self.build: (subject: untyped, method: Method, max_arity: Integer)
180
- -> BCDD::Result::Error::InvalidSubjectMethodArity
181
- end
182
-
183
- class UnhandledTypes < BCDD::Result::Error
184
- def self.build: (types: Set[Symbol])
185
- -> BCDD::Result::Error::UnhandledTypes
186
- end
187
- end
188
- end
189
-
190
- class BCDD::Result
191
- class Handler
192
- UNDEFINED: Object
193
-
194
- def initialize: (
195
- BCDD::Result,
196
- type_checker: BCDD::Result::Contract::TypeChecker
197
- ) -> void
198
-
199
- def []: (*Symbol) { (untyped, Symbol) -> void } -> untyped
200
- def failure: (*Symbol) { (untyped, Symbol) -> void } -> untyped
201
- def success: (*Symbol) { (untyped, Symbol) -> void } -> untyped
202
- def unknown: () { (untyped, Symbol) -> void } -> untyped
203
-
204
- alias type []
205
-
206
- private
207
-
208
- attr_reader result: BCDD::Result
209
- attr_reader allowed_types: BCDD::Result::Handler::AllowedTypes
210
-
211
- def outcome?: -> bool
212
- def outcome=: (Proc) -> void
213
- def outcome: -> untyped
214
- end
215
- end
216
-
217
- class BCDD::Result::Handler
218
- class AllowedTypes
219
- attr_reader unchecked: Set[Symbol]
220
- attr_reader type_checker: BCDD::Result::Contract::TypeChecker
221
-
222
- def initialize: (
223
- BCDD::Result::Contract::TypeChecker
224
- ) -> void
225
-
226
- def allow?: (Array[Symbol]) -> bool
227
- def allow_success?: (Array[Symbol]) -> bool
228
- def allow_failure?: (Array[Symbol]) -> bool
229
-
230
- def all_checked?: -> bool
231
-
232
- private
233
-
234
- def check!: (Array[Symbol], bool) -> bool
235
- end
236
- end
237
-
238
- module BCDD::Result::Contract
239
- NONE: BCDD::Result::Contract::Evaluator
240
-
241
- def self.evaluate: (
242
- BCDD::Result::Data,
243
- BCDD::Result::Contract::Evaluator
244
- ) -> BCDD::Result::Contract::TypeChecker
245
-
246
- ToEnsure: ^(Hash[Symbol, untyped] | Array[Symbol], Hash[Symbol, Hash[Symbol, bool]])
247
- -> BCDD::Result::Contract::Interface
248
-
249
- def self.new: (
250
- success: Hash[Symbol, untyped] | Array[Symbol],
251
- failure: Hash[Symbol, untyped] | Array[Symbol],
252
- config: Hash[Symbol, Hash[Symbol, bool]]
253
- ) -> BCDD::Result::Contract::Evaluator
254
- end
255
-
256
- module BCDD::Result::Contract
257
- class TypeChecker
258
- attr_reader result_type: Symbol
259
- attr_reader expectations: BCDD::Result::Contract::Evaluator
260
-
261
- def initialize: (
262
- Symbol,
263
- expectations: BCDD::Result::Contract::Evaluator
264
- ) -> void
265
-
266
- def allow?: (Array[Symbol]) -> bool
267
- def allow_success?: (Array[Symbol]) -> bool
268
- def allow_failure?: (Array[Symbol]) -> bool
269
-
270
- private
271
-
272
- def validate: (
273
- Array[Symbol],
274
- expected: BCDD::Result::Contract::Interface,
275
- allow_empty: bool
276
- ) -> bool
277
- end
278
- end
279
-
280
- class BCDD::Result::Contract::Error < BCDD::Result::Error
281
- class UnexpectedType < BCDD::Result::Contract::Error
282
- def self.build: (type: Symbol, allowed_types: Set[Symbol])
283
- -> BCDD::Result::Contract::Error::UnexpectedType
284
- end
285
-
286
- class UnexpectedValue < BCDD::Result::Contract::Error
287
- def self.build: (type: Symbol, value: untyped, ?cause: Exception)
288
- -> BCDD::Result::Contract::Error::UnexpectedValue
289
- end
290
- end
291
-
292
- module BCDD::Result::Contract
293
- module Interface
294
- def ==: (BCDD::Result::Contract::Interface) -> bool
295
-
296
- def allowed_types: -> Set[Symbol]
297
-
298
- def type?: (Symbol) -> bool
299
-
300
- def type!: (Symbol) -> Symbol
301
-
302
- def type_and_value!: (BCDD::Result::Data) -> void
303
-
304
- def !=: (untyped) -> bool
305
- end
306
- end
307
-
308
- module BCDD::Result::Contract
309
- module Disabled
310
- extend Interface
311
-
312
- EMPTY_SET: Set[Symbol]
313
- end
314
- end
315
-
316
- module BCDD::Result::Contract
317
- class ForTypes
318
- include Interface
319
-
320
- def initialize: (Array[Symbol]) -> void
321
- end
322
- end
323
-
324
- module BCDD::Result::Contract
325
- class ForTypesAndValues
326
- include Interface
327
-
328
- def initialize: (
329
- Hash[Symbol, untyped],
330
- Hash[Symbol, Hash[Symbol, bool]]
331
- ) -> void
332
-
333
- private
334
-
335
- def nil_as_valid_value_checking?: -> bool
336
- end
337
- end
338
-
339
- module BCDD::Result::Contract
340
- class Evaluator
341
- include Interface
342
-
343
- attr_reader allowed_types: Set[Symbol]
344
- attr_reader success: BCDD::Result::Contract::Interface
345
- attr_reader failure: BCDD::Result::Contract::Interface
346
-
347
- def initialize: (
348
- BCDD::Result::Contract::Interface,
349
- BCDD::Result::Contract::Interface
350
- ) -> void
351
-
352
- private
353
-
354
- def for: (BCDD::Result::Data) -> BCDD::Result::Contract::Interface
355
- end
356
- end
357
-
358
- class BCDD::Result::Expectations
359
- def self.mixin: (
360
- ?config: Hash[Symbol, Hash[Symbol, bool]],
361
- ?success: Hash[Symbol, untyped] | Array[Symbol],
362
- ?failure: Hash[Symbol, untyped] | Array[Symbol]
363
- ) -> Module
364
-
365
- def self.mixin!: (
366
- ?config: Hash[Symbol, Hash[Symbol, bool]],
367
- ?success: Hash[Symbol, untyped] | Array[Symbol],
368
- ?failure: Hash[Symbol, untyped] | Array[Symbol]
369
- ) -> Module
370
-
371
- def self.mixin_module: -> singleton(BCDD::Result::Expectations::Mixin)
372
-
373
- def self.result_factory_without_expectations: -> singleton(BCDD::Result)
374
-
375
- def self.new: (
376
- ?subject: untyped,
377
- ?contract: BCDD::Result::Contract::Evaluator,
378
- ?halted: bool,
379
- **untyped
380
- ) -> (BCDD::Result::Expectations | untyped)
381
-
382
- def initialize: (
383
- ?subject: untyped,
384
- ?contract: BCDD::Result::Contract::Evaluator,
385
- ?halted: bool,
386
- **untyped
387
- ) -> void
388
-
389
- def Success: (Symbol, ?untyped) -> BCDD::Result::Success
390
- def Failure: (Symbol, ?untyped) -> BCDD::Result::Failure
391
-
392
- def with: (subject: untyped) -> BCDD::Result::Expectations
393
-
394
- private
395
-
396
- def _ResultAs: (singleton(BCDD::Result), Symbol, untyped) -> untyped
397
-
398
- attr_reader subject: untyped
399
- attr_reader contract: BCDD::Result::Contract::Evaluator
400
- attr_reader halted: bool
401
- end
402
-
403
- module BCDD::Result::Expectations::Mixin
404
- module Factory
405
- def self.module!: -> Module
406
- end
407
-
408
- module Methods
409
- BASE: String
410
- FACTORY: String
411
-
412
- def self.to_eval: (Hash[Symbol, untyped]) -> String
413
- end
414
-
415
- module Addons
416
- module Continuable
417
- private def Continue: (untyped) -> BCDD::Result::Success
418
- end
419
-
420
- OPTIONS: Hash[Symbol, Module]
421
-
422
- def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
423
- end
424
- end
425
-
426
- class BCDD::Result::Context < BCDD::Result
427
- EXPECTED_OUTCOME: String
428
-
429
- SubjectMethodArity: ^(Method) -> Integer
430
-
431
- attr_reader acc: Hash[Symbol, untyped]
432
-
433
- def initialize: (
434
- type: Symbol,
435
- value: untyped,
436
- ?subject: untyped,
437
- ?expectations: BCDD::Result::Contract::Evaluator,
438
- ?halted: bool
439
- ) -> void
440
-
441
- def and_then: (?Symbol, **untyped) ?{ (Hash[Symbol, untyped]) -> untyped } -> BCDD::Result::Context
442
-
443
- private
444
-
445
- def call_subject_method: (Symbol, Hash[Symbol, untyped]) -> BCDD::Result::Context
446
- def ensure_result_object: (untyped, origin: Symbol) -> BCDD::Result::Context
447
-
448
- def raise_unexpected_outcome_error: (BCDD::Result::Context | untyped, Symbol) -> void
449
- end
450
-
451
- class BCDD::Result::Context
452
- class Success < BCDD::Result::Context
453
- include BCDD::Result::Success::Methods
454
-
455
- def and_expose: (Symbol, Array[Symbol]) -> BCDD::Result::Context::Success
456
- end
457
-
458
- def self.Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
459
- end
460
-
461
- class BCDD::Result::Context
462
- class Failure < BCDD::Result::Context
463
- include BCDD::Result::Failure::Methods
464
-
465
- def and_expose: (Symbol, Array[Symbol]) -> BCDD::Result::Context::Failure
466
- end
467
-
468
- def self.Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
469
- end
470
-
471
- class BCDD::Result::Context
472
- module Mixin
473
- Factory: singleton(BCDD::Result::Mixin::Factory)
474
-
475
- module Methods
476
- def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
477
-
478
- def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
479
-
480
- private
481
-
482
- def _ResultAs: (singleton(BCDD::Result::Context), Symbol, untyped, ?halted: bool) -> untyped
483
- end
484
-
485
- module Addons
486
- module Continuable
487
- include BCDD::Result::Context::Mixin::Methods
488
-
489
- private
490
-
491
- def Continue: (**untyped) -> BCDD::Result::Context::Success
492
- end
493
-
494
- OPTIONS: Hash[Symbol, Module]
495
-
496
- def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
497
- end
498
- end
499
-
500
- def self.mixin_module: -> singleton(BCDD::Result::Context::Mixin)
501
-
502
- def self.result_factory: -> singleton(BCDD::Result::Context)
503
- end
504
-
505
- class BCDD::Result::Context::Expectations < BCDD::Result::Expectations
506
- def self.mixin_module: -> singleton(BCDD::Result::Context::Expectations::Mixin)
507
-
508
- def self.result_factory_without_expectations: -> singleton(BCDD::Result)
509
-
510
- def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
511
- def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
512
- end
513
-
514
- module BCDD::Result::Context::Expectations::Mixin
515
- Methods: singleton(BCDD::Result::Expectations::Mixin::Methods)
516
- Factory: singleton(BCDD::Result::Expectations::Mixin::Factory)
517
-
518
- module Addons
519
- module Continuable
520
- private def Continue: (**untyped) -> BCDD::Result::Context::Success
521
- end
522
-
523
- OPTIONS: Hash[Symbol, Module]
524
-
525
- def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
526
- end
527
- end
528
-
529
- class BCDD::Result::Config
530
- include Singleton
531
-
532
- ADDON: Hash[Symbol, Hash[Symbol, untyped]]
533
- FEATURE: Hash[Symbol, Hash[Symbol, untyped]]
534
- PATTERN_MATCHING: Hash[Symbol, Hash[Symbol, untyped]]
535
-
536
- attr_reader addon: BCDD::Result::Config::Switcher
537
- attr_reader feature: BCDD::Result::Config::Switcher
538
- attr_reader constant_alias: BCDD::Result::Config::Switcher
539
- attr_reader pattern_matching: BCDD::Result::Config::Switcher
540
-
541
- def self.instance: -> BCDD::Result::Config
542
-
543
- def initialize: -> void
544
-
545
- def freeze: -> BCDD::Result::Config
546
- def options: -> Hash[Symbol, BCDD::Result::Config::Switcher]
547
- def to_h: -> Hash[Symbol, Hash[Symbol | String, bool]]
548
- end
549
-
550
- class BCDD::Result::Config::Switcher
551
- private attr_reader _affects: Hash[Symbol | String, Array[String]]
552
- private attr_reader _options: Hash[Symbol | String, bool]
553
- private attr_reader listener: Proc
554
-
555
- def initialize: (
556
- options: Hash[Symbol | String, Hash[Symbol, untyped]],
557
- ?listener: Proc
558
- ) -> void
559
-
560
- def freeze: -> BCDD::Result::Config::Switcher
561
-
562
- def to_h: -> Hash[Symbol | String, bool]
563
-
564
- def options: -> Hash[Symbol | String, Hash[Symbol, untyped]]
565
-
566
- def enabled?: (Symbol | String) -> bool
567
-
568
- def enable!: (*(Symbol | String)) -> Hash[Symbol | String, Hash[Symbol, untyped]]
569
-
570
- def disable!: (*(Symbol | String)) -> Hash[Symbol | String, Hash[Symbol, untyped]]
571
-
572
- private
573
-
574
- def set_many: (Array[Symbol | String], to: bool) -> Hash[Symbol | String, Hash[Symbol, untyped]]
575
-
576
- def set_one: (Symbol | String, bool) -> void
577
-
578
- def require_option!: (Array[Symbol | String]) -> void
579
-
580
- def validate_option!: (Symbol | String) -> void
581
-
582
- def available_options_message: -> String
583
- end
584
-
585
- module BCDD::Result::Config::ConstantAlias
586
- MAPPING: Hash[String, Hash[Symbol, untyped]]
587
- OPTIONS: Hash[String, Hash[Symbol, untyped]]
588
- Listener: Proc
589
-
590
- def self.switcher: -> BCDD::Result::Config::Switcher
591
- end
592
-
593
- module BCDD::Result::Config::Options
594
- def self.with_defaults: (
595
- Hash[Symbol, Hash[Symbol, bool]],
596
- Symbol
597
- ) -> Hash[Symbol, bool]
598
-
599
- def self.select: (
600
- Hash[Symbol, Hash[Symbol, bool]],
601
- config: Symbol,
602
- from: Hash[Symbol, untyped]
603
- ) -> Hash[Symbol, untyped]
604
-
605
- def self.addon: (
606
- map: Hash[Symbol, Hash[Symbol, bool]],
607
- from: Hash[Symbol, Module]
608
- ) -> Hash[Symbol, Module]
609
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcdd-result
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-12 00:00:00.000000000 Z
11
+ date: 2023-12-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Empower Ruby apps with pragmatic use of Result pattern (monad), Railway
14
14
  Oriented Programming, and B/CDD.
@@ -29,9 +29,12 @@ files:
29
29
  - lib/bcdd-result.rb
30
30
  - lib/bcdd/result.rb
31
31
  - lib/bcdd/result/config.rb
32
- - lib/bcdd/result/config/constant_alias.rb
33
32
  - lib/bcdd/result/config/options.rb
34
33
  - lib/bcdd/result/config/switcher.rb
34
+ - lib/bcdd/result/config/switchers/addons.rb
35
+ - lib/bcdd/result/config/switchers/constant_aliases.rb
36
+ - lib/bcdd/result/config/switchers/features.rb
37
+ - lib/bcdd/result/config/switchers/pattern_matching.rb
35
38
  - lib/bcdd/result/context.rb
36
39
  - lib/bcdd/result/context/expectations.rb
37
40
  - lib/bcdd/result/context/expectations/mixin.rb
@@ -57,8 +60,23 @@ files:
57
60
  - lib/bcdd/result/mixin.rb
58
61
  - lib/bcdd/result/success.rb
59
62
  - lib/bcdd/result/success/methods.rb
63
+ - lib/bcdd/result/transitions.rb
64
+ - lib/bcdd/result/transitions/tracking.rb
65
+ - lib/bcdd/result/transitions/tracking/disabled.rb
66
+ - lib/bcdd/result/transitions/tracking/enabled.rb
67
+ - lib/bcdd/result/transitions/tree.rb
60
68
  - lib/bcdd/result/version.rb
61
69
  - sig/bcdd/result.rbs
70
+ - sig/bcdd/result/config.rbs
71
+ - sig/bcdd/result/context.rbs
72
+ - sig/bcdd/result/contract.rbs
73
+ - sig/bcdd/result/data.rbs
74
+ - sig/bcdd/result/error.rbs
75
+ - sig/bcdd/result/expectations.rbs
76
+ - sig/bcdd/result/handler.rbs
77
+ - sig/bcdd/result/mixin.rbs
78
+ - sig/bcdd/result/transitions.rbs
79
+ - sig/bcdd/result/version.rbs
62
80
  homepage: https://github.com/b-cdd/result
63
81
  licenses:
64
82
  - MIT
@@ -83,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
101
  - !ruby/object:Gem::Version
84
102
  version: '0'
85
103
  requirements: []
86
- rubygems_version: 3.4.19
104
+ rubygems_version: 3.5.3
87
105
  signing_key:
88
106
  specification_version: 4
89
107
  summary: Empower Ruby apps with pragmatic use of Result pattern (monad), Railway Oriented