service_core 0.2.0 → 1.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +19 -2
- data/.tool-versions +1 -0
- data/Appraisals +19 -0
- data/CHANGELOG.md +79 -1
- data/README.md +186 -220
- data/Rakefile +0 -2
- data/gemfiles/rails_7.2.gemfile +18 -0
- data/gemfiles/rails_8.0.gemfile +18 -0
- data/gemfiles/rails_8.1.gemfile +18 -0
- data/lib/service_core/base.rb +32 -26
- data/lib/service_core/errors.rb +11 -0
- data/lib/service_core/field_set.rb +21 -0
- data/lib/service_core/logger.rb +0 -2
- data/lib/service_core/output.rb +15 -13
- data/lib/service_core/responder.rb +38 -0
- data/lib/service_core/response.rb +95 -22
- data/lib/service_core/step_validation.rb +24 -28
- data/lib/service_core/version.rb +1 -3
- data/lib/service_core.rb +3 -4
- metadata +20 -15
- data/.byebug_history +0 -71
- data/sig/service_core.rbs +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9e82b7404a555e1d2b60d559e82b3f37a2cfe829ad947687f5e290252b87712
|
|
4
|
+
data.tar.gz: a170ee5ab04fe57be88786b027b07ca1db31732fa316eafb0a36b10c827c078c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a109447da13844396e83db86186849598c0ad4b55b845d07fb6c8c1592aa7a10dc69b135cd84785b407588580871470bf94132158e60c2b237b7a05fdd099ff
|
|
7
|
+
data.tar.gz: b2a495f969e193f7f6a9403c32fd88cf7586f49150268d61bbb600ea565ed039107aa1edc119cf8c5ebc37614f303a10471230292294c420930d3f19241c6539
|
data/.rubocop.yml
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-rake
|
|
3
|
+
|
|
1
4
|
require:
|
|
2
5
|
- rubocop-rspec
|
|
3
6
|
|
|
4
7
|
AllCops:
|
|
5
|
-
TargetRubyVersion:
|
|
8
|
+
TargetRubyVersion: 3.1
|
|
6
9
|
NewCops: enable
|
|
10
|
+
SuggestExtensions: false
|
|
11
|
+
Exclude:
|
|
12
|
+
- "gemfiles/**/*"
|
|
13
|
+
- "vendor/**/*"
|
|
7
14
|
|
|
8
15
|
Style/StringLiterals:
|
|
9
16
|
Enabled: true
|
|
10
17
|
EnforcedStyle: double_quotes
|
|
11
18
|
|
|
19
|
+
# Per project style, frozen_string_literal magic comments are not used.
|
|
20
|
+
Style/FrozenStringLiteralComment:
|
|
21
|
+
Enabled: false
|
|
22
|
+
|
|
12
23
|
Style/StringLiteralsInInterpolation:
|
|
13
24
|
Enabled: true
|
|
14
25
|
EnforcedStyle: double_quotes
|
|
@@ -32,4 +43,10 @@ RSpec/MessageSpies:
|
|
|
32
43
|
Enabled: false
|
|
33
44
|
|
|
34
45
|
RSpec/VerifiedDoubleReference:
|
|
35
|
-
Enabled: false
|
|
46
|
+
Enabled: false
|
|
47
|
+
|
|
48
|
+
# add_error_and_validate is part of the public API and intentionally returns
|
|
49
|
+
# the boolean result of valid?, but its name describes the action it performs.
|
|
50
|
+
Naming/PredicateMethod:
|
|
51
|
+
AllowedMethods:
|
|
52
|
+
- add_error_and_validate
|
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 3.4.9
|
data/Appraisals
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Each appraisal pins ActiveModel/ActiveSupport to a maintained Rails release.
|
|
2
|
+
# Older Rails versions (6.1, 7.0, 7.1) are still permitted by the gemspec
|
|
3
|
+
# floor but are not exercised here because their upstream support window
|
|
4
|
+
# has ended.
|
|
5
|
+
|
|
6
|
+
appraise "rails-7.2" do
|
|
7
|
+
gem("activemodel", "~> 7.2.0")
|
|
8
|
+
gem("activesupport", "~> 7.2.0")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
appraise "rails-8.0" do
|
|
12
|
+
gem("activemodel", "~> 8.0.0")
|
|
13
|
+
gem("activesupport", "~> 8.0.0")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
appraise "rails-8.1" do
|
|
17
|
+
gem("activemodel", "~> 8.1.0")
|
|
18
|
+
gem("activesupport", "~> 8.1.0")
|
|
19
|
+
end
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
1
8
|
## [Unreleased]
|
|
2
9
|
|
|
10
|
+
## [1.0.0] - 2026-05-14
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `ServiceCore::Response`: a Hash-compatible value object backing
|
|
15
|
+
`service.response` / `service.output` and the return of `#call`. Adds
|
|
16
|
+
named accessors (`response.status`, `response.data`, `response.message`,
|
|
17
|
+
`response.errors`), Hash-style `[]` / `[]=` / `==`, `dig`, `fetch`,
|
|
18
|
+
`each_pair`, and `as_json` / `to_json`. Callers that previously
|
|
19
|
+
reached for `service.output[:key]` on the 0.1.0 Hash output continue
|
|
20
|
+
to work unchanged.
|
|
21
|
+
- `service.response` as an alias for `service.output`.
|
|
22
|
+
- `ServiceCore::FieldSet`: an immutable snapshot for `service.fields`.
|
|
23
|
+
Each declared symbol field is exposed as a real method (e.g.
|
|
24
|
+
`service.fields.first_name`); call `to_h` for a plain Hash.
|
|
25
|
+
- `field` raises `ServiceCore::ReservedFieldName` when the declared name
|
|
26
|
+
would shadow a ServiceCore method. The reserved names are `:call`,
|
|
27
|
+
`:errors`, `:fields`, `:output`, `:perform` and `:response`. Previously
|
|
28
|
+
these names silently overrode gem internals (most dangerously
|
|
29
|
+
`:errors`, which broke `ActiveModel::Validations`).
|
|
30
|
+
- `ServiceCore::Error` hierarchy with concrete subclasses
|
|
31
|
+
`ServiceCore::InvalidKey` (raised by `Response#[]` / `[]=` on a
|
|
32
|
+
non-allowed key) and `ServiceCore::ReservedFieldName`. `Error` itself
|
|
33
|
+
existed since 0.1.0 but was never raised; `rescue ServiceCore::Error`
|
|
34
|
+
now actually catches things.
|
|
35
|
+
- Cross-Rails test matrix via `appraisal`: Rails 7.2, 8.0 and 8.1.
|
|
36
|
+
- CI matrix across Ruby 3.3, 3.4 and 4.0 (excluding Ruby 4.0 + Rails 7.2).
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- The mixin that provides `success_response`, `error_response` and
|
|
41
|
+
`formatted_response` is renamed from `ServiceCore::Response` to
|
|
42
|
+
`ServiceCore::Responder`. The `Response` name now refers to the value
|
|
43
|
+
object; the `Responder` mixin is the builder. Both modules are internal
|
|
44
|
+
implementation details consumed via `include ServiceCore`, so users
|
|
45
|
+
who only ever `include ServiceCore` are unaffected. Anyone including
|
|
46
|
+
`ServiceCore::Response` directly must switch to
|
|
47
|
+
`include ServiceCore::Responder`.
|
|
48
|
+
- Gemspec: `required_ruby_version` raised to `>= 3.1.0` (Ruby 2.7 and 3.0 are EOL).
|
|
49
|
+
- Gemspec: ActiveModel / ActiveSupport range widened to `>= 6.1, < 9.0`.
|
|
50
|
+
- RuboCop bumped to `~> 1.86` with `rubocop-rake` added as a plugin.
|
|
51
|
+
- Replaced `byebug` (unmaintained on Ruby 3+) with the stdlib `debug` gem.
|
|
52
|
+
- Removed `# frozen_string_literal: true` magic comments project-wide in
|
|
53
|
+
favour of the project style; `VERSION` is now explicitly `.freeze`d.
|
|
54
|
+
- `add_error_and_validate` now forwards its `options` argument to
|
|
55
|
+
`add_error` (and through to `ActiveModel::Errors#add`), matching its
|
|
56
|
+
declared signature.
|
|
57
|
+
- Internal cleanups: `Output#initialize` now calls `super()`, the
|
|
58
|
+
`StepValidation` validator helpers are private, and `auto_assign_status`
|
|
59
|
+
no longer has the redundant elsif clauses.
|
|
60
|
+
- The class-level `fields_defined` registry is renamed to `field_names`
|
|
61
|
+
and is now a `Set` of declared names rather than a Hash mapping names
|
|
62
|
+
to defaults. Typed defaults are still applied through
|
|
63
|
+
`ActiveModel::Attributes`; the old Hash was a Set with a confusing
|
|
64
|
+
name and shape.
|
|
65
|
+
- `service.fields` no longer behaves like a Hash. The new `FieldSet`
|
|
66
|
+
exposes named accessors plus `to_h`. Callers that did
|
|
67
|
+
`service.fields[:name]` should use `service.fields.name`; iteration
|
|
68
|
+
goes through `service.fields.to_h.each`.
|
|
69
|
+
|
|
70
|
+
### Fixed
|
|
71
|
+
|
|
72
|
+
- `Output#set_output` no longer drops legitimate falsy values. Previously
|
|
73
|
+
`false`, `0`, and `""` were silently discarded; only `nil` is now skipped.
|
|
74
|
+
- `Responder#formatted_response` no longer gates its writes on
|
|
75
|
+
ActiveSupport `present?`. `success_response(data: false)` now records
|
|
76
|
+
`data: false`.
|
|
77
|
+
- `Base.field` no longer swallows positional defaults of `false` or `nil`.
|
|
78
|
+
The arity of the positional arguments is used instead of `||`, so
|
|
79
|
+
`field :enabled, :boolean, false` actually defaults to `false`.
|
|
80
|
+
|
|
3
81
|
## [0.1.0] - 2024-07-17
|
|
4
82
|
|
|
5
|
-
- Initial release
|
|
83
|
+
- Initial release.
|