functional-light-service 0.5.4 → 6.0.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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/project-build.yml +35 -11
  3. data/.rubocop.yml +101 -160
  4. data/AUDIT-functional-light-service.md +352 -0
  5. data/CHANGELOG.md +38 -0
  6. data/README.md +54 -2
  7. data/audit/bench.rb +99 -0
  8. data/audit/verify_findings.rb +172 -0
  9. data/functional-light-service.gemspec +15 -21
  10. data/lib/functional-light-service/action.rb +97 -101
  11. data/lib/functional-light-service/configuration.rb +26 -24
  12. data/lib/functional-light-service/context/key_verifier.rb +124 -118
  13. data/lib/functional-light-service/context.rb +63 -20
  14. data/lib/functional-light-service/deprecations.rb +26 -0
  15. data/lib/functional-light-service/errors.rb +8 -6
  16. data/lib/functional-light-service/functional/enum.rb +286 -250
  17. data/lib/functional-light-service/functional/maybe.rb +21 -15
  18. data/lib/functional-light-service/functional/monad.rb +77 -66
  19. data/lib/functional-light-service/functional/null.rb +88 -74
  20. data/lib/functional-light-service/functional/option.rb +100 -97
  21. data/lib/functional-light-service/functional/result.rb +129 -116
  22. data/lib/functional-light-service/localization_adapter.rb +48 -47
  23. data/lib/functional-light-service/organizer/execute.rb +16 -14
  24. data/lib/functional-light-service/organizer/iterate.rb +30 -25
  25. data/lib/functional-light-service/organizer/reduce_if.rb +19 -17
  26. data/lib/functional-light-service/organizer/reduce_until.rb +22 -20
  27. data/lib/functional-light-service/organizer/scoped_reducable.rb +15 -13
  28. data/lib/functional-light-service/organizer/with_callback.rb +28 -26
  29. data/lib/functional-light-service/organizer/with_reducer.rb +81 -77
  30. data/lib/functional-light-service/organizer/with_reducer_factory.rb +20 -18
  31. data/lib/functional-light-service/organizer/with_reducer_log_decorator.rb +110 -108
  32. data/lib/functional-light-service/organizer.rb +114 -114
  33. data/lib/functional-light-service/testing/context_factory.rb +48 -42
  34. data/lib/functional-light-service/testing.rb +3 -1
  35. data/lib/functional-light-service/version.rb +5 -3
  36. data/lib/functional-light-service.rb +30 -28
  37. data/spec/acceptance/after_actions_spec.rb +87 -71
  38. data/spec/acceptance/before_actions_spec.rb +115 -98
  39. data/spec/acceptance/custom_log_from_organizer_spec.rb +61 -60
  40. data/spec/acceptance/deprecation_warnings_spec.rb +82 -0
  41. data/spec/acceptance/fail_spec.rb +52 -50
  42. data/spec/acceptance/message_localization_spec.rb +119 -118
  43. data/spec/acceptance/organizer/context_failure_and_skipping_spec.rb +68 -65
  44. data/spec/acceptance/organizer/reduce_if_spec.rb +89 -89
  45. data/spec/acceptance/organizer/with_callback_spec.rb +113 -110
  46. data/spec/acceptance/{not_having_call_method_warning_spec.rb → organizer_entry_point_spec.rb} +10 -7
  47. data/spec/acceptance/rollback_spec.rb +183 -132
  48. data/spec/action_expects_and_promises_spec.rb +97 -93
  49. data/spec/action_promised_keys_spec.rb +126 -122
  50. data/spec/context_spec.rb +289 -197
  51. data/spec/examples/controller_spec.rb +63 -63
  52. data/spec/examples/validate_address_spec.rb +38 -37
  53. data/spec/lib/deterministic/currify_spec.rb +90 -88
  54. data/spec/lib/deterministic/null_spec.rb +6 -1
  55. data/spec/lib/deterministic/option_spec.rb +140 -137
  56. data/spec/lib/deterministic/result/result_map_spec.rb +155 -154
  57. data/spec/lib/deterministic/result/result_shared.rb +3 -2
  58. data/spec/lib/deterministic/result_spec.rb +2 -2
  59. data/spec/lib/edge_cases_spec.rb +156 -0
  60. data/spec/lib/enum_spec.rb +1 -1
  61. data/spec/lib/native_pattern_matching_spec.rb +74 -0
  62. data/spec/organizer_spec.rb +115 -114
  63. data/spec/readme_spec.rb +45 -47
  64. data/spec/sample/calculates_order_tax_action_spec.rb +16 -16
  65. data/spec/sample/calculates_tax_spec.rb +1 -1
  66. data/spec/sample/looks_up_tax_percentage_action_spec.rb +55 -55
  67. data/spec/sample/tax/calculates_order_tax_action.rb +10 -9
  68. data/spec/sample/tax/looks_up_tax_percentage_action.rb +28 -27
  69. data/spec/sample/tax/provides_free_shipping_action.rb +11 -10
  70. data/spec/spec_helper.rb +6 -0
  71. data/spec/test_doubles.rb +628 -599
  72. data/spec/testing/context_factory_spec.rb +21 -0
  73. metadata +45 -161
  74. data/lib/functional-light-service/organizer/verify_call_method_exists.rb +0 -29
  75. data/spec/acceptance/include_warning_spec.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 414c6227c90e74daa910411118172e82f1d10078f9cd5f86596b5e3618580016
4
- data.tar.gz: 7780ccf972ab6b1ed15e746d5b5011fe4aeb605418406c839a976937c9a056ee
3
+ metadata.gz: a02972ac6e701ec1ed5ceafcea5880e961ccbaf23ff886fe8f490c5bb514e6e1
4
+ data.tar.gz: 0a35af1df1d0820de886bae015cc84846dc0809d4602d12528c7f716b537a2f9
5
5
  SHA512:
6
- metadata.gz: 7df8560f4f03d7d457f51222e17eaf371a412ee73ff91f74265c25d71595b1b4367646a9655ffaed7fa1df4494e34a80f512a82c1cfb2f36c3ea61eb3f426f67
7
- data.tar.gz: d1280e2f293a994cb4ce41b00bea1cb9065fd0107e9f3178a05c6f3b22b05d380223ef95daa65ca1a3041f43f593916bf38393432f6daf786f925a92ebed8aa0
6
+ metadata.gz: 1ec467e5b62e74629391dfaf9b2e0ede5534338b3ce1411f9c0f7c4a9c38b7aa880701ddd98e4fd5f8a61fa7e8dc741633c626a6b422c544084c825e883b1453
7
+ data.tar.gz: e526d9bd6c3736ea555db60add374336dd6a9e957f7fae265bee44282ffe0dbb2fb43bba03eaafd210aab7bcf1f9d1f7af96391fa34b680dacfe4cd148fff4ca
@@ -2,9 +2,9 @@ name: CI Tests
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ main, master ]
5
+ branches: [ main, master, develop ]
6
6
  pull_request:
7
- branches: [ main, master ]
7
+ branches: [ main, master, develop ]
8
8
 
9
9
  jobs:
10
10
  test:
@@ -13,19 +13,43 @@ jobs:
13
13
  fail-fast: false
14
14
  matrix:
15
15
  os: [ubuntu, macos, windows]
16
- ruby: [2.6.8, 2.7.4, 3.0.2]
17
- gemfile: [dry_inflector_0_2_1, i18n_1_8_11]
18
- continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
19
- env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
20
- BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
16
+ ruby: ['3.1', '3.2', '3.3', '3.4', '4.0']
21
17
  steps:
22
- - uses: actions/checkout@v2
18
+ - uses: actions/checkout@v4
23
19
  - uses: ruby/setup-ruby@v1
24
20
  with:
25
21
  ruby-version: ${{ matrix.ruby }}
26
- - run: bundle install --jobs 4 --retry 3
22
+ bundler-cache: true
27
23
  - run: bundle exec rspec spec
24
+
25
+ rubocop:
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: '3.4'
32
+ bundler-cache: true
28
33
  - run: bundle exec rubocop
34
+
35
+ # Verifica che i vincoli minimi delle dipendenze runtime dichiarati
36
+ # nel gemspec siano reali (sulla versione Ruby minima supportata)
37
+ minimal-deps:
38
+ runs-on: ubuntu-latest
39
+ strategy:
40
+ fail-fast: false
41
+ matrix:
42
+ gemfile: [dry_inflector_0_2_1, i18n_1_8_11]
43
+ env:
44
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ - uses: ruby/setup-ruby@v1
48
+ with:
49
+ ruby-version: '3.1'
50
+ bundler-cache: true
51
+ - run: bundle exec rspec spec
52
+
29
53
  codecov:
30
54
  name: Codecov
31
55
  runs-on: ubuntu-latest
@@ -35,8 +59,8 @@ jobs:
35
59
  - uses: actions/checkout@v4
36
60
  - uses: ruby/setup-ruby@v1
37
61
  with:
38
- ruby-version: 3.0.2
39
- - run: bundle install --jobs 4 --retry 3
62
+ ruby-version: '3.4'
63
+ bundler-cache: true
40
64
  - run: bundle exec rspec spec
41
65
  - uses: codecov/codecov-action@v5
42
66
  with:
data/.rubocop.yml CHANGED
@@ -1,160 +1,101 @@
1
- # require: rubocop-performance
2
-
3
- AllCops:
4
- TargetRubyVersion: 2.7
5
- Exclude:
6
- - 'lib/functional-light-service.rb'
7
- - 'vendor/bundle/**/*'
8
- - 'gemfiles/vendor/bundle/**/*'
9
- - 'bin/*'
10
- - 'functional-light-service.gemspec'
11
- NewCops: enable
12
- SuggestExtensions: false
13
-
14
- Style/Documentation:
15
- Enabled: false
16
-
17
- Style/FrozenStringLiteralComment:
18
- Enabled: false
19
-
20
- Style/Encoding:
21
- Enabled: false
22
-
23
- Style/StringLiterals:
24
- Enabled: false
25
-
26
- Style/FormatStringToken:
27
- Enabled: false
28
-
29
- Style/RedundantReturn:
30
- Enabled: false
31
-
32
- Style/SignalException:
33
- Enabled: true
34
-
35
- Style/HashSyntax:
36
- EnforcedStyle: hash_rockets
37
-
38
- Style/TrivialAccessors:
39
- AllowPredicates: true
40
-
41
- Style/MissingRespondToMissing:
42
- Enabled: false
43
-
44
- Style/Alias:
45
- Enabled: false
46
-
47
- Style/Lambda:
48
- EnforcedStyle: literal
49
-
50
- Naming/PredicateName:
51
- Enabled: false
52
-
53
- Metrics/MethodLength:
54
- Max: 15
55
-
56
- Metrics/BlockLength:
57
- Max: 35
58
- Exclude:
59
- - 'spec/**/*.rb'
60
-
61
- Metrics/AbcSize:
62
- Max: 24
63
-
64
- Naming/MethodParameterName:
65
- Enabled: false
66
-
67
- Layout/TrailingEmptyLines:
68
- Enabled: false
69
-
70
- Layout/LineLength:
71
- Max: 100
72
-
73
- Layout/EndOfLine:
74
- Enabled: False
75
-
76
- Lint/ConstantDefinitionInBlock:
77
- Exclude:
78
- - 'spec/**/*.rb'
79
-
80
- Lint/EmptyClass:
81
- Exclude:
82
- - 'spec/**/*.rb'
83
-
84
- # Defaults after the Rubocop upgrade
85
- Gemspec/DateAssignment: # new in 1.10
86
- Enabled: true
87
- Layout/LineEndStringConcatenationIndentation: # new in 1.18
88
- Enabled: true
89
- Layout/SpaceBeforeBrackets: # new in 1.7
90
- Enabled: true
91
- Lint/AmbiguousAssignment: # new in 1.7
92
- Enabled: true
93
- Lint/AmbiguousOperatorPrecedence: # new in 1.21
94
- Enabled: true
95
- Lint/AmbiguousRange: # new in 1.19
96
- Enabled: true
97
- Lint/DeprecatedConstants: # new in 1.8
98
- Enabled: true
99
- Lint/DuplicateBranch: # new in 1.3
100
- Enabled: true
101
- Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
102
- Enabled: true
103
- Lint/EmptyBlock: # new in 1.1
104
- Enabled: true
105
- Lint/EmptyInPattern: # new in 1.16
106
- Enabled: true
107
- Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
108
- Enabled: true
109
- Lint/LambdaWithoutLiteralBlock: # new in 1.8
110
- Enabled: true
111
- Lint/NoReturnInBeginEndBlocks: # new in 1.2
112
- Enabled: true
113
- Lint/NumberedParameterAssignment: # new in 1.9
114
- Enabled: true
115
- Lint/OrAssignmentToConstant: # new in 1.9
116
- Enabled: true
117
- Lint/RedundantDirGlobSort: # new in 1.8
118
- Enabled: true
119
- Lint/SymbolConversion: # new in 1.9
120
- Enabled: true
121
- Lint/ToEnumArguments: # new in 1.1
122
- Enabled: true
123
- Lint/TripleQuotes: # new in 1.9
124
- Enabled: true
125
- Lint/UnexpectedBlockArity: # new in 1.5
126
- Enabled: true
127
- Lint/UnmodifiedReduceAccumulator: # new in 1.1
128
- Enabled: true
129
- Style/ArgumentsForwarding: # new in 1.1
130
- Enabled: true
131
- Style/CollectionCompact: # new in 1.2
132
- Enabled: true
133
- Style/DocumentDynamicEvalDefinition: # new in 1.1
134
- Enabled: true
135
- Style/EndlessMethod: # new in 1.8
136
- Enabled: true
137
- Style/HashConversion: # new in 1.10
138
- Enabled: true
139
- Style/HashExcept: # new in 1.7
140
- Enabled: true
141
- Style/IfWithBooleanLiteralBranches: # new in 1.9
142
- Enabled: true
143
- Style/InPatternThen: # new in 1.16
144
- Enabled: true
145
- Style/MultilineInPatternThen: # new in 1.16
146
- Enabled: true
147
- Style/NegatedIfElseCondition: # new in 1.2
148
- Enabled: true
149
- Style/NilLambda: # new in 1.3
150
- Enabled: true
151
- Style/QuotedSymbols: # new in 1.16
152
- Enabled: true
153
- Style/RedundantArgument: # new in 1.4
154
- Enabled: true
155
- Style/RedundantSelfAssignmentBranch: # new in 1.19
156
- Enabled: true
157
- Style/StringChars: # new in 1.12
158
- Enabled: true
159
- Style/SwapValues: # new in 1.1
160
- Enabled: true
1
+ # require: rubocop-performance
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 3.1
5
+ Exclude:
6
+ - 'lib/functional-light-service.rb'
7
+ - 'vendor/bundle/**/*'
8
+ - 'gemfiles/vendor/bundle/**/*'
9
+ - 'bin/*'
10
+ - 'functional-light-service.gemspec'
11
+ - 'audit/**/*'
12
+ NewCops: enable
13
+ SuggestExtensions: false
14
+
15
+ Style/Documentation:
16
+ Enabled: false
17
+
18
+ Style/FrozenStringLiteralComment:
19
+ Enabled: true
20
+ Include:
21
+ - 'lib/**/*.rb'
22
+
23
+ Style/Encoding:
24
+ Enabled: false
25
+
26
+ Style/StringLiterals:
27
+ Enabled: false
28
+
29
+ Style/FormatStringToken:
30
+ Enabled: false
31
+
32
+ Style/RedundantReturn:
33
+ Enabled: false
34
+
35
+ Style/SignalException:
36
+ Enabled: true
37
+
38
+ Style/HashSyntax:
39
+ EnforcedStyle: hash_rockets
40
+
41
+ Style/TrivialAccessors:
42
+ AllowPredicates: true
43
+
44
+ Style/MissingRespondToMissing:
45
+ Enabled: false
46
+
47
+ Style/Alias:
48
+ Enabled: false
49
+
50
+ Style/Lambda:
51
+ EnforcedStyle: literal
52
+
53
+ Naming/PredicatePrefix:
54
+ Enabled: false
55
+
56
+ Metrics/MethodLength:
57
+ Max: 15
58
+
59
+ Metrics/BlockLength:
60
+ Max: 35
61
+ Exclude:
62
+ - 'spec/**/*.rb'
63
+
64
+ Metrics/AbcSize:
65
+ Max: 24
66
+
67
+ Naming/MethodParameterName:
68
+ Enabled: false
69
+
70
+ Layout/TrailingEmptyLines:
71
+ Enabled: false
72
+
73
+ Layout/LineLength:
74
+ Max: 100
75
+
76
+ Layout/EndOfLine:
77
+ Enabled: False
78
+
79
+ Lint/ConstantDefinitionInBlock:
80
+ Exclude:
81
+ - 'spec/**/*.rb'
82
+
83
+ Lint/EmptyClass:
84
+ Exclude:
85
+ - 'spec/**/*.rb'
86
+
87
+ # I cop nuovi sono abilitati automaticamente da NewCops: enable
88
+
89
+ # Template method (throw_error_predicate) e simili: nomi storici dell'API interna
90
+ Naming/PredicateMethod:
91
+ Enabled: false
92
+
93
+ # La gem definisce deliberatamente classi correlate nello stesso file
94
+ # (Result + Prelude, i verifier delle chiavi, i test double)
95
+ Style/OneClassPerFile:
96
+ Enabled: false
97
+
98
+ # Nelle spec l'include a top-level e' prassi
99
+ Style/MixinUsage:
100
+ Exclude:
101
+ - 'spec/**/*.rb'