bcdd-result 0.7.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dda53cc516fcb8d18b2bd3c8431f2ca8d5d7363b6e58fd57d3fe3d1b49877e20
4
- data.tar.gz: 367b97ba29f35dd2d6918817db38a2253929252c616aebcb47d7fc024888d258
3
+ metadata.gz: 2b49559a4258169692f89f3263c14485cde2e17e36c90ccde9bf88dab355d458
4
+ data.tar.gz: b62c215886f572f942a752767db89544ae5e483a496975882fcc9108d99edc0f
5
5
  SHA512:
6
- metadata.gz: 3618c5090981f4923977708944d94c257879fe57c06d1b2c922b7378c026e4d39c8ab13fdf64ad6277cfea4229d43d120b0d3ec3d7cb676676f0bf8d6714892d
7
- data.tar.gz: 880a2f0ebcd8f7bb9ee32b2967c39011211e604981d43b59735fc912ec414635bc152ab13549ba64c87af987f66a7c334fae909cd860d3f36f6b092565b8cf24
6
+ metadata.gz: 2794daec03ab43d9d9549887dae87d0138195f0c85f65ddcc1015d74a9a940c639e7dc73086c9f948de00c8ce95d576105a3ad9e671b068d56d39e4ef075c3ff
7
+ data.tar.gz: 197572b1a2dc61a72de744af1bbb50a642731dc4e248133164da36fb8ff8d257fe89c2874798ea9f77533aa462e386dd002cc2dd25f241ca12cd02ff8d080fa4
data/.rubocop.yml CHANGED
@@ -65,3 +65,10 @@ Minitest/MultipleAssertions:
65
65
 
66
66
  Minitest/AssertEmptyLiteral:
67
67
  Enabled: false
68
+
69
+ Minitest/AssertOperator:
70
+ Enabled: false
71
+
72
+ Naming/FileName:
73
+ Exclude:
74
+ - lib/bcdd-result.rb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,125 @@
1
+ - [\[Unreleased\]](#unreleased)
2
+ - [\[0.8.0\] - 2023-12-11](#080---2023-12-11)
3
+ - [Added](#added)
4
+ - [Changed](#changed)
5
+ - [Removed](#removed)
6
+ - [\[0.7.0\] - 2023-10-27](#070---2023-10-27)
7
+ - [Added](#added-1)
8
+ - [Changed](#changed-1)
9
+ - [\[0.6.0\] - 2023-10-11](#060---2023-10-11)
10
+ - [Added](#added-2)
11
+ - [Changed](#changed-2)
12
+ - [\[0.5.0\] - 2023-10-09](#050---2023-10-09)
13
+ - [Added](#added-3)
14
+ - [\[0.4.0\] - 2023-09-28](#040---2023-09-28)
15
+ - [Added](#added-4)
16
+ - [Changed](#changed-3)
17
+ - [Removed](#removed-1)
18
+ - [\[0.3.0\] - 2023-09-26](#030---2023-09-26)
19
+ - [Added](#added-5)
20
+ - [\[0.2.0\] - 2023-09-26](#020---2023-09-26)
21
+ - [Added](#added-6)
22
+ - [Removed](#removed-2)
23
+ - [\[0.1.0\] - 2023-09-25](#010---2023-09-25)
24
+ - [Added](#added-7)
25
+
1
26
  ## [Unreleased]
2
27
 
28
+ ## [0.8.0] - 2023-12-11
29
+
30
+ ### Added
31
+
32
+ - Add `BCDD::Result.config`
33
+ - **Feature**
34
+ ```ruby
35
+ BCDD::Result.config.feature.options
36
+ BCDD::Result.config.feature.enabled?(:expectations)
37
+ BCDD::Result.config.feature.enable!(:expectations)
38
+ BCDD::Result.config.feature.disable!(:expectations)
39
+ ```
40
+ - **Default Add-ons**
41
+ ```ruby
42
+ BCDD::Result.config.addon.options
43
+ BCDD::Result.config.addon.enabled?(:continue)
44
+ BCDD::Result.config.addon.enable!(:continue)
45
+ BCDD::Result.config.addon.disable!(:continue)
46
+ ```
47
+ - **Pattern matching**
48
+ ```ruby
49
+ BCDD::Result.config.pattern_matching.options
50
+ BCDD::Result.config.pattern_matching.enabled?(:nil_as_valid_value_checking)
51
+ BCDD::Result.config.pattern_matching.enable!(:nil_as_valid_value_checking)
52
+ BCDD::Result.config.pattern_matching.disable!(:nil_as_valid_value_checking)
53
+ ```
54
+ - **Constant Aliases**
55
+ ```ruby
56
+ BCDD::Result.config.constant_alias.options
57
+ BCDD::Result.config.constant_alias.enabled?('Result')
58
+ BCDD::Result.config.constant_alias.enable!('Result')
59
+ BCDD::Result.config.constant_alias.disable!('Result')
60
+ ```
61
+
62
+ - Add `BCDD::Result::configuration`. It freezes the configuration, disallowing methods that promote changes but allowing the query ones. You can use this feature to ensure integrity in your configuration.
63
+ ```ruby
64
+ BCDD::Result.configuration do |config|
65
+ config.addon.enable!(:continue)
66
+
67
+ config.constant_alias.enable!('Result')
68
+
69
+ config.pattern_matching.disable!(:nil_as_valid_value_checking)
70
+
71
+ config.feature.disable!(:expectations) if ::Rails.env.production?
72
+ end
73
+
74
+ BCDD::Result.config.addon.enabled?(:continue) # true
75
+ BCDD::Result.config.constant_alias.enabled?('Result') # true
76
+
77
+ BCDD::Result.config.addon.disable!(:continue) # raises FrozenError
78
+ BCDD::Result.config.constant_alias.disable!('Result') # raises FrozenError
79
+ ```
80
+
81
+ - Allow the pattern matching feature to be turned on/off through the `BCDD::Result::Expectations.mixin`. Now, it can be used without enabling it for the whole project.
82
+ ```ruby
83
+ extend BCDD::Result::Expectations.mixin(
84
+ config: {
85
+ addon: { continue: false },
86
+ pattern_matching: { nil_as_valid_value_checking: true },
87
+ },
88
+ success: {
89
+ numbers: ->(value) { value => [Numeric, Numeric] },
90
+ division_completed: Numeric
91
+ },
92
+ failure: {
93
+ invalid_arg: String,
94
+ division_by_zero: String
95
+ }
96
+ )
97
+ ```
98
+
99
+ ### Changed
100
+
101
+ - **(BREAKING)** Replace `BCDD::Result::Contract.nil_as_valid_value_checking!` with `BCDD::Result::Config.pattern_matching.enable!(:nil_as_valid_value_checking)`.
102
+
103
+ - **(BREAKING)** Replace `BCDD::Result::Contract.nil_as_valid_value_checking?` with `BCDD::Result::Config.pattern_matching.enabled?(:nil_as_valid_value_checking)`.
104
+
105
+ - **(BREAKING)** Replace `mixin(with:)` with `mixin(config:)` keyword argument.
106
+
107
+ - **(BREAKING)** Change the addons definition.
108
+ - **From**
109
+ ```ruby
110
+ BCDD::Result.mixin(with: :Continue)
111
+ BCDD::Result.mixin(with: [:Continue])
112
+ ```
113
+ - **To**
114
+ ```ruby
115
+ BCDD::Result.mixin(config: { addon: { continue: true } })
116
+ ```
117
+ - These examples are valid to all kinds of mixins (`BCDD::Result.mixin`, `BCDD::Result::Context.mixin`, `BCDD::Result::Expectations.mixin`, `BCDD::Result::Context::Expectations.mixin`)
118
+
119
+ ### Removed
120
+
121
+ - **(BREAKING)** Remove the `lib/result` file. Now you can define `Result` as an alias for `BCDD::Result` using `BCDD::Result::Config.constant_alias.enable!('Result')`.
122
+
3
123
  ## [0.7.0] - 2023-10-27
4
124
 
5
125
  ### Added