convenient_service 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gem_release.yml +0 -12
- data/.github/issue_template.md +35 -0
- data/.github/pull_request_template.md +31 -0
- data/.github/workflows/cd.yml +15 -2
- data/.github/workflows/ci.yml +6 -6
- data/CHANGELOG.md +27 -0
- data/README.md +12 -3
- data/ROADMAP.md +22 -8
- data/Taskfile.yml +5 -13
- data/env.rb +4 -0
- data/lib/convenient_service/common/plugins/caches_return_value/middleware.rb +17 -2
- data/lib/convenient_service/common/plugins/caches_return_value.rb +0 -1
- data/lib/convenient_service/common/plugins/has_constructor/concern.rb +13 -0
- data/lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb +27 -0
- data/lib/convenient_service/common/plugins/has_constructor_without_initialize.rb +3 -0
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/concern.rb +8 -4
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache.rb +0 -1
- data/lib/convenient_service/common/plugins.rb +1 -0
- data/lib/convenient_service/configs/standard.rb +16 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/commands/cast_container.rb +0 -2
- data/lib/convenient_service/dependencies.rb +1 -0
- data/lib/convenient_service/examples/dry/gemfile/dry_service/config.rb +3 -1
- data/lib/convenient_service/examples/dry/gemfile/services/assert_file_exists.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile/services/assert_file_not_empty.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile/services/assert_npm_package_available.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile/services/parse_content.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile/services/print_shell_command.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile/services/read_file_content.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile/services/run_shell.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile/services/strip_comments.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile.rb +5 -4
- data/lib/convenient_service/examples/rails/gemfile/rails_service/config.rb +3 -1
- data/lib/convenient_service/examples/rails/gemfile.rb +5 -4
- data/lib/convenient_service/examples/standard/cowsay/services/build_cloud.rb +42 -0
- data/lib/convenient_service/examples/standard/cowsay/services/build_cow.rb +38 -0
- data/lib/convenient_service/examples/standard/cowsay/services/print.rb +32 -0
- data/lib/convenient_service/examples/standard/cowsay/services.rb +5 -0
- data/lib/convenient_service/examples/standard/cowsay.rb +24 -0
- data/lib/convenient_service/examples/standard/gemfile/services/format.rb +2 -0
- data/lib/convenient_service/examples/standard/gemfile.rb +5 -4
- data/lib/convenient_service/rspec/helpers/custom/stub_service/entities/result_spec.rb +96 -7
- data/lib/convenient_service/rspec/helpers/custom/wrap_method/entities/wrapped_method.rb +44 -8
- data/lib/convenient_service/rspec/helpers/custom/wrap_method/errors.rb +11 -9
- data/lib/convenient_service/rspec/matchers/custom/cache_its_value.rb +7 -7
- data/lib/convenient_service/rspec/matchers/custom/call_chain_next.rb +2 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to.rb +50 -12
- data/lib/convenient_service/rspec/matchers/custom/results/be_success.rb +6 -0
- data/lib/convenient_service/service/plugins/aliases.rb +1 -0
- data/lib/convenient_service/service/plugins/has_inspect/concern.rb +23 -0
- data/lib/convenient_service/service/plugins/has_inspect.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/commands/create_result_class.rb +10 -0
- data/lib/convenient_service/service/plugins/has_result/concern/class_methods.rb +23 -14
- data/lib/convenient_service/service/plugins/has_result/concern/instance_methods.rb +17 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/concern.rb +4 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_inspect/concern.rb +31 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_inspect.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands/cast_jsend_attributes.rb +37 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/concern/instance_methods.rb +127 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/concern.rb +27 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/code/class_methods.rb +34 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/code.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data/class_methods.rb +32 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message/class_methods.rb +34 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message.rb +45 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status/class_methods.rb +34 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb +73 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/{entities.rb → plugins/has_jsend_status_and_attributes/entities.rb} +0 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/errors.rb +29 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/middleware.rb +31 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs/jsend_attributes.rb +21 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes.rb +8 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins.rb +2 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result.rb +0 -4
- data/lib/convenient_service/service/plugins/has_result_method_steps/middleware.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result_method_steps/services/method_step_config.rb +30 -4
- data/lib/convenient_service/service/plugins/has_result_params_validations/using_dry_validation/middleware.rb +19 -9
- data/lib/convenient_service/service/plugins/has_result_status_check_short_syntax/concern.rb +63 -0
- data/lib/convenient_service/service/plugins/has_result_status_check_short_syntax.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_steps/concern.rb +2 -1
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/has_inspect/concern.rb +31 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/has_inspect.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step.rb +1 -0
- data/lib/convenient_service/service/plugins/has_result_steps/middleware.rb +1 -1
- data/lib/convenient_service/service/plugins.rb +2 -0
- data/lib/convenient_service/support/cache/key.rb +100 -0
- data/lib/convenient_service/support/cache.rb +131 -0
- data/lib/convenient_service/support/copyable.rb +3 -2
- data/lib/convenient_service/support/delegate.rb +3 -2
- data/lib/convenient_service/support.rb +1 -0
- data/lib/convenient_service/version.rb +1 -1
- data/logo.png +0 -0
- metadata +40 -21
- data/lib/convenient_service/common/plugins/caches_return_value/entities/key.rb +0 -79
- data/lib/convenient_service/common/plugins/caches_return_value/entities.rb +0 -3
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/entities/cache.rb +0 -81
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/entities.rb +0 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/commands/cast_result_params.rb +0 -33
- data/lib/convenient_service/service/plugins/has_result/entities/result/commands.rb +0 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/concern/instance_methods.rb +0 -64
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/code/class_methods.rb +0 -30
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/code.rb +0 -45
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/data/class_methods.rb +0 -28
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/data.rb +0 -45
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/message/class_methods.rb +0 -30
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/message.rb +0 -41
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/status/class_methods.rb +0 -30
- data/lib/convenient_service/service/plugins/has_result/entities/result/entities/status.rb +0 -69
- data/lib/convenient_service/service/plugins/has_result/entities/result/errors.rb +0 -25
- data/lib/convenient_service/service/plugins/has_result/entities/result/structs/result_params.rb +0 -17
- data/lib/convenient_service/service/plugins/has_result/entities/result/structs.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70d36eabeb3ea9598979a7158d06e0bfc627398066abc5180411f13fce9142e8
|
4
|
+
data.tar.gz: 6c6ea0ce690bb915c32f2e810afe70f87e74961f7a3c01b4e3a6389b8f98b1dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa610f3ac041e97849914d6bf15e626cceef9d8abd9aed0e5244b112595c89c9ac1eb91438bf67a84065bc8b90e91ebd8fff19cbcfb3c4a77e9b1246100b25fd
|
7
|
+
data.tar.gz: d704307543e1a14efa13f2701a109ee2748af75ed2260bbf9e4e64bc06b5bbe2a23ac208eabea1ec2d536578c9b9ec97c76541fa79181b9e896f4f844594d743
|
data/.gem_release.yml
CHANGED
@@ -1,17 +1,5 @@
|
|
1
1
|
quiet: false
|
2
2
|
|
3
|
-
##
|
4
|
-
# NOTE: `bump` options.
|
5
|
-
# https://github.com/svenfuchs/gem-release#gem-bump
|
6
|
-
#
|
7
|
-
bump:
|
8
|
-
file: ./lib/convenient_service/version.rb
|
9
|
-
message: 🎉 🎉 🎉 Release %{version} 🎉 🎉 🎉
|
10
|
-
recurse: false
|
11
|
-
release: true
|
12
|
-
sign: true
|
13
|
-
tag: true
|
14
|
-
|
15
3
|
##
|
16
4
|
# NOTE: `release` options.
|
17
5
|
# https://github.com/svenfuchs/gem-release#gem-release
|
@@ -0,0 +1,35 @@
|
|
1
|
+
## What is the issue?
|
2
|
+
<!--- Briefly describe the problem -->
|
3
|
+
|
4
|
+
-
|
5
|
+
|
6
|
+
## When it happens? How to reproduce it?
|
7
|
+
<!--- Tell us how to reproduce the problem. You can write a step-by-step guide, for example -->
|
8
|
+
|
9
|
+
-
|
10
|
+
|
11
|
+
## Where it happens?
|
12
|
+
<!--- Point to the file/loc which causes inconsistent behaviour -->
|
13
|
+
|
14
|
+
-
|
15
|
+
|
16
|
+
## How big is the damage from it?
|
17
|
+
|
18
|
+
-
|
19
|
+
|
20
|
+
## Why it happens?
|
21
|
+
|
22
|
+
-
|
23
|
+
|
24
|
+
## What can be done to resolve it?
|
25
|
+
|
26
|
+
-
|
27
|
+
|
28
|
+
## What is the complexity of a possible fix?
|
29
|
+
|
30
|
+
-
|
31
|
+
|
32
|
+
## Notes
|
33
|
+
<!--- Additional info, links, screenshots, actually anything that helps to recreate the way of thoughts (optional). -->
|
34
|
+
|
35
|
+
-
|
@@ -0,0 +1,31 @@
|
|
1
|
+
## What was done as a part of this PR?
|
2
|
+
<!--- Describe your changes -->
|
3
|
+
|
4
|
+
-
|
5
|
+
|
6
|
+
## Why it was done?
|
7
|
+
<!--- Why is this change required? Does it improve something? What problem does it solve? -->
|
8
|
+
<!--- If it fixes an open issue, please link to the issue here. -->
|
9
|
+
|
10
|
+
-
|
11
|
+
|
12
|
+
## How it was done?
|
13
|
+
<!--- Useful when a solution is not obvious (seems too extraordinary or too heavy) for a team you work with (optional). -->
|
14
|
+
|
15
|
+
-
|
16
|
+
|
17
|
+
## How to test?
|
18
|
+
|
19
|
+
- `task rspec -- corresponding_spec.rb`
|
20
|
+
- [Development: Local Development#tests](https://github.com/marian13/convenient_service/wiki/Development:-Local-Development#tests).
|
21
|
+
|
22
|
+
## Notes
|
23
|
+
<!--- Additional info, links, screenshots, actually anything that helps to recreate the way of thoughts (optional). -->
|
24
|
+
|
25
|
+
-
|
26
|
+
|
27
|
+
## Checklist:
|
28
|
+
|
29
|
+
- [ ] I have performed a self-review of my code.
|
30
|
+
- [ ] I have added/adjusted tests that prove my fix is effective or that my feature works.
|
31
|
+
- [ ] CI is green.
|
data/.github/workflows/cd.yml
CHANGED
@@ -22,9 +22,9 @@ on:
|
|
22
22
|
- main
|
23
23
|
|
24
24
|
jobs:
|
25
|
-
|
25
|
+
deploy_api_docs:
|
26
26
|
runs-on: ubuntu-20.04
|
27
|
-
name: Deploy
|
27
|
+
name: Deploy API Docs
|
28
28
|
steps:
|
29
29
|
- uses: actions/checkout@v2
|
30
30
|
- name: Set up Ruby
|
@@ -52,3 +52,16 @@ jobs:
|
|
52
52
|
with:
|
53
53
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
54
54
|
publish_dir: ./docs
|
55
|
+
|
56
|
+
create_github_release:
|
57
|
+
runs-on: ubuntu-20.04
|
58
|
+
name: Create GitHub Release PR
|
59
|
+
steps:
|
60
|
+
- uses: google-github-actions/release-please-action@v3
|
61
|
+
with:
|
62
|
+
changelog-path: CHANGELOG.md
|
63
|
+
default-branch: main
|
64
|
+
include-v-in-tag: true
|
65
|
+
package-name: convenient_service
|
66
|
+
release-type: ruby
|
67
|
+
version-file: lib/convenient_service/version.rb
|
data/.github/workflows/ci.yml
CHANGED
@@ -128,14 +128,14 @@ jobs:
|
|
128
128
|
run: task rspec:standard
|
129
129
|
- name: Install dependencies for appraisals
|
130
130
|
run: task deps:install
|
131
|
-
- name: Run RSpec with Rails 5.2
|
132
|
-
run: task rspec:rails_5.2
|
133
|
-
- name: Run RSpec with Rails 6.0
|
134
|
-
run: task rspec:rails_6.0
|
135
|
-
- name: Run RSpec with Rails 6.1
|
136
|
-
run: task rspec:rails_6.1
|
137
131
|
- name: Run RSpec with Rails 7.0
|
138
132
|
run: task rspec:rails_7.0
|
133
|
+
- name: Run RSpec with Rails 6.1
|
134
|
+
run: task rspec:rails_6.1
|
135
|
+
- name: Run RSpec with Rails 6.0
|
136
|
+
run: task rspec:rails_6.0
|
137
|
+
- name: Run RSpec with Rails 5.2
|
138
|
+
run: task rspec:rails_5.2
|
139
139
|
- name: Run RSpec with Dry
|
140
140
|
run: task rspec:dry
|
141
141
|
##
|
data/CHANGELOG.md
CHANGED
@@ -1 +1,28 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [0.2.1](https://github.com/marian13/convenient_service/compare/v0.2.0...v0.2.1) (2022-12-14)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* **has_result_steps:** return step copy to have fresh state ([55cc368](https://github.com/marian13/convenient_service/commit/55cc368484641040c0c76ecb38872cc9a268397c), [fc7cebb](https://github.com/marian13/convenient_service/commit/fc7cebb4e159af7b35eac3cf8c25c7009e14c9d1))
|
9
|
+
* **standard:** place UsingActiveModelValidations before HasResultSteps ([4c43205](https://github.com/marian13/convenient_service/commit/4c43205382da2e7ae395fea6639c2bcc43d1eec2))
|
10
|
+
* **standard:** place UsingDryValidation before HasResultSteps ([63c31c0](https://github.com/marian13/convenient_service/commit/63c31c04ac7c2581defd3557aad13db3188806ba))
|
11
|
+
|
12
|
+
## [0.2.0](https://github.com/marian13/convenient_service/compare/v0.1.0...v0.2.0) (2022-11-26)
|
13
|
+
|
14
|
+
|
15
|
+
### Features
|
16
|
+
|
17
|
+
* **be_success:** add without_data chaining ([e1c7a7e](https://github.com/marian13/convenient_service/commit/e1c7a7e534b4c8c112b343a3318177d69f7ad06d))
|
18
|
+
* **has_constructor_without_initialize:** introduce .create_without_initialize ([b0835aa](https://github.com/marian13/convenient_service/commit/b0835aaae46820b47ecc57887613acd8599c1908))
|
19
|
+
* **has_constructor:** introduce .create ([2cc450b](https://github.com/marian13/convenient_service/commit/2cc450bd529596ac8e2fda3d26c2e0b1d4fad959))
|
20
|
+
* **has_inspect:** indroduce inspect for Service and Result ([c3815c8](https://github.com/marian13/convenient_service/commit/c3815c8d25f47d8f2457ccfbad8660a930e32da1))
|
21
|
+
* **has_inspect:** introduce HasInspect for Step ([6a6ada7](https://github.com/marian13/convenient_service/commit/6a6ada73962ea96f5e9c40d62e87d91a1e09b961))
|
22
|
+
* **has_inspect:** introduce inspect for Service and Result ([7c9fe0e](https://github.com/marian13/convenient_service/commit/7c9fe0e4a7aedfcaff1e717f99a934d2fab4c03b))
|
23
|
+
* **has_result_status_check_short_syntax:** add ability to use short bool result check ([14909c5](https://github.com/marian13/convenient_service/commit/14909c584164a2bd130f788fa48e76edd3c7a758))
|
24
|
+
* **standard:** use HasConstructorWithoutInitialize ([b16232c](https://github.com/marian13/convenient_service/commit/b16232c88fe75028531cd7e834fb59fece49d122))
|
25
|
+
* **wrap_method:** add ability to reset wrapped method ([ae01aa8](https://github.com/marian13/convenient_service/commit/ae01aa825dcf0d06b2abdc693331dccb65d95d6b))
|
26
|
+
|
27
|
+
|
1
28
|
## 0.1.0
|
data/README.md
CHANGED
@@ -29,8 +29,6 @@
|
|
29
29
|
|
30
30
|
<!-- general_description:start -->
|
31
31
|
Yet another approach to revisit the service object pattern, but this time focusing on the unique, opinionated features.
|
32
|
-
|
33
|
-
\* Logo is downloaded from [CuteWallpaper.org](https://cutewallpaper.org/24/cartoon-diamond-png/2703010921.html). It will be replaced later.
|
34
32
|
<!-- general_description:end -->
|
35
33
|
|
36
34
|
<!-- warning:start -->
|
@@ -47,9 +45,20 @@ This library is under heavy development. Public API may be subject to change. Th
|
|
47
45
|
|
48
46
|
- Have a look at [Convenient Service Development Wiki](https://github.com/marian13/convenient_service/wiki) if you consider making a contribution.
|
49
47
|
|
50
|
-
|
48
|
+
- [API docs](https://marian13.github.io/convenient_service/).
|
49
|
+
|
51
50
|
<!-- documentation:end -->
|
52
51
|
|
52
|
+
## Links
|
53
|
+
|
54
|
+
<!-- links:start -->
|
55
|
+
- [RubyGems](https://rubygems.org/gems/convenient_service).
|
56
|
+
|
57
|
+
- [Official User Docs Source](https://github.com/marian13/convenient_service_docs).
|
58
|
+
<!-- links:end -->
|
59
|
+
|
60
|
+
---
|
61
|
+
|
53
62
|
<!-- author:start -->
|
54
63
|
Copyright (c) 2022 [Marian Kostyk](http://mariankostyk.com).
|
55
64
|
<!-- author:end -->
|
data/ROADMAP.md
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
| - | - | - | - |
|
5
5
|
| High | ✅ | 100% coverage of `Core` | |
|
6
6
|
| Medium | 🚧 | Type signatures for the whole codebase ([Yard @param, @overload, @return](https://rubydoc.info/gems/yard/file/docs/Tags.md#taglist)) | |
|
7
|
-
| Medium |
|
8
|
-
| Medium |
|
7
|
+
| Medium | ✅ | `Service.success?` shortcut for `Service.result.success?` | |
|
8
|
+
| Medium | ✅ | Release `v0.1.0` with a warning that lib is still under heavy development | |
|
9
9
|
| Medium | 🚧 | [Active Record transaction](https://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html) examples | |
|
10
|
+
| Medium | 🚧 | [Rails Current Attributes integration](https://api.rubyonrails.org/classes/ActiveSupport/CurrentAttributes.html) to cache repeated results | |
|
10
11
|
| Low | 🚧 | [Capybara](https://github.com/teamcapybara/capybara) examples | |
|
11
|
-
| Low | 🚧 | [Thread.current](https://ruby-doc.org/core-3.1.2/Thread.html#method-c-current) to cache repetable nested steps during an organizer invocation | |
|
12
12
|
| Medium | 🚧 | Inline step sequence | |
|
13
13
|
| High | 🚧 | Move callbacks to internals | |
|
14
14
|
| Low | 🚧 | Create an example of `id_or_record` [attribute](https://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html) |
|
@@ -17,7 +17,7 @@
|
|
17
17
|
| High | ✅ | `respond_to_missing?` | [ConvenientService::Core::ClassMethods#respond_to_missing?](https://github.com/marian13/convenient_service/blob/main/lib/convenient_service/core/class_methods.rb#L105), [ConvenientService::Core::InstanceMethods#respond_to_missing?](https://github.com/marian13/convenient_service/blob/main/lib/convenient_service/core/instance_methods.rb#L30) |
|
18
18
|
| High | ⏳ | Custom matcher to track `ConvenientService::Logger` messages | |
|
19
19
|
| Medium | 🚧 | Remove `respond_to?` from `Copyable` | Investigate before making any decision |
|
20
|
-
| High | 🚧 | Unified `inspect` | |
|
20
|
+
| High | 🚧 | Unified `inspect` | Remove `internals` from inspect, ivars wrapperd by double underscore |
|
21
21
|
| High | ✅ | Remove race condition for `method_missing` | https://github.com/marian13/convenient_service/pull/5 |
|
22
22
|
| High | ✅ | Remove incompatiility of [Module#include](https://gist.github.com/marian13/9c25041f835564e945d978839097d419) | https://github.com/marian13/convenient_service/pull/3 |
|
23
23
|
| Medium | ✅ | Split `Utils` specs into separate files | [convenient_service/spec/lib/convenient_service/utils](https://github.com/marian13/convenient_service/tree/main/spec/lib/convenient_service/utils) |
|
@@ -25,7 +25,6 @@
|
|
25
25
|
| Medium | ✅ | Rename `Utils::Module.find_own_const` to `Utils::Module.get_own_const` | [ConvenientService::Utils::Module::GetOwnConst](https://github.com/marian13/convenient_service/blob/main/lib/convenient_service/utils/module/get_own_const.rb) |
|
26
26
|
| Medium | 🚧 | Mark `@api private` methods, classes | [YARD Tags](https://www.rubydoc.info/gems/yard/file/docs/Tags.md) |
|
27
27
|
| Medium | ✅ | A way to check if block has one required positional argument | [#proc_has_one_positional_argument?](https://github.com/marian13/convenient_service/blob/main/lib/convenient_service/utils/proc/exec_config.rb#L96) |
|
28
|
-
| Medium | 🚧 | Factories for POROs in specs | |
|
29
28
|
| Low | 🚧 | Define method middleware caller with visibility | |
|
30
29
|
| Low | 🚧 | Dependency containers to remove high coupling | |
|
31
30
|
| Low | 🚧 | Measure performance | |
|
@@ -33,9 +32,24 @@
|
|
33
32
|
| High | 🚧 | Optimize `stack.dup` in `MethodMiddlewares#call` | Core v3 |
|
34
33
|
| Medium | 🚧 | Make a decision of what to do with `printable_block` in custom RSpec matchers | |
|
35
34
|
| Medium | 🚧 | User-friendly exception messages | |
|
36
|
-
| High | 🚧 | Factories for POROs ❗❗❗ | |
|
35
|
+
| High | 🚧 | Factories for POROs in specs ❗❗❗ | Start with `result_class`, `class self::Result`, `service_class`, `step_class`, `organizer_class` |
|
37
36
|
| High | 🚧 | Resolve warning during specs | |
|
38
37
|
| Medium | 🚧 | Consider to change/rewrite `delegate` backend to minify its interface | |
|
39
|
-
| Medium | 🚧 | Same order of attr macros, delegators, initialize, class methods, attr methods, queries, actions, to_
|
40
|
-
| Medium |
|
38
|
+
| Medium | 🚧 | Same order of attr macros, delegators, initialize, class methods, attr methods, queries, actions, `to_*`, comparison, inspect | |
|
39
|
+
| Medium | ✅ | Move `Cache` to `Support` | |
|
41
40
|
| Medium | 🚧 | Statically specify plugin dependencies | |
|
41
|
+
| Medium | 🚧 | Statically specify plugin entity types | |
|
42
|
+
| Medium | 🚧 | Consider to create `ComparableProc` descendant from `Proc` | To abstract away `block&.source_location != other.block&.source_location` |
|
43
|
+
| Medium | 🚧 | Consider to use `Struct` as key in `Support::Cache` | To hide overriden [eql?](https://github.com/marian13/convenient_service/blob/v0.1.0/lib/convenient_service/common/plugins/caches_return_value/entities/key.rb#L60) |
|
44
|
+
| High | 🚧 | `included_once` for `Support::Concern` |
|
45
|
+
| Medium | 🚧 | Custom YARD type for service instance, service class as return values |
|
46
|
+
| Medium | 🚧 | Heredoc for error messages |
|
47
|
+
| Medium | 🚧 | Specs for `be_success`, `be_error`, `be_failure` matchers | |
|
48
|
+
| Low | 🚧 | [Receive Counts](https://relishapp.com/rspec/rspec-mocks/docs/setting-constraints/receive-counts) for `delegate_to` | |
|
49
|
+
| Low | 🚧 | Prefer versioning instead of modification plugin | |
|
50
|
+
| Low | 🚧 | Consider to move `__steps__` and `__callbacks__` to `internals_class` | Benefit? |
|
51
|
+
| Medium | 🚧 | User friendly `raise` that removes lib backtrace from caller | Should have a `debug` mode. Should work well with examples. Check RSpec `CallerFilter.first_non_rspec_line` |
|
52
|
+
| High | 🚧 | A plugin that catches `StandardError` and returns `failure` | Should be the lowest in the stack |
|
53
|
+
| High | 🚧 | `Support::Command` alias | Should be visible to the end user |
|
54
|
+
|
55
|
+
Search for `TODO`s in the codebase for more tasks.
|
data/Taskfile.yml
CHANGED
@@ -194,25 +194,17 @@ tasks:
|
|
194
194
|
- bundle exec rake playground
|
195
195
|
interactive: true
|
196
196
|
|
197
|
-
release:
|
197
|
+
release:
|
198
198
|
cmds:
|
199
|
-
- gem
|
200
|
-
|
201
|
-
release:minor:
|
202
|
-
cmds:
|
203
|
-
- gem bump convenient_service --version minor
|
204
|
-
|
205
|
-
release:patch:
|
206
|
-
cmds:
|
207
|
-
- gem bump convenient_service --version patch
|
199
|
+
- gem release
|
208
200
|
|
209
201
|
rspec:
|
210
202
|
cmds:
|
211
203
|
- task: rspec:standard
|
212
|
-
- task: rspec:rails_5.2
|
213
|
-
- task: rspec:rails_6.0
|
214
|
-
- task: rspec:rails_6.1
|
215
204
|
- task: rspec:rails_7.0
|
205
|
+
- task: rspec:rails_6.1
|
206
|
+
- task: rspec:rails_6.0
|
207
|
+
- task: rspec:rails_5.2
|
216
208
|
- task: rspec:dry
|
217
209
|
|
218
210
|
##
|
data/env.rb
CHANGED
@@ -12,8 +12,12 @@
|
|
12
12
|
#
|
13
13
|
ENV["APPRAISAL_NAME"] ||= ENV["BUNDLE_GEMFILE"].to_s.then(&File.method(:basename)).then { |name| name.end_with?(".gemfile") ? name.delete_suffix(".gemfile") : "" }
|
14
14
|
|
15
|
+
puts "ENV[\"APPRAISAL_NAME\"] -> `#{ENV["APPRAISAL_NAME"]}`"
|
16
|
+
|
15
17
|
##
|
16
18
|
# NOTE: Ruby version may be set by docker.
|
17
19
|
# https://github.com/docker-library/ruby/blob/master/3.1/alpine3.16/Dockerfile#L30
|
18
20
|
#
|
19
21
|
ENV["RUBY_VERSION"] ||= ::RUBY_VERSION
|
22
|
+
|
23
|
+
puts "ENV[\"RUBY_VERSION\"] -> `#{ENV["RUBY_VERSION"]}`"
|
@@ -5,10 +5,25 @@ module ConvenientService
|
|
5
5
|
module Plugins
|
6
6
|
module CachesReturnValue
|
7
7
|
class Middleware < Core::MethodChainMiddleware
|
8
|
+
##
|
9
|
+
# @param args [Array]
|
10
|
+
# @param kwargs [Hash]
|
11
|
+
# @param block [Proc]
|
12
|
+
# @return [Object] Can be any type.
|
13
|
+
#
|
8
14
|
def next(*args, **kwargs, &block)
|
9
|
-
key =
|
15
|
+
key = cache.keygen(:return_values, method, *args, **kwargs, &block)
|
10
16
|
|
11
|
-
|
17
|
+
cache.fetch(key) { chain.next(*args, **kwargs, &block) }
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
##
|
23
|
+
# @return [ConvenientService::Support::Cache]
|
24
|
+
#
|
25
|
+
def cache
|
26
|
+
@cache ||= entity.internals.cache
|
12
27
|
end
|
13
28
|
end
|
14
29
|
end
|
@@ -8,9 +8,22 @@ module ConvenientService
|
|
8
8
|
include Support::Concern
|
9
9
|
|
10
10
|
instance_methods do
|
11
|
+
##
|
12
|
+
# @return [void]
|
13
|
+
#
|
11
14
|
def initialize(...)
|
12
15
|
end
|
13
16
|
end
|
17
|
+
|
18
|
+
class_methods do
|
19
|
+
##
|
20
|
+
# @return [Object]
|
21
|
+
# @since 0.2.0
|
22
|
+
#
|
23
|
+
def create(...)
|
24
|
+
new(...)
|
25
|
+
end
|
26
|
+
end
|
14
27
|
end
|
15
28
|
end
|
16
29
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Common
|
5
|
+
module Plugins
|
6
|
+
module HasConstructorWithoutInitialize
|
7
|
+
module Concern
|
8
|
+
include Support::Concern
|
9
|
+
|
10
|
+
class_methods do
|
11
|
+
##
|
12
|
+
# @return [Object]
|
13
|
+
# @since 0.2.0
|
14
|
+
#
|
15
|
+
# @internal
|
16
|
+
# - https://ruby-doc.org/core-2.5.0/Class.html#method-i-allocate
|
17
|
+
# - https://frontdeveloper.pl/2018/11/ruby-allocate-method/
|
18
|
+
#
|
19
|
+
def create_without_initialize
|
20
|
+
allocate
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -7,16 +7,20 @@ module ConvenientService
|
|
7
7
|
module Entities
|
8
8
|
class Internals
|
9
9
|
module Plugins
|
10
|
+
##
|
11
|
+
# @internal
|
12
|
+
# TODO: Consider to refactor into common plugin?
|
13
|
+
#
|
10
14
|
module HasCache
|
11
|
-
##
|
12
|
-
# TODO: Specs.
|
13
|
-
#
|
14
15
|
module Concern
|
15
16
|
include Support::Concern
|
16
17
|
|
17
18
|
instance_methods do
|
19
|
+
##
|
20
|
+
# @return [ConvenientService::Support::Cache]
|
21
|
+
#
|
18
22
|
def cache
|
19
|
-
@cache ||=
|
23
|
+
@cache ||= Support::Cache.new
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
@@ -11,6 +11,7 @@ require_relative "plugins/can_be_copied"
|
|
11
11
|
require_relative "plugins/has_around_callbacks"
|
12
12
|
require_relative "plugins/has_callbacks"
|
13
13
|
require_relative "plugins/has_constructor"
|
14
|
+
require_relative "plugins/has_constructor_without_initialize"
|
14
15
|
require_relative "plugins/has_internals"
|
15
16
|
|
16
17
|
require_relative "plugins/aliases"
|
@@ -20,6 +20,7 @@ module ConvenientService
|
|
20
20
|
concerns do
|
21
21
|
use Plugins::Common::HasInternals::Concern
|
22
22
|
use Plugins::Common::HasConstructor::Concern
|
23
|
+
use Plugins::Common::HasConstructorWithoutInitialize::Concern
|
23
24
|
|
24
25
|
use Plugins::Common::CachesConstructorParams::Concern
|
25
26
|
use Plugins::Common::CanBeCopied::Concern
|
@@ -27,10 +28,12 @@ module ConvenientService
|
|
27
28
|
use Plugins::Service::HasResultShortSyntax::Concern
|
28
29
|
use Plugins::Service::HasResultSteps::Concern
|
29
30
|
use Plugins::Service::CanRecalculateResult::Concern
|
31
|
+
use Plugins::Service::HasResultStatusCheckShortSyntax::Concern
|
30
32
|
|
31
33
|
use Plugins::Common::HasCallbacks::Concern
|
32
34
|
use Plugins::Common::HasAroundCallbacks::Concern
|
33
35
|
|
36
|
+
use Plugins::Service::HasInspect::Concern
|
34
37
|
##
|
35
38
|
# NOTE: Optional plugins.
|
36
39
|
# TODO: Specs.
|
@@ -97,9 +100,20 @@ module ConvenientService
|
|
97
100
|
|
98
101
|
concerns do
|
99
102
|
use Plugins::Common::HasInternals::Concern
|
103
|
+
use Plugins::Common::HasConstructor::Concern
|
104
|
+
|
105
|
+
use Plugins::Result::HasJsendStatusAndAttributes::Concern
|
100
106
|
|
101
107
|
use Plugins::Result::HasResultShortSyntax::Concern
|
102
108
|
use Plugins::Result::CanRecalculateResult::Concern
|
109
|
+
|
110
|
+
use Plugins::Result::HasInspect::Concern
|
111
|
+
end
|
112
|
+
|
113
|
+
middlewares :initialize do
|
114
|
+
use Plugins::Common::NormalizesEnv::Middleware
|
115
|
+
|
116
|
+
use Plugins::Result::HasJsendStatusAndAttributes::Middleware
|
103
117
|
end
|
104
118
|
|
105
119
|
middlewares :success? do
|
@@ -170,6 +184,8 @@ module ConvenientService
|
|
170
184
|
|
171
185
|
concerns do
|
172
186
|
use Plugins::Common::HasInternals::Concern
|
187
|
+
|
188
|
+
use Plugins::Step::HasInspect::Concern
|
173
189
|
end
|
174
190
|
|
175
191
|
middlewares :result do
|
@@ -31,7 +31,9 @@ module ConvenientService
|
|
31
31
|
end
|
32
32
|
|
33
33
|
middlewares :result do
|
34
|
-
|
34
|
+
insert_before \
|
35
|
+
Plugins::Service::HasResultSteps::Middleware,
|
36
|
+
Plugins::Service::HasResultParamsValidations::UsingDryValidation::Middleware
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
@@ -4,17 +4,18 @@ require_relative "gemfile/dry_service"
|
|
4
4
|
require_relative "gemfile/services"
|
5
5
|
|
6
6
|
##
|
7
|
-
#
|
7
|
+
# @internal
|
8
|
+
# Usage example:
|
8
9
|
#
|
9
|
-
#
|
10
|
-
#
|
10
|
+
# result = ConvenientService::Examples::Dry::Gemfile.format("Gemfile")
|
11
|
+
# result = ConvenientService::Examples::Dry::Gemfile.format("spec/cli/gemfile/format/fixtures/Gemfile")
|
11
12
|
#
|
12
13
|
module ConvenientService
|
13
14
|
module Examples
|
14
15
|
module Dry
|
15
16
|
module Gemfile
|
16
17
|
class << self
|
17
|
-
def format
|
18
|
+
def format(path)
|
18
19
|
Services::Format[path: path]
|
19
20
|
end
|
20
21
|
end
|
@@ -42,7 +42,9 @@ module ConvenientService
|
|
42
42
|
end
|
43
43
|
|
44
44
|
middlewares :result do
|
45
|
-
|
45
|
+
insert_before \
|
46
|
+
Plugins::Service::HasResultSteps::Middleware,
|
47
|
+
Plugins::Service::HasResultParamsValidations::UsingActiveModelValidations::Middleware
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|