bcdd-result 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/CHANGELOG.md +120 -0
- data/README.md +315 -133
- data/Rakefile +9 -3
- data/Steepfile +1 -1
- data/lib/bcdd/result/config/constant_alias.rb +33 -0
- data/lib/bcdd/result/config/options.rb +26 -0
- data/lib/bcdd/result/config/switcher.rb +82 -0
- data/lib/bcdd/result/config.rb +71 -0
- data/lib/bcdd/result/context/expectations/mixin.rb +5 -17
- data/lib/bcdd/result/context/expectations.rb +7 -23
- data/lib/bcdd/result/context/mixin.rb +12 -9
- data/lib/bcdd/result/contract/for_types_and_values.rb +7 -2
- data/lib/bcdd/result/contract.rb +4 -14
- data/lib/bcdd/result/expectations/mixin.rb +12 -10
- data/lib/bcdd/result/expectations.rb +31 -7
- data/lib/bcdd/result/mixin.rb +27 -14
- data/lib/bcdd/result/version.rb +1 -1
- data/lib/bcdd/result.rb +11 -0
- data/lib/bcdd-result.rb +3 -0
- data/sig/bcdd/result.rbs +146 -38
- metadata +11 -8
- data/lib/result.rb +0 -5
data/sig/bcdd/result.rbs
CHANGED
@@ -11,6 +11,9 @@ class BCDD::Result
|
|
11
11
|
attr_reader data: BCDD::Result::Data
|
12
12
|
attr_reader subject: untyped
|
13
13
|
|
14
|
+
def self.config: -> BCDD::Result::Config
|
15
|
+
def self.configuration: { (BCDD::Result::Config) -> void } -> BCDD::Result::Config
|
16
|
+
|
14
17
|
def initialize: (
|
15
18
|
type: Symbol,
|
16
19
|
value: untyped,
|
@@ -94,6 +97,10 @@ end
|
|
94
97
|
|
95
98
|
class BCDD::Result
|
96
99
|
module Mixin
|
100
|
+
module Factory
|
101
|
+
def self.module!: -> Module
|
102
|
+
end
|
103
|
+
|
97
104
|
module Methods
|
98
105
|
def Success: (Symbol type, ?untyped value) -> BCDD::Result::Success
|
99
106
|
|
@@ -111,13 +118,15 @@ class BCDD::Result
|
|
111
118
|
|
112
119
|
OPTIONS: Hash[Symbol, Module]
|
113
120
|
|
114
|
-
def self.options: (
|
121
|
+
def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Array[Module]
|
115
122
|
end
|
116
|
-
|
117
|
-
def self.module!: -> Module
|
118
123
|
end
|
119
124
|
|
120
|
-
def self.mixin: (?
|
125
|
+
def self.mixin: (?config: Hash[Symbol, Hash[Symbol, bool]]) -> Module
|
126
|
+
|
127
|
+
def self.mixin_module: -> singleton(BCDD::Result::Mixin)
|
128
|
+
|
129
|
+
def self.result_factory: -> singleton(BCDD::Result)
|
121
130
|
end
|
122
131
|
|
123
132
|
class BCDD::Result
|
@@ -225,16 +234,14 @@ module BCDD::Result::Contract
|
|
225
234
|
BCDD::Result::Contract::Evaluator
|
226
235
|
) -> BCDD::Result::Contract::TypeChecker
|
227
236
|
|
228
|
-
ToEnsure: ^(Hash[Symbol, untyped] | Array[Symbol])
|
229
|
-
-> BCDD::Result::Contract::
|
237
|
+
ToEnsure: ^(Hash[Symbol, untyped] | Array[Symbol], Hash[Symbol, Hash[Symbol, bool]])
|
238
|
+
-> BCDD::Result::Contract::Interface
|
230
239
|
|
231
240
|
def self.new: (
|
232
241
|
success: Hash[Symbol, untyped] | Array[Symbol],
|
233
|
-
failure: Hash[Symbol, untyped] | Array[Symbol]
|
242
|
+
failure: Hash[Symbol, untyped] | Array[Symbol],
|
243
|
+
config: Hash[Symbol, Hash[Symbol, bool]]
|
234
244
|
) -> BCDD::Result::Contract::Evaluator
|
235
|
-
|
236
|
-
def self.nil_as_valid_value_checking!: (?enabled: bool) -> void
|
237
|
-
def self.nil_as_valid_value_checking?: -> bool
|
238
245
|
end
|
239
246
|
|
240
247
|
module BCDD::Result::Contract
|
@@ -309,7 +316,14 @@ module BCDD::Result::Contract
|
|
309
316
|
class ForTypesAndValues
|
310
317
|
include Interface
|
311
318
|
|
312
|
-
def initialize: (
|
319
|
+
def initialize: (
|
320
|
+
Hash[Symbol, untyped],
|
321
|
+
Hash[Symbol, Hash[Symbol, bool]]
|
322
|
+
) -> void
|
323
|
+
|
324
|
+
private
|
325
|
+
|
326
|
+
def nil_as_valid_value_checking?: -> bool
|
313
327
|
end
|
314
328
|
end
|
315
329
|
|
@@ -334,16 +348,35 @@ end
|
|
334
348
|
|
335
349
|
class BCDD::Result::Expectations
|
336
350
|
def self.mixin: (
|
337
|
-
?
|
351
|
+
?config: Hash[Symbol, Hash[Symbol, bool]],
|
338
352
|
?success: Hash[Symbol, untyped] | Array[Symbol],
|
339
353
|
?failure: Hash[Symbol, untyped] | Array[Symbol]
|
340
354
|
) -> Module
|
341
355
|
|
356
|
+
def self.mixin!: (
|
357
|
+
?config: Hash[Symbol, Hash[Symbol, bool]],
|
358
|
+
?success: Hash[Symbol, untyped] | Array[Symbol],
|
359
|
+
?failure: Hash[Symbol, untyped] | Array[Symbol]
|
360
|
+
) -> Module
|
361
|
+
|
362
|
+
def self.mixin_module: -> singleton(BCDD::Result::Expectations::Mixin)
|
363
|
+
|
364
|
+
def self.result_factory_without_expectations: -> singleton(BCDD::Result)
|
365
|
+
|
366
|
+
def self.new: (
|
367
|
+
?subject: untyped,
|
368
|
+
?success: Hash[Symbol, untyped] | Array[Symbol],
|
369
|
+
?failure: Hash[Symbol, untyped] | Array[Symbol],
|
370
|
+
?contract: BCDD::Result::Contract::Evaluator,
|
371
|
+
?config: Hash[Symbol, Hash[Symbol, bool]]
|
372
|
+
) -> (BCDD::Result::Expectations | untyped)
|
373
|
+
|
342
374
|
def initialize: (
|
343
375
|
?subject: untyped,
|
344
376
|
?success: Hash[Symbol, untyped] | Array[Symbol],
|
345
377
|
?failure: Hash[Symbol, untyped] | Array[Symbol],
|
346
|
-
?contract: BCDD::Result::Contract::Evaluator
|
378
|
+
?contract: BCDD::Result::Contract::Evaluator,
|
379
|
+
?config: Hash[Symbol, Hash[Symbol, bool]]
|
347
380
|
) -> void
|
348
381
|
|
349
382
|
def Success: (Symbol, ?untyped) -> BCDD::Result::Success
|
@@ -358,6 +391,10 @@ class BCDD::Result::Expectations
|
|
358
391
|
end
|
359
392
|
|
360
393
|
module BCDD::Result::Expectations::Mixin
|
394
|
+
module Factory
|
395
|
+
def self.module!: -> Module
|
396
|
+
end
|
397
|
+
|
361
398
|
METHODS: String
|
362
399
|
|
363
400
|
module Addons
|
@@ -367,10 +404,8 @@ module BCDD::Result::Expectations::Mixin
|
|
367
404
|
|
368
405
|
OPTIONS: Hash[Symbol, Module]
|
369
406
|
|
370
|
-
def self.options: (Symbol) -> Array[Module]
|
407
|
+
def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Array[Module]
|
371
408
|
end
|
372
|
-
|
373
|
-
def self.module!: -> Module
|
374
409
|
end
|
375
410
|
|
376
411
|
class BCDD::Result::Context < BCDD::Result
|
@@ -419,6 +454,8 @@ end
|
|
419
454
|
|
420
455
|
class BCDD::Result::Context
|
421
456
|
module Mixin
|
457
|
+
Factory: singleton(BCDD::Result::Mixin::Factory)
|
458
|
+
|
422
459
|
module Methods
|
423
460
|
def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
|
424
461
|
|
@@ -436,40 +473,27 @@ class BCDD::Result::Context
|
|
436
473
|
|
437
474
|
OPTIONS: Hash[Symbol, Module]
|
438
475
|
|
439
|
-
def self.options: (
|
476
|
+
def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Array[Module]
|
440
477
|
end
|
441
478
|
end
|
442
479
|
|
443
|
-
def self.
|
480
|
+
def self.mixin_module: -> singleton(BCDD::Result::Context::Mixin)
|
481
|
+
|
482
|
+
def self.result_factory: -> singleton(BCDD::Result::Context)
|
444
483
|
end
|
445
484
|
|
446
|
-
class BCDD::Result::Context::Expectations
|
447
|
-
def self.
|
448
|
-
?with: Symbol,
|
449
|
-
?success: Hash[Symbol, untyped] | Array[Symbol],
|
450
|
-
?failure: Hash[Symbol, untyped] | Array[Symbol]
|
451
|
-
) -> Module
|
485
|
+
class BCDD::Result::Context::Expectations < BCDD::Result::Expectations
|
486
|
+
def self.mixin_module: -> singleton(BCDD::Result::Context::Expectations::Mixin)
|
452
487
|
|
453
|
-
def
|
454
|
-
?subject: untyped,
|
455
|
-
?success: Hash[Symbol, untyped] | Array[Symbol],
|
456
|
-
?failure: Hash[Symbol, untyped] | Array[Symbol],
|
457
|
-
?contract: BCDD::Result::Contract::Evaluator
|
458
|
-
) -> void
|
488
|
+
def self.result_factory_without_expectations: -> singleton(BCDD::Result)
|
459
489
|
|
460
490
|
def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
|
461
491
|
def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
|
462
|
-
|
463
|
-
def with: (subject: untyped) -> BCDD::Result::Context::Expectations
|
464
|
-
|
465
|
-
private
|
466
|
-
|
467
|
-
attr_reader subject: untyped
|
468
|
-
attr_reader contract: BCDD::Result::Contract::Evaluator
|
469
492
|
end
|
470
493
|
|
471
494
|
module BCDD::Result::Context::Expectations::Mixin
|
472
495
|
METHODS: String
|
496
|
+
Factory: singleton(BCDD::Result::Expectations::Mixin::Factory)
|
473
497
|
|
474
498
|
module Addons
|
475
499
|
module Continuable
|
@@ -478,6 +502,90 @@ module BCDD::Result::Context::Expectations::Mixin
|
|
478
502
|
|
479
503
|
OPTIONS: Hash[Symbol, Module]
|
480
504
|
|
481
|
-
def self.options: (Symbol) -> Array[Module]
|
505
|
+
def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Array[Module]
|
482
506
|
end
|
483
507
|
end
|
508
|
+
|
509
|
+
class BCDD::Result::Config
|
510
|
+
include Singleton
|
511
|
+
|
512
|
+
ADDON: Hash[Symbol, Hash[Symbol, untyped]]
|
513
|
+
FEATURE: Hash[Symbol, Hash[Symbol, untyped]]
|
514
|
+
PATTERN_MATCHING: Hash[Symbol, Hash[Symbol, untyped]]
|
515
|
+
|
516
|
+
attr_reader addon: BCDD::Result::Config::Switcher
|
517
|
+
attr_reader feature: BCDD::Result::Config::Switcher
|
518
|
+
attr_reader constant_alias: BCDD::Result::Config::Switcher
|
519
|
+
attr_reader pattern_matching: BCDD::Result::Config::Switcher
|
520
|
+
|
521
|
+
def self.instance: -> BCDD::Result::Config
|
522
|
+
|
523
|
+
def initialize: -> void
|
524
|
+
|
525
|
+
def freeze: -> BCDD::Result::Config
|
526
|
+
def options: -> Hash[Symbol, BCDD::Result::Config::Switcher]
|
527
|
+
def to_h: -> Hash[Symbol, Hash[Symbol | String, bool]]
|
528
|
+
end
|
529
|
+
|
530
|
+
class BCDD::Result::Config::Switcher
|
531
|
+
private attr_reader _affects: Hash[Symbol | String, Array[String]]
|
532
|
+
private attr_reader _options: Hash[Symbol | String, bool]
|
533
|
+
private attr_reader listener: Proc
|
534
|
+
|
535
|
+
def initialize: (
|
536
|
+
options: Hash[Symbol | String, Hash[Symbol, untyped]],
|
537
|
+
?listener: Proc
|
538
|
+
) -> void
|
539
|
+
|
540
|
+
def freeze: -> BCDD::Result::Config::Switcher
|
541
|
+
|
542
|
+
def to_h: -> Hash[Symbol | String, bool]
|
543
|
+
|
544
|
+
def options: -> Hash[Symbol | String, Hash[Symbol, untyped]]
|
545
|
+
|
546
|
+
def enabled?: (Symbol | String) -> bool
|
547
|
+
|
548
|
+
def enable!: (*(Symbol | String)) -> Hash[Symbol | String, Hash[Symbol, untyped]]
|
549
|
+
|
550
|
+
def disable!: (*(Symbol | String)) -> Hash[Symbol | String, Hash[Symbol, untyped]]
|
551
|
+
|
552
|
+
private
|
553
|
+
|
554
|
+
def set_many: (Array[Symbol | String], to: bool) -> Hash[Symbol | String, Hash[Symbol, untyped]]
|
555
|
+
|
556
|
+
def set_one: (Symbol | String, bool) -> void
|
557
|
+
|
558
|
+
def require_option!: (Array[Symbol | String]) -> void
|
559
|
+
|
560
|
+
def validate_option!: (Symbol | String) -> void
|
561
|
+
|
562
|
+
def available_options_message: -> String
|
563
|
+
end
|
564
|
+
|
565
|
+
module BCDD::Result::Config::ConstantAlias
|
566
|
+
RESULT: String
|
567
|
+
|
568
|
+
OPTIONS: Hash[String, Hash[Symbol, untyped]]
|
569
|
+
MAPPING: Hash[String, Hash[Symbol, untyped]]
|
570
|
+
Listener: Proc
|
571
|
+
|
572
|
+
def self.switcher: -> BCDD::Result::Config::Switcher
|
573
|
+
end
|
574
|
+
|
575
|
+
module BCDD::Result::Config::Options
|
576
|
+
def self.with_defaults: (
|
577
|
+
Hash[Symbol, Hash[Symbol, bool]],
|
578
|
+
Symbol
|
579
|
+
) -> Hash[Symbol, bool]
|
580
|
+
|
581
|
+
def self.filter_map: (
|
582
|
+
Hash[Symbol, Hash[Symbol, bool]],
|
583
|
+
config: Symbol,
|
584
|
+
from: Hash[Symbol, untyped]
|
585
|
+
) -> Array[untyped]
|
586
|
+
|
587
|
+
def self.addon: (
|
588
|
+
map: Hash[Symbol, Hash[Symbol, bool]],
|
589
|
+
from: Hash[Symbol, Module]
|
590
|
+
) -> Array[Module]
|
591
|
+
end
|
metadata
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcdd-result
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.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-
|
11
|
+
date: 2023-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
|
16
|
-
It's a general-purpose result monad that allows you to create objects representing a success (BCDD::Result::Success) or failure (BCDD::Result::Failure).
|
13
|
+
description: Empower Ruby apps with pragmatic use of Result monad, Railway Oriented
|
14
|
+
Programming, and B/CDD.
|
17
15
|
email:
|
18
16
|
- rodrigo.serradura@gmail.com
|
19
17
|
executables: []
|
@@ -28,7 +26,12 @@ files:
|
|
28
26
|
- README.md
|
29
27
|
- Rakefile
|
30
28
|
- Steepfile
|
29
|
+
- lib/bcdd-result.rb
|
31
30
|
- lib/bcdd/result.rb
|
31
|
+
- lib/bcdd/result/config.rb
|
32
|
+
- lib/bcdd/result/config/constant_alias.rb
|
33
|
+
- lib/bcdd/result/config/options.rb
|
34
|
+
- lib/bcdd/result/config/switcher.rb
|
32
35
|
- lib/bcdd/result/context.rb
|
33
36
|
- lib/bcdd/result/context/expectations.rb
|
34
37
|
- lib/bcdd/result/context/expectations/mixin.rb
|
@@ -55,7 +58,6 @@ files:
|
|
55
58
|
- lib/bcdd/result/success.rb
|
56
59
|
- lib/bcdd/result/success/methods.rb
|
57
60
|
- lib/bcdd/result/version.rb
|
58
|
-
- lib/result.rb
|
59
61
|
- sig/bcdd/result.rbs
|
60
62
|
homepage: https://github.com/b-cdd/result
|
61
63
|
licenses:
|
@@ -84,5 +86,6 @@ requirements: []
|
|
84
86
|
rubygems_version: 3.4.19
|
85
87
|
signing_key:
|
86
88
|
specification_version: 4
|
87
|
-
summary:
|
89
|
+
summary: Empower Ruby apps with pragmatic use of Result monad, Railway Oriented Programming,
|
90
|
+
and B/CDD.
|
88
91
|
test_files: []
|