servus 0.2.1 → 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.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/servus/event_handler/event_handler_generator.rb +1 -1
  3. data/lib/generators/servus/guard/guard_generator.rb +1 -1
  4. data/lib/generators/servus/guard/templates/guard.rb.erb +5 -3
  5. data/lib/generators/servus/service/service_generator.rb +1 -1
  6. data/lib/servus/base.rb +67 -9
  7. data/lib/servus/config.rb +71 -3
  8. data/lib/servus/events/bus.rb +29 -0
  9. data/lib/servus/events/emitter.rb +15 -0
  10. data/lib/servus/extensions/lazily/call.rb +82 -0
  11. data/lib/servus/extensions/lazily/errors.rb +37 -0
  12. data/lib/servus/extensions/lazily/ext.rb +23 -0
  13. data/lib/servus/extensions/lazily/resolver.rb +32 -0
  14. data/lib/servus/guard.rb +7 -6
  15. data/lib/servus/guards/falsey_guard.rb +3 -3
  16. data/lib/servus/guards/presence_guard.rb +4 -4
  17. data/lib/servus/guards/state_guard.rb +4 -5
  18. data/lib/servus/guards/truthy_guard.rb +3 -3
  19. data/lib/servus/helpers/controller_helpers.rb +40 -0
  20. data/lib/servus/railtie.rb +7 -1
  21. data/lib/servus/support/data_object.rb +80 -0
  22. data/lib/servus/support/errors.rb +16 -0
  23. data/lib/servus/support/lockdown.rb +94 -0
  24. data/lib/servus/support/logger.rb +16 -0
  25. data/lib/servus/support/response.rb +12 -1
  26. data/lib/servus/support/validator.rb +79 -34
  27. data/lib/servus/testing/example_builders.rb +74 -0
  28. data/lib/servus/testing/matchers.rb +99 -0
  29. data/lib/servus/version.rb +1 -1
  30. data/lib/servus.rb +2 -0
  31. metadata +16 -114
  32. data/.claude/commands/check-docs.md +0 -1
  33. data/.claude/commands/consistency-check.md +0 -1
  34. data/.claude/commands/fine-tooth-comb.md +0 -1
  35. data/.claude/commands/red-green-refactor.md +0 -5
  36. data/.claude/settings.json +0 -24
  37. data/.rspec +0 -3
  38. data/.rubocop.yml +0 -27
  39. data/.yardopts +0 -6
  40. data/CHANGELOG.md +0 -122
  41. data/CLAUDE.md +0 -10
  42. data/IDEAS.md +0 -5
  43. data/LICENSE.txt +0 -21
  44. data/READme.md +0 -856
  45. data/Rakefile +0 -45
  46. data/docs/core/1_overview.md +0 -77
  47. data/docs/core/2_architecture.md +0 -120
  48. data/docs/core/3_service_objects.md +0 -121
  49. data/docs/features/1_schema_validation.md +0 -119
  50. data/docs/features/2_error_handling.md +0 -121
  51. data/docs/features/3_async_execution.md +0 -81
  52. data/docs/features/4_logging.md +0 -64
  53. data/docs/features/5_event_bus.md +0 -244
  54. data/docs/features/6_guards.md +0 -356
  55. data/docs/features/guards_naming_convention.md +0 -540
  56. data/docs/guides/1_common_patterns.md +0 -90
  57. data/docs/guides/2_migration_guide.md +0 -175
  58. data/docs/integration/1_configuration.md +0 -154
  59. data/docs/integration/2_testing.md +0 -287
  60. data/docs/integration/3_rails_integration.md +0 -99
  61. data/docs/yard/Servus/Base.html +0 -1645
  62. data/docs/yard/Servus/Config.html +0 -582
  63. data/docs/yard/Servus/Extensions/Async/Call.html +0 -400
  64. data/docs/yard/Servus/Extensions/Async/Errors/AsyncError.html +0 -140
  65. data/docs/yard/Servus/Extensions/Async/Errors/JobEnqueueError.html +0 -154
  66. data/docs/yard/Servus/Extensions/Async/Errors/ServiceNotFoundError.html +0 -154
  67. data/docs/yard/Servus/Extensions/Async/Errors.html +0 -128
  68. data/docs/yard/Servus/Extensions/Async/Ext.html +0 -119
  69. data/docs/yard/Servus/Extensions/Async/Job.html +0 -310
  70. data/docs/yard/Servus/Extensions/Async.html +0 -141
  71. data/docs/yard/Servus/Extensions.html +0 -117
  72. data/docs/yard/Servus/Generators/ServiceGenerator.html +0 -261
  73. data/docs/yard/Servus/Generators.html +0 -115
  74. data/docs/yard/Servus/Helpers/ControllerHelpers.html +0 -457
  75. data/docs/yard/Servus/Helpers.html +0 -115
  76. data/docs/yard/Servus/Railtie.html +0 -134
  77. data/docs/yard/Servus/Support/Errors/AuthenticationError.html +0 -287
  78. data/docs/yard/Servus/Support/Errors/BadRequestError.html +0 -283
  79. data/docs/yard/Servus/Support/Errors/ForbiddenError.html +0 -284
  80. data/docs/yard/Servus/Support/Errors/InternalServerError.html +0 -283
  81. data/docs/yard/Servus/Support/Errors/NotFoundError.html +0 -284
  82. data/docs/yard/Servus/Support/Errors/ServiceError.html +0 -489
  83. data/docs/yard/Servus/Support/Errors/ServiceUnavailableError.html +0 -290
  84. data/docs/yard/Servus/Support/Errors/UnauthorizedError.html +0 -200
  85. data/docs/yard/Servus/Support/Errors/UnprocessableEntityError.html +0 -288
  86. data/docs/yard/Servus/Support/Errors/ValidationError.html +0 -200
  87. data/docs/yard/Servus/Support/Errors.html +0 -140
  88. data/docs/yard/Servus/Support/Logger.html +0 -856
  89. data/docs/yard/Servus/Support/Rescuer/BlockContext.html +0 -585
  90. data/docs/yard/Servus/Support/Rescuer/CallOverride.html +0 -257
  91. data/docs/yard/Servus/Support/Rescuer/ClassMethods.html +0 -343
  92. data/docs/yard/Servus/Support/Rescuer.html +0 -267
  93. data/docs/yard/Servus/Support/Response.html +0 -574
  94. data/docs/yard/Servus/Support/Validator.html +0 -1150
  95. data/docs/yard/Servus/Support.html +0 -119
  96. data/docs/yard/Servus/Testing/ExampleBuilders.html +0 -523
  97. data/docs/yard/Servus/Testing/ExampleExtractor.html +0 -578
  98. data/docs/yard/Servus/Testing.html +0 -142
  99. data/docs/yard/Servus.html +0 -343
  100. data/docs/yard/_index.html +0 -535
  101. data/docs/yard/class_list.html +0 -54
  102. data/docs/yard/css/common.css +0 -1
  103. data/docs/yard/css/full_list.css +0 -58
  104. data/docs/yard/css/style.css +0 -503
  105. data/docs/yard/file.1_common_patterns.html +0 -154
  106. data/docs/yard/file.1_configuration.html +0 -115
  107. data/docs/yard/file.1_overview.html +0 -142
  108. data/docs/yard/file.1_schema_validation.html +0 -188
  109. data/docs/yard/file.2_architecture.html +0 -157
  110. data/docs/yard/file.2_error_handling.html +0 -190
  111. data/docs/yard/file.2_migration_guide.html +0 -242
  112. data/docs/yard/file.2_testing.html +0 -227
  113. data/docs/yard/file.3_async_execution.html +0 -145
  114. data/docs/yard/file.3_rails_integration.html +0 -160
  115. data/docs/yard/file.3_service_objects.html +0 -191
  116. data/docs/yard/file.4_logging.html +0 -135
  117. data/docs/yard/file.ErrorHandling.html +0 -190
  118. data/docs/yard/file.READme.html +0 -674
  119. data/docs/yard/file.architecture.html +0 -157
  120. data/docs/yard/file.async_execution.html +0 -145
  121. data/docs/yard/file.common_patterns.html +0 -154
  122. data/docs/yard/file.configuration.html +0 -115
  123. data/docs/yard/file.error_handling.html +0 -190
  124. data/docs/yard/file.logging.html +0 -135
  125. data/docs/yard/file.migration_guide.html +0 -242
  126. data/docs/yard/file.overview.html +0 -142
  127. data/docs/yard/file.rails_integration.html +0 -160
  128. data/docs/yard/file.schema_validation.html +0 -188
  129. data/docs/yard/file.service_objects.html +0 -191
  130. data/docs/yard/file.testing.html +0 -227
  131. data/docs/yard/file_list.html +0 -119
  132. data/docs/yard/frames.html +0 -22
  133. data/docs/yard/index.html +0 -674
  134. data/docs/yard/js/app.js +0 -344
  135. data/docs/yard/js/full_list.js +0 -242
  136. data/docs/yard/js/jquery.js +0 -4
  137. data/docs/yard/method_list.html +0 -542
  138. data/docs/yard/top-level-namespace.html +0 -110
data/lib/servus.rb CHANGED
@@ -20,10 +20,12 @@ require_relative 'servus/config'
20
20
 
21
21
  # Support
22
22
  require_relative 'servus/support/logger'
23
+ require_relative 'servus/support/data_object'
23
24
  require_relative 'servus/support/response'
24
25
  require_relative 'servus/support/validator'
25
26
  require_relative 'servus/support/errors'
26
27
  require_relative 'servus/support/rescuer'
28
+ require_relative 'servus/support/lockdown'
27
29
  require_relative 'servus/support/message_resolver'
28
30
 
29
31
  # Events
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Scholl
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-04-30 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: active_model_serializers
@@ -27,14 +28,14 @@ dependencies:
27
28
  name: activesupport
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - "~>"
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '8.0'
33
34
  type: :runtime
34
35
  prerelease: false
35
36
  version_requirements: !ruby/object:Gem::Requirement
36
37
  requirements:
37
- - - "~>"
38
+ - - ">="
38
39
  - !ruby/object:Gem::Version
39
40
  version: '8.0'
40
41
  - !ruby/object:Gem::Dependency
@@ -55,14 +56,14 @@ dependencies:
55
56
  name: actionpack
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
- - - "~>"
59
+ - - ">="
59
60
  - !ruby/object:Gem::Version
60
61
  version: '8.0'
61
62
  type: :development
62
63
  prerelease: false
63
64
  version_requirements: !ruby/object:Gem::Requirement
64
65
  requirements:
65
- - - "~>"
66
+ - - ">="
66
67
  - !ruby/object:Gem::Version
67
68
  version: '8.0'
68
69
  description: Servus is a Ruby gem that provides a structured way to create and manage
@@ -74,113 +75,6 @@ executables: []
74
75
  extensions: []
75
76
  extra_rdoc_files: []
76
77
  files:
77
- - ".claude/commands/check-docs.md"
78
- - ".claude/commands/consistency-check.md"
79
- - ".claude/commands/fine-tooth-comb.md"
80
- - ".claude/commands/red-green-refactor.md"
81
- - ".claude/settings.json"
82
- - ".rspec"
83
- - ".rubocop.yml"
84
- - ".yardopts"
85
- - CHANGELOG.md
86
- - CLAUDE.md
87
- - IDEAS.md
88
- - LICENSE.txt
89
- - READme.md
90
- - Rakefile
91
- - docs/core/1_overview.md
92
- - docs/core/2_architecture.md
93
- - docs/core/3_service_objects.md
94
- - docs/features/1_schema_validation.md
95
- - docs/features/2_error_handling.md
96
- - docs/features/3_async_execution.md
97
- - docs/features/4_logging.md
98
- - docs/features/5_event_bus.md
99
- - docs/features/6_guards.md
100
- - docs/features/guards_naming_convention.md
101
- - docs/guides/1_common_patterns.md
102
- - docs/guides/2_migration_guide.md
103
- - docs/integration/1_configuration.md
104
- - docs/integration/2_testing.md
105
- - docs/integration/3_rails_integration.md
106
- - docs/yard/Servus.html
107
- - docs/yard/Servus/Base.html
108
- - docs/yard/Servus/Config.html
109
- - docs/yard/Servus/Extensions.html
110
- - docs/yard/Servus/Extensions/Async.html
111
- - docs/yard/Servus/Extensions/Async/Call.html
112
- - docs/yard/Servus/Extensions/Async/Errors.html
113
- - docs/yard/Servus/Extensions/Async/Errors/AsyncError.html
114
- - docs/yard/Servus/Extensions/Async/Errors/JobEnqueueError.html
115
- - docs/yard/Servus/Extensions/Async/Errors/ServiceNotFoundError.html
116
- - docs/yard/Servus/Extensions/Async/Ext.html
117
- - docs/yard/Servus/Extensions/Async/Job.html
118
- - docs/yard/Servus/Generators.html
119
- - docs/yard/Servus/Generators/ServiceGenerator.html
120
- - docs/yard/Servus/Helpers.html
121
- - docs/yard/Servus/Helpers/ControllerHelpers.html
122
- - docs/yard/Servus/Railtie.html
123
- - docs/yard/Servus/Support.html
124
- - docs/yard/Servus/Support/Errors.html
125
- - docs/yard/Servus/Support/Errors/AuthenticationError.html
126
- - docs/yard/Servus/Support/Errors/BadRequestError.html
127
- - docs/yard/Servus/Support/Errors/ForbiddenError.html
128
- - docs/yard/Servus/Support/Errors/InternalServerError.html
129
- - docs/yard/Servus/Support/Errors/NotFoundError.html
130
- - docs/yard/Servus/Support/Errors/ServiceError.html
131
- - docs/yard/Servus/Support/Errors/ServiceUnavailableError.html
132
- - docs/yard/Servus/Support/Errors/UnauthorizedError.html
133
- - docs/yard/Servus/Support/Errors/UnprocessableEntityError.html
134
- - docs/yard/Servus/Support/Errors/ValidationError.html
135
- - docs/yard/Servus/Support/Logger.html
136
- - docs/yard/Servus/Support/Rescuer.html
137
- - docs/yard/Servus/Support/Rescuer/BlockContext.html
138
- - docs/yard/Servus/Support/Rescuer/CallOverride.html
139
- - docs/yard/Servus/Support/Rescuer/ClassMethods.html
140
- - docs/yard/Servus/Support/Response.html
141
- - docs/yard/Servus/Support/Validator.html
142
- - docs/yard/Servus/Testing.html
143
- - docs/yard/Servus/Testing/ExampleBuilders.html
144
- - docs/yard/Servus/Testing/ExampleExtractor.html
145
- - docs/yard/_index.html
146
- - docs/yard/class_list.html
147
- - docs/yard/css/common.css
148
- - docs/yard/css/full_list.css
149
- - docs/yard/css/style.css
150
- - docs/yard/file.1_common_patterns.html
151
- - docs/yard/file.1_configuration.html
152
- - docs/yard/file.1_overview.html
153
- - docs/yard/file.1_schema_validation.html
154
- - docs/yard/file.2_architecture.html
155
- - docs/yard/file.2_error_handling.html
156
- - docs/yard/file.2_migration_guide.html
157
- - docs/yard/file.2_testing.html
158
- - docs/yard/file.3_async_execution.html
159
- - docs/yard/file.3_rails_integration.html
160
- - docs/yard/file.3_service_objects.html
161
- - docs/yard/file.4_logging.html
162
- - docs/yard/file.ErrorHandling.html
163
- - docs/yard/file.READme.html
164
- - docs/yard/file.architecture.html
165
- - docs/yard/file.async_execution.html
166
- - docs/yard/file.common_patterns.html
167
- - docs/yard/file.configuration.html
168
- - docs/yard/file.error_handling.html
169
- - docs/yard/file.logging.html
170
- - docs/yard/file.migration_guide.html
171
- - docs/yard/file.overview.html
172
- - docs/yard/file.rails_integration.html
173
- - docs/yard/file.schema_validation.html
174
- - docs/yard/file.service_objects.html
175
- - docs/yard/file.testing.html
176
- - docs/yard/file_list.html
177
- - docs/yard/frames.html
178
- - docs/yard/index.html
179
- - docs/yard/js/app.js
180
- - docs/yard/js/full_list.js
181
- - docs/yard/js/jquery.js
182
- - docs/yard/method_list.html
183
- - docs/yard/top-level-namespace.html
184
78
  - lib/generators/servus/event_handler/event_handler_generator.rb
185
79
  - lib/generators/servus/event_handler/templates/handler.rb.erb
186
80
  - lib/generators/servus/event_handler/templates/handler_spec.rb.erb
@@ -203,6 +97,10 @@ files:
203
97
  - lib/servus/extensions/async/errors.rb
204
98
  - lib/servus/extensions/async/ext.rb
205
99
  - lib/servus/extensions/async/job.rb
100
+ - lib/servus/extensions/lazily/call.rb
101
+ - lib/servus/extensions/lazily/errors.rb
102
+ - lib/servus/extensions/lazily/ext.rb
103
+ - lib/servus/extensions/lazily/resolver.rb
206
104
  - lib/servus/guard.rb
207
105
  - lib/servus/guards.rb
208
106
  - lib/servus/guards/falsey_guard.rb
@@ -211,7 +109,9 @@ files:
211
109
  - lib/servus/guards/truthy_guard.rb
212
110
  - lib/servus/helpers/controller_helpers.rb
213
111
  - lib/servus/railtie.rb
112
+ - lib/servus/support/data_object.rb
214
113
  - lib/servus/support/errors.rb
114
+ - lib/servus/support/lockdown.rb
215
115
  - lib/servus/support/logger.rb
216
116
  - lib/servus/support/message_resolver.rb
217
117
  - lib/servus/support/rescuer.rb
@@ -231,6 +131,7 @@ metadata:
231
131
  source_code_uri: https://github.com/zarpay/servus
232
132
  changelog_uri: https://github.com/zarpay/servus/blob/main/CHANGELOG.md
233
133
  rubygems_mfa_required: 'true'
134
+ post_install_message:
234
135
  rdoc_options: []
235
136
  require_paths:
236
137
  - lib
@@ -245,7 +146,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
146
  - !ruby/object:Gem::Version
246
147
  version: '0'
247
148
  requirements: []
248
- rubygems_version: 3.6.7
149
+ rubygems_version: 3.5.22
150
+ signing_key:
249
151
  specification_version: 4
250
152
  summary: A gem for managing service objects.
251
153
  test_files: []
@@ -1 +0,0 @@
1
- Scan the documentation in docs/ then check the current git changeset. If the changeset has modifications that might affect the documentation, then review the related documentation and make any necessary updates.
@@ -1 +0,0 @@
1
- Are the latest changes consistent with the way that similar functionality has been implemented in the rest of the codebase? #$ARGUMENTS
@@ -1 +0,0 @@
1
- We're going to go over #$ARGUMENTS with a fine-tooth comb. I want detailed explanations and no edits unless I ask for them. Start by identifying the first thing that looks wrong and explain why.
@@ -1,5 +0,0 @@
1
- During this session we will be practicing TDD in the red-green-refactor cycle. The first step in the cycle is to write a test for the smallest possible unit of functionality. Once the test is written, run the test and it should fail. This is the red phase. The next step is to write the code to make the test pass. This is the green phase. Once the test passes, the code is refactored to be more readable and maintainable. This is the refactor phase.
2
-
3
- If we get into a situation where more than one test fails, we will focus on the test that is most important to fix first. During that fix phase, we will only run the test that is failing until it passes.
4
-
5
- While we're in this mode, you will not use your TODO tool to track tasks. You will rely on me (the human user) to tell you what the next step is.
@@ -1,24 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(bundle exec rspec:*)",
5
- "Bash(bundle exec rubocop:*)",
6
- "Bash(find:*)"
7
- ],
8
- "deny": [],
9
- "ask": []
10
- },
11
- "hooks": {
12
- "PostToolUse": [
13
- {
14
- "matcher": "Write|Edit",
15
- "hooks": [
16
- {
17
- "type": "command",
18
- "command": "bundle exec rubocop -A"
19
- }
20
- ]
21
- }
22
- ]
23
- }
24
- }
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,27 +0,0 @@
1
- AllCops:
2
- NewCops: enable
3
- TargetRubyVersion: 3.3
4
- Include:
5
- - 'lib/**/*.rb'
6
- - 'spec/**/*.rb'
7
- Exclude:
8
- - 'spec/dummy/**/*'
9
- - 'vendor/bundle/**/*'
10
-
11
- Lint/ConstantDefinitionInBlock:
12
- Enabled: false
13
-
14
- Lint/ConstantReassignment:
15
- Exclude:
16
- - 'spec/**/*'
17
-
18
- Lint/MissingSuper:
19
- Exclude:
20
- - 'spec/**/*'
21
-
22
- Metrics/BlockLength:
23
- Exclude:
24
- - 'spec/**/*'
25
-
26
- Naming/PredicateMethod:
27
- Enabled: false
data/.yardopts DELETED
@@ -1,6 +0,0 @@
1
- --output-dir ./docs/yard
2
- --readme READme.md
3
- --files docs/**/*.md
4
- --markup markdown
5
- --markup-provider redcarpet
6
- --title "Servus | Service Object Framework"
data/CHANGELOG.md DELETED
@@ -1,122 +0,0 @@
1
- ## [0.2.1] - 2025-12-20
2
-
3
- ### Added
4
-
5
- - **EventHandler Scheduling Options**: Extended the `invoke` DSL to support ActiveJob scheduling options
6
- - `:wait` - delay execution (e.g., `5.minutes`)
7
- - `:wait_until` - schedule for specific time
8
- - `:priority` - job priority
9
- - `:job_options` - additional ActiveJob options
10
- - Options are passed through to `call_async`, enabling delayed and scheduled event handling
11
-
12
- - **Custom HTTP Error Classes**: Added granular error classes for HTTP status handling
13
- - Error classes for common HTTP statuses (400, 401, 403, 404, 409, 422, 429, 500, 502, 503, 504)
14
- - Each error class has appropriate `http_status` and default `code`/`message`
15
- - Enables more precise error handling and cleaner rescue blocks
16
-
17
- ## [0.2.0] - 2025-12-16
18
-
19
- ### Added
20
-
21
- - **Guards System**: Reusable validation rules with rich error responses
22
- - `Servus::Guard` base class for creating custom guards
23
- - `Servus::Guards` module included in services with `enforce_*!` and `check_*?` methods
24
- - Built-in guards:
25
- - `PresenceGuard` - validates values are present (not nil or empty)
26
- - `TruthyGuard` - validates object attributes are truthy
27
- - `FalseyGuard` - validates object attributes are falsey
28
- - `StateGuard` - validates object attributes match expected value(s)
29
- - Guards auto-define methods when classes inherit from `Servus::Guard`
30
- - Guard DSL: `http_status`, `error_code`, `message` with interpolation support
31
- - Multiple message template formats: String, I18n Symbol, inline Hash, Proc
32
- - Rails auto-loading from `app/guards/*_guard.rb`
33
- - Configuration options: `guards_dir`, `include_default_guards`
34
-
35
- - **GuardError**: New error class for guard validation failures
36
- - Custom `code` and `http_status` per guard
37
- - Services catch `:guard_failure` and wrap in failure response automatically
38
-
39
- ### Changed
40
-
41
- - **Error API Refactored**: Cleaner separation of HTTP status and error body
42
- - All errors now have `http_status` method returning Rails status symbol
43
- - `api_error` returns `{ code:, message: }` for response body only
44
- - Follows community conventions (Stripe, JSON:API) where HTTP status is in header
45
-
46
- - **Controller Helpers Refactored**:
47
- - Renamed `render_service_object_error` to `render_service_error`
48
- - Now takes error object directly instead of `api_error` hash
49
- - Response format: `{ error: { code:, message: } }` with status from `error.http_status`
50
-
51
- ### Breaking Changes
52
-
53
- - `render_service_object_error` renamed to `render_service_error`
54
- - `render_service_error` now accepts error object, not hash: `render_service_error(result.error)` instead of `render_service_error(result.error.api_error)`
55
- - Error response JSON structure changed from `{ code:, message: }` to `{ error: { code:, message: } }`
56
-
57
- ## [0.1.6] - 2025-12-06
58
-
59
- ### Fixed
60
-
61
- - Make `emit_events_for` public in `Servus::Events::Emitter` to allow external event emission
62
-
63
- ## [0.1.5] - 2025-12-03
64
-
65
- ### Added
66
-
67
- - **Event Bus Architecture**: Introduced event-driven architecture for decoupling service logic from side effects
68
- - `Servus::EventHandler` base class for creating event handlers that subscribe to events and invoke services
69
- - `emits` DSL on `Servus::Base` for declaring events that fire on `:success`, `:failure`, or `:error!`
70
- - `Servus::Events::Bus` for routing events to handlers via ActiveSupport::Notifications
71
- - Rails generator: `rails g servus:event_handler event_name` creates handler and spec files
72
- - Event handlers auto-load from `app/events/` directory in Rails applications
73
-
74
- - **Event Payload Validation**: JSON Schema validation for event payloads
75
- - `schema payload: {...}` DSL on EventHandler for declaring payload schemas
76
- - Validation occurs when events are emitted via `EventHandler.emit(payload)`
77
-
78
- - **Event Testing Matchers**: RSpec matchers for testing event emission
79
- - `emit_event(:event_name)` matcher to assert events are emitted
80
- - `emit_event(:event_name).with(payload)` for payload assertions
81
- - `call_service(ServiceClass).with(args)` matcher for handler testing
82
- - `call_service(ServiceClass).async` for async invocation testing
83
-
84
- - **Configuration Options**: New and updated configuration settings
85
- - `config.schemas_dir` - Directory for JSON schema files (default: `app/schemas`)
86
- - `config.services_dir` - Directory for service files (default: `app/services`)
87
- - `config.events_dir` - Directory for event handlers (default: `app/events`)
88
- - `config.strict_event_validation` - Validate handlers subscribe to emitted events (default: `true`)
89
- - `Servus::EventHandler.validate_all_handlers!` for CI validation of handler-event mappings
90
-
91
- - **Generator Improvements**: Enhanced service and event handler generators
92
- - Service templates now include comprehensive YARD documentation
93
- - Service spec templates include example test patterns
94
- - JSON schema templates include proper structure with `$schema` reference
95
- - Event handler templates include full documentation and examples
96
- - `--no-docs` flag to skip documentation comments in generated files
97
-
98
- ### Changed
99
-
100
- - Updated execution flow to include event emission after result validation
101
- - Enhanced Railtie to auto-load event handlers and clear the event bus on reload in development
102
-
103
- ## [0.1.4] - 2025-11-21
104
- - Added: Test helpers (`servus_arguments_example` and `servus_result_example`) to extract example values from schemas for testing
105
- - Added: YARD documentation configuration with README homepage and markdown file support
106
- - Added: Added `schema` DSL method for cleaner schema definition. Supports `schema arguments: {...}, result: {...}` syntax. Fully backwards compatible with existing `ARGUMENTS_SCHEMA` and `RESULT_SCHEMA` constants.
107
- - Added: Added support from blocks on `rescue_from` to override default failure handler.
108
- - Fixed: YARD link resolution warnings in documentation
109
-
110
- ## [0.1.3] - 2025-10-10
111
- - Added: Added `call_async` method to `Servus::Base` to enqueue a job for calling the service asynchronously
112
- - Added: Added `Async::Job` to handle async enqueing with support for ActiveJob set options
113
-
114
- ## [0.1.1] - 2025-08-20
115
-
116
- - Added: Added `rescue_from` method to `Servus::Base` to rescue from standard errors and use custom error types.
117
- - Added: Added `run_service` and `render_service_object_error` helpers to `Servus::Helpers::ControllerHelpers`.
118
- - Fixed: All rubocop warnings.
119
-
120
- ## [0.1.0] - 2025-04-28
121
-
122
- - Initial release
data/CLAUDE.md DELETED
@@ -1,10 +0,0 @@
1
- Before starting a session, always review the latest docs in the following order:
2
-
3
- 1. `/docs/core/**/*.md`
4
- 2. `/docs/features/**/*.md`
5
- 3. `/docs/guides/**/*.md`
6
- 4. `/docs/integration/**/*.md`
7
-
8
- Focus on writing code consistent with the rest of the project. Use existing files as references for conventions and style.
9
-
10
- Ensure new code always encludes world class YARD documentation. If documentation looks out of date or incomplete, suggest a relevant edit.
data/IDEAS.md DELETED
@@ -1,5 +0,0 @@
1
- 1. Make sure Async Jobs don't retry when the job class cant be constantized.
2
-
3
- 2. Improve error handling with an error registry that can be referenced by codes as opposed to fully qualified class names.
4
-
5
- 3. Update generators to not make schema files and instead add schemas to schema: method in generators.
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2025 Sebastian Scholl
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.