convenient_service 0.5.0 → 0.6.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/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/ROADMAP.md +14 -3
- data/Taskfile.yml +30 -0
- data/convenient_service.gemspec +3 -1
- data/lib/convenient_service/aliases.rb +1 -0
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_active_model_attribute_assignment/concern.rb +0 -2
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_dry_initializer/concern.rb +0 -2
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/commands/resolve_methods_middlewares_callers.rb +1 -24
- data/lib/convenient_service/dependencies.rb +7 -0
- data/lib/convenient_service/examples/dry/gemfile/dry_service/config.rb +3 -1
- data/lib/convenient_service/examples/rails/gemfile/rails_service/config.rb +3 -1
- data/lib/convenient_service/examples/standard/request_params/constants.rb +15 -0
- data/lib/convenient_service/examples/standard/request_params/entities/description.rb +40 -0
- data/lib/convenient_service/examples/standard/request_params/entities/format.rb +40 -0
- data/lib/convenient_service/examples/standard/request_params/entities/id.rb +47 -0
- data/lib/convenient_service/examples/standard/request_params/entities/logger.rb +21 -0
- data/lib/convenient_service/examples/standard/request_params/entities/request.rb +23 -0
- data/lib/convenient_service/examples/standard/request_params/entities/source.rb +40 -0
- data/lib/convenient_service/examples/standard/request_params/entities/tag.rb +40 -0
- data/lib/convenient_service/examples/standard/request_params/entities/title.rb +40 -0
- data/lib/convenient_service/examples/standard/request_params/entities.rb +11 -0
- data/lib/convenient_service/examples/standard/request_params/services/apply_default_param_values.rb +26 -0
- data/lib/convenient_service/examples/standard/request_params/services/cast_params.rb +38 -0
- data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_body.rb +70 -0
- data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path.rb +62 -0
- data/lib/convenient_service/examples/standard/request_params/services/filter_out_unpermitted_params.rb +26 -0
- data/lib/convenient_service/examples/standard/request_params/services/log_request_params.rb +54 -0
- data/lib/convenient_service/examples/standard/request_params/services/merge_params.rb +26 -0
- data/lib/convenient_service/examples/standard/request_params/services/prepare.rb +65 -0
- data/lib/convenient_service/examples/standard/request_params/services/validate_casted_params.rb +94 -0
- data/lib/convenient_service/examples/standard/request_params/services/validate_uncasted_params.rb +72 -0
- data/lib/convenient_service/examples/standard/request_params/services.rb +13 -0
- data/lib/convenient_service/examples/standard/request_params/utils/array/wrap.rb +46 -0
- data/lib/convenient_service/examples/standard/request_params/utils/array.rb +21 -0
- data/lib/convenient_service/examples/standard/request_params/utils/http/request/parse_body.rb +42 -0
- data/lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb +40 -0
- data/lib/convenient_service/examples/standard/request_params/utils/http/request.rb +28 -0
- data/lib/convenient_service/examples/standard/request_params/utils/http.rb +3 -0
- data/lib/convenient_service/examples/standard/request_params/utils/integer/safe_parse.rb +31 -0
- data/lib/convenient_service/examples/standard/request_params/utils/integer.rb +25 -0
- data/lib/convenient_service/examples/standard/request_params/utils/json/safe_parse.rb +40 -0
- data/lib/convenient_service/examples/standard/request_params/utils/json.rb +21 -0
- data/lib/convenient_service/examples/standard/request_params/utils/object/blank.rb +34 -0
- data/lib/convenient_service/examples/standard/request_params/utils/object/present.rb +31 -0
- data/lib/convenient_service/examples/standard/request_params/utils/object.rb +26 -0
- data/lib/convenient_service/examples/standard/request_params/utils.rb +7 -0
- data/lib/convenient_service/examples/standard/request_params.rb +48 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/commands/generate_printable_method.rb +50 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/commands.rb +3 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments/commands/apply_stub_to_track_delegations.rb +78 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments/commands/generate_printable_arguments.rb +100 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments/commands.rb +4 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments.rb +95 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/sub_matchers/base.rb +87 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/sub_matchers/return_its_value.rb +129 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/sub_matchers/with_any_arguments.rb +37 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/sub_matchers/with_concrete_arguments.rb +37 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/sub_matchers/without_arguments.rb +37 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/values/base.rb +41 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/values/with_calling_original.rb +30 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings/values/without_calling_original.rb +30 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings.rb +12 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings_collection/errors.rb +57 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings_collection.rb +171 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/delegation.rb +79 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities.rb +5 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher.rb +276 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities.rb +3 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to.rb +58 -234
- data/lib/convenient_service/rspec/matchers/custom/singleton_prepend_module.rb +79 -0
- data/lib/convenient_service/rspec/matchers/custom.rb +1 -0
- data/lib/convenient_service/rspec/matchers/singleton_prepend_module.rb +13 -0
- data/lib/convenient_service/rspec/matchers.rb +2 -0
- data/lib/convenient_service/service/plugins/has_result_steps/concern.rb +25 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_caller.rb +8 -1
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_direction.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_key.rb +8 -1
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_name.rb +9 -5
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/concern/instance_methods.rb +4 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers/base.rb +4 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers/reassignment/commands/define_method_in_container.rb +74 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers/reassignment/commands.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers/reassignment.rb +50 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/callers.rb +1 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/values/reassignment.rb +43 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/values.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities.rb +1 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/errors.rb +22 -0
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/concern/instance_methods.rb +13 -2
- data/lib/convenient_service/support/arguments/null_arguments.rb +28 -0
- data/lib/convenient_service/support/arguments.rb +87 -0
- data/lib/convenient_service/support/dependency_container/commands/assert_valid_scope.rb +32 -0
- data/lib/convenient_service/support/dependency_container/commands/import_method.rb +13 -23
- data/lib/convenient_service/support/dependency_container/commands.rb +1 -0
- data/lib/convenient_service/support/dependency_container/constants.rb +4 -2
- data/lib/convenient_service/support/dependency_container/entities/method.rb +2 -9
- data/lib/convenient_service/support/dependency_container/entities/namespace_collection.rb +0 -9
- data/lib/convenient_service/support/dependency_container/errors.rb +25 -0
- data/lib/convenient_service/support/dependency_container/export.rb +8 -0
- data/lib/convenient_service/support/dependency_container/import.rb +3 -1
- data/lib/convenient_service/support/version/null_version.rb +7 -0
- data/lib/convenient_service/support/version.rb +11 -1
- data/lib/convenient_service/support.rb +1 -0
- data/lib/convenient_service/utils/object/instance_variable_delete.rb +41 -0
- data/lib/convenient_service/utils/object/instance_variable_fetch.rb +4 -0
- data/lib/convenient_service/utils/object.rb +9 -0
- data/lib/convenient_service/utils/proc/display.rb +43 -0
- data/lib/convenient_service/utils/proc.rb +5 -0
- data/lib/convenient_service/version.rb +1 -1
- metadata +101 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ec5188e0830cb8a97b589ff6985d4aa1e361bce486dba86a1a1f697924d0be7
|
|
4
|
+
data.tar.gz: ab763a1c604849509f5557938768bf019b5d962dd5d6fa62771b17e3c524025d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 32cf7296bf8a5ff16d7bfed6c20a855831e27b0300edede75ba7c737f357ed6ddf462641d7cacc9c5f7a65c64c3a4e59b04a60cee0ad9793f173fca7e9c0ad24
|
|
7
|
+
data.tar.gz: 71aadf20b54f0f507eb6721999b2192630eb2265d660d40ecc461de311fb930376883d1546c9c030c03f15e90e0c02e172066adc2213cb61140cc3f8b45b5137
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.0](https://github.com/marian13/convenient_service/compare/v0.5.0...v0.6.0) (2023-01-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **dependency_container:** assert valid scope ([5d75f59](https://github.com/marian13/convenient_service/commit/5d75f593c01baa695e75fe49af6b4c6b80d7d9b1))
|
|
9
|
+
* **singleton_prepend_module:** introduce singleton_prepend_module custom RSpec matcher ([6636b8d](https://github.com/marian13/convenient_service/commit/6636b8d030329e4a6216a934748a70ef4bae6ff3))
|
|
10
|
+
* **has_result_steps:** introduce reassign ([75855be](https://github.com/marian13/convenient_service/commit/75855be7fd9115d01d5cfad99d35319486332bd2))
|
|
11
|
+
|
|
3
12
|
## [0.5.0](https://github.com/marian13/convenient_service/compare/v0.4.0...v0.5.0) (2023-01-19)
|
|
4
13
|
|
|
5
14
|
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -60,5 +60,5 @@ This library is under heavy development. Public API may be subject to change. Th
|
|
|
60
60
|
---
|
|
61
61
|
|
|
62
62
|
<!-- author:start -->
|
|
63
|
-
Copyright (c) 2022 [Marian Kostyk](http://mariankostyk.com).
|
|
63
|
+
Copyright (c) 2022-2023 [Marian Kostyk](http://mariankostyk.com).
|
|
64
64
|
<!-- author:end -->
|
data/ROADMAP.md
CHANGED
|
@@ -44,14 +44,25 @@
|
|
|
44
44
|
| High | 🚧 | `included_once` for `Support::Concern` |
|
|
45
45
|
| Medium | 🚧 | Custom YARD type for service instance, service class as return values |
|
|
46
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` | |
|
|
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
49
|
| Low | 🚧 | Prefer versioning instead of modification plugin | |
|
|
50
50
|
| Low | 🚧 | Consider to move `__steps__` and `__callbacks__` to `internals_class` | Benefit? |
|
|
51
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
52
|
| High | 🚧 | A plugin that catches `StandardError` and returns `failure` | Should be the lowest in the stack |
|
|
53
53
|
| High | 🚧 | `Support::Command` alias | Should be visible to the end user |
|
|
54
54
|
| Low | 🚧 | Parallel steps | A killer feature |
|
|
55
|
-
| Medium | 🚧 | Add Ruby 3.2 support to Docker and CI | |
|
|
55
|
+
| Medium | 🚧 | Add `Ruby 3.2` support to `Docker` and `CI` | |
|
|
56
|
+
| Low | 🚧 | `overload do` | |
|
|
57
|
+
| Low | 🚧 | Same spec example group organization | |
|
|
58
|
+
| Medium | 🚧 | `Support::Arguments` | |
|
|
59
|
+
| Low | 🚧 | Null object to Nil object? | |
|
|
60
|
+
| High | 🚧 | Do not use Testing Toolkit in the Primitives layer | See [Components Diagram](https://marian13.github.io/static_content/convenient_service/diagrams/components_graph.html) + it should take the minimal amount of efforts to extract and reuse `Utils`, `Suppport` in the different projects |
|
|
61
|
+
| Medium | 🚧 | Perfromance testing | [rspec-benchmark](https://github.com/piotrmurach/rspec-benchmark), [Testing object allocations](https://www.honeybadger.io/blog/testing-object-allocations/), [allocation_stats](https://github.com/srawlins/allocation_stats) |
|
|
62
|
+
| Medium | 🚧 | Mutant testing | [mutant](https://github.com/mbj/mutant) |
|
|
63
|
+
| Low | 🚧 | Add `JRuby` support | [jruby](https://www.jruby.org/) |
|
|
64
|
+
| Medium | 🚧 | Add `shoulda-context` to test conditionals when `RSpec` is not loaded | [shoulda-context](https://github.com/thoughtbot/shoulda-context) |
|
|
65
|
+
| High | 🚧 | Abstract factory for `CastMethod` | |
|
|
66
|
+
| Medium | 🚧 | `delegate_to` - option to specify of how to compare blocks | |
|
|
56
67
|
|
|
57
68
|
Search for `TODO`s in the codebase for more tasks.
|
data/Taskfile.yml
CHANGED
|
@@ -78,6 +78,16 @@ tasks:
|
|
|
78
78
|
|
|
79
79
|
docker:build:ruby_2.7:
|
|
80
80
|
cmds:
|
|
81
|
+
##
|
|
82
|
+
# NOTE: Meaning of `|| 2> /dev/null`.
|
|
83
|
+
# https://stackoverflow.com/a/10250395/12201472
|
|
84
|
+
#
|
|
85
|
+
# NOTE: Meaning of `|| true`.
|
|
86
|
+
# https://superuser.com/a/887349/1180656
|
|
87
|
+
#
|
|
88
|
+
- rm Gemfile.2.7 2> /dev/null || true
|
|
89
|
+
- rm Gemfile.2.7.lock 2> /dev/null || true
|
|
90
|
+
- cp Gemfile Gemfile.2.7
|
|
81
91
|
- docker build . -f docker/2.7/Dockerfile -t convenient_service:2.7
|
|
82
92
|
preconditions:
|
|
83
93
|
- sh: '[ "${IN_DOCKER_CONTAINER}" != "true" ]'
|
|
@@ -85,6 +95,16 @@ tasks:
|
|
|
85
95
|
|
|
86
96
|
docker:build:ruby_3.0:
|
|
87
97
|
cmds:
|
|
98
|
+
##
|
|
99
|
+
# NOTE: Meaning of `|| 2> /dev/null`.
|
|
100
|
+
# https://stackoverflow.com/a/10250395/12201472
|
|
101
|
+
#
|
|
102
|
+
# NOTE: Meaning of `|| true`.
|
|
103
|
+
# https://superuser.com/a/887349/1180656
|
|
104
|
+
#
|
|
105
|
+
- rm Gemfile.3.0 2> /dev/null || true
|
|
106
|
+
- rm Gemfile.3.0.lock 2> /dev/null || true
|
|
107
|
+
- cp Gemfile Gemfile.3.0
|
|
88
108
|
- docker build . -f docker/3.0/Dockerfile -t convenient_service:3.0
|
|
89
109
|
preconditions:
|
|
90
110
|
- sh: '[ "${IN_DOCKER_CONTAINER}" != "true" ]'
|
|
@@ -92,6 +112,16 @@ tasks:
|
|
|
92
112
|
|
|
93
113
|
docker:build:ruby_3.1:
|
|
94
114
|
cmds:
|
|
115
|
+
##
|
|
116
|
+
# NOTE: Meaning of `|| 2> /dev/null`.
|
|
117
|
+
# https://stackoverflow.com/a/10250395/12201472
|
|
118
|
+
#
|
|
119
|
+
# NOTE: Meaning of `|| true`.
|
|
120
|
+
# https://superuser.com/a/887349/1180656
|
|
121
|
+
#
|
|
122
|
+
- rm Gemfile.3.1 2> /dev/null || true
|
|
123
|
+
- rm Gemfile.3.1.lock 2> /dev/null || true
|
|
124
|
+
- cp Gemfile Gemfile.3.1
|
|
95
125
|
- docker build . -f docker/3.1/Dockerfile -t convenient_service:3.1
|
|
96
126
|
preconditions:
|
|
97
127
|
- sh: '[ "${IN_DOCKER_CONTAINER}" != "true" ]'
|
data/convenient_service.gemspec
CHANGED
|
@@ -35,18 +35,20 @@ Gem::Specification.new do |spec|
|
|
|
35
35
|
spec.add_development_dependency "commonmarker"
|
|
36
36
|
spec.add_development_dependency "gem-release"
|
|
37
37
|
spec.add_development_dependency "inch"
|
|
38
|
+
spec.add_development_dependency "json"
|
|
38
39
|
spec.add_development_dependency "paint"
|
|
39
40
|
spec.add_development_dependency "progressbar"
|
|
40
41
|
spec.add_development_dependency "rake", "~> 12.0"
|
|
41
42
|
spec.add_development_dependency "rerun"
|
|
42
43
|
spec.add_development_dependency "rouge"
|
|
43
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
|
44
|
+
spec.add_development_dependency "rspec", "~> 3.11.0"
|
|
44
45
|
spec.add_development_dependency "rubocop", "~> 1.40.0"
|
|
45
46
|
spec.add_development_dependency "rubocop-rspec"
|
|
46
47
|
spec.add_development_dependency "tty-prompt"
|
|
47
48
|
spec.add_development_dependency "standard"
|
|
48
49
|
spec.add_development_dependency "simplecov"
|
|
49
50
|
spec.add_development_dependency "simplecov-lcov"
|
|
51
|
+
spec.add_development_dependency "webrick"
|
|
50
52
|
spec.add_development_dependency "yard"
|
|
51
53
|
spec.add_development_dependency "yard-junk"
|
|
52
54
|
end
|
|
@@ -35,30 +35,7 @@ module ConvenientService
|
|
|
35
35
|
# @return [Module]
|
|
36
36
|
#
|
|
37
37
|
def call
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
private
|
|
42
|
-
|
|
43
|
-
##
|
|
44
|
-
# @return [Module, nil]
|
|
45
|
-
#
|
|
46
|
-
def get_methods_middlewares_callers
|
|
47
|
-
Utils::Module.get_own_const(klass, module_name)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
##
|
|
51
|
-
# @return [Module]
|
|
52
|
-
#
|
|
53
|
-
def set_methods_middlewares_callers
|
|
54
|
-
klass.const_set(module_name, ::Module.new)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
##
|
|
58
|
-
# @return [Symbol]
|
|
59
|
-
#
|
|
60
|
-
def module_name
|
|
61
|
-
@module_name ||= :MethodsMiddlewaresCallers
|
|
38
|
+
Utils::Module.fetch_own_const(klass, :MethodsMiddlewaresCallers) { ::Module.new }
|
|
62
39
|
end
|
|
63
40
|
end
|
|
64
41
|
end
|
|
@@ -113,9 +113,12 @@ module ConvenientService
|
|
|
113
113
|
# @api private
|
|
114
114
|
#
|
|
115
115
|
def require_standard_examples
|
|
116
|
+
require "json"
|
|
116
117
|
require "progressbar"
|
|
118
|
+
require "webrick"
|
|
117
119
|
|
|
118
120
|
require_relative "examples/standard/cowsay"
|
|
121
|
+
require_relative "examples/standard/request_params"
|
|
119
122
|
require_relative "examples/standard/gemfile"
|
|
120
123
|
end
|
|
121
124
|
|
|
@@ -126,7 +129,9 @@ module ConvenientService
|
|
|
126
129
|
# @api private
|
|
127
130
|
#
|
|
128
131
|
def require_rails_examples
|
|
132
|
+
require "json"
|
|
129
133
|
require "progressbar"
|
|
134
|
+
require "webrick"
|
|
130
135
|
|
|
131
136
|
require_relative "examples/rails/gemfile"
|
|
132
137
|
end
|
|
@@ -138,7 +143,9 @@ module ConvenientService
|
|
|
138
143
|
# @api private
|
|
139
144
|
#
|
|
140
145
|
def require_dry_examples
|
|
146
|
+
require "json"
|
|
141
147
|
require "progressbar"
|
|
148
|
+
require "webrick"
|
|
142
149
|
|
|
143
150
|
require_relative "examples/dry/gemfile"
|
|
144
151
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConvenientService
|
|
4
|
+
module Examples
|
|
5
|
+
module Standard
|
|
6
|
+
module RequestParams
|
|
7
|
+
module Entities
|
|
8
|
+
class Description
|
|
9
|
+
def initialize(value:)
|
|
10
|
+
@value = value
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
def cast(value)
|
|
15
|
+
case value
|
|
16
|
+
when ::String
|
|
17
|
+
new(value: value.to_s)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def ==(other)
|
|
23
|
+
return unless other.instance_of?(self.class)
|
|
24
|
+
|
|
25
|
+
value == other.value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_s
|
|
29
|
+
value
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
attr_reader :value
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConvenientService
|
|
4
|
+
module Examples
|
|
5
|
+
module Standard
|
|
6
|
+
module RequestParams
|
|
7
|
+
module Entities
|
|
8
|
+
class Format
|
|
9
|
+
def initialize(value:)
|
|
10
|
+
@value = value
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
def cast(value)
|
|
15
|
+
case value
|
|
16
|
+
when ::String
|
|
17
|
+
new(value: value.to_s)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def ==(other)
|
|
23
|
+
return unless other.instance_of?(self.class)
|
|
24
|
+
|
|
25
|
+
value == other.value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_s
|
|
29
|
+
value
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
attr_reader :value
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConvenientService
|
|
4
|
+
module Examples
|
|
5
|
+
module Standard
|
|
6
|
+
module RequestParams
|
|
7
|
+
module Entities
|
|
8
|
+
##
|
|
9
|
+
# TODO: https://ruby-doc.org/3.1.3/stdlibs/yaml/YAML/DBM.html
|
|
10
|
+
#
|
|
11
|
+
class ID
|
|
12
|
+
def initialize(value:)
|
|
13
|
+
@value = value
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class << self
|
|
17
|
+
def cast(value)
|
|
18
|
+
case value
|
|
19
|
+
when ::String, ::Integer
|
|
20
|
+
new(value: value.to_s)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def ==(other)
|
|
26
|
+
return unless other.instance_of?(self.class)
|
|
27
|
+
|
|
28
|
+
value == other.value
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def to_i
|
|
32
|
+
value.to_i
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def to_s
|
|
36
|
+
value
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
protected
|
|
40
|
+
|
|
41
|
+
attr_reader :value
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConvenientService
|
|
4
|
+
module Examples
|
|
5
|
+
module Standard
|
|
6
|
+
module RequestParams
|
|
7
|
+
module Entities
|
|
8
|
+
class Logger
|
|
9
|
+
class << self
|
|
10
|
+
def log(message, out: $stdout)
|
|
11
|
+
out.puts message
|
|
12
|
+
|
|
13
|
+
message
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConvenientService
|
|
4
|
+
module Examples
|
|
5
|
+
module Standard
|
|
6
|
+
module RequestParams
|
|
7
|
+
module Entities
|
|
8
|
+
class Request
|
|
9
|
+
attr_reader :http_string
|
|
10
|
+
|
|
11
|
+
def initialize(http_string:)
|
|
12
|
+
@http_string = http_string
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_s
|
|
16
|
+
http_string
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConvenientService
|
|
4
|
+
module Examples
|
|
5
|
+
module Standard
|
|
6
|
+
module RequestParams
|
|
7
|
+
module Entities
|
|
8
|
+
class Source
|
|
9
|
+
def initialize(value:)
|
|
10
|
+
@value = value
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
def cast(value)
|
|
15
|
+
case value
|
|
16
|
+
when ::String
|
|
17
|
+
new(value: value.to_s)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def ==(other)
|
|
23
|
+
return unless other.instance_of?(self.class)
|
|
24
|
+
|
|
25
|
+
value == other.value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_s
|
|
29
|
+
value
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
attr_reader :value
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConvenientService
|
|
4
|
+
module Examples
|
|
5
|
+
module Standard
|
|
6
|
+
module RequestParams
|
|
7
|
+
module Entities
|
|
8
|
+
class Tag
|
|
9
|
+
def initialize(value:)
|
|
10
|
+
@value = value
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
def cast(value)
|
|
15
|
+
case value
|
|
16
|
+
when ::String
|
|
17
|
+
new(value: value.to_s)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def ==(other)
|
|
23
|
+
return unless other.instance_of?(self.class)
|
|
24
|
+
|
|
25
|
+
value == other.value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_s
|
|
29
|
+
value
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
attr_reader :value
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConvenientService
|
|
4
|
+
module Examples
|
|
5
|
+
module Standard
|
|
6
|
+
module RequestParams
|
|
7
|
+
module Entities
|
|
8
|
+
class Title
|
|
9
|
+
def initialize(value:)
|
|
10
|
+
@value = value
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
def cast(value)
|
|
15
|
+
case value
|
|
16
|
+
when ::String
|
|
17
|
+
new(value: value.to_s)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def ==(other)
|
|
23
|
+
return unless other.instance_of?(self.class)
|
|
24
|
+
|
|
25
|
+
value == other.value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_s
|
|
29
|
+
value
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
attr_reader :value
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "entities/logger"
|
|
4
|
+
require_relative "entities/request"
|
|
5
|
+
|
|
6
|
+
require_relative "entities/description"
|
|
7
|
+
require_relative "entities/format"
|
|
8
|
+
require_relative "entities/id"
|
|
9
|
+
require_relative "entities/source"
|
|
10
|
+
require_relative "entities/tag"
|
|
11
|
+
require_relative "entities/title"
|
data/lib/convenient_service/examples/standard/request_params/services/apply_default_param_values.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConvenientService
|
|
4
|
+
module Examples
|
|
5
|
+
module Standard
|
|
6
|
+
module RequestParams
|
|
7
|
+
module Services
|
|
8
|
+
class ApplyDefaultParamValues
|
|
9
|
+
include ConvenientService::Standard::Config
|
|
10
|
+
|
|
11
|
+
attr_reader :params, :defaults
|
|
12
|
+
|
|
13
|
+
def initialize(params:, defaults:)
|
|
14
|
+
@params = params
|
|
15
|
+
@defaults = defaults
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def result
|
|
19
|
+
success(params: defaults.merge(params))
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ConvenientService
|
|
4
|
+
module Examples
|
|
5
|
+
module Standard
|
|
6
|
+
module RequestParams
|
|
7
|
+
module Services
|
|
8
|
+
class CastParams
|
|
9
|
+
include ConvenientService::Standard::Config
|
|
10
|
+
|
|
11
|
+
attr_reader :params
|
|
12
|
+
|
|
13
|
+
def initialize(params:)
|
|
14
|
+
@params = params
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def result
|
|
18
|
+
success(original_params: params, casted_params: casted_params)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def casted_params
|
|
24
|
+
{
|
|
25
|
+
id: Entities::ID.cast(params[:id]),
|
|
26
|
+
format: Entities::Format.cast(params[:format]),
|
|
27
|
+
title: Entities::Title.cast(params[:title]),
|
|
28
|
+
description: Entities::Description.cast(params[:description]),
|
|
29
|
+
tags: Utils::Array.wrap(params[:tags]).map { |tag| Entities::Tag.cast(tag) },
|
|
30
|
+
sources: Utils::Array.wrap(params[:sources]).map { |source| Entities::Source.cast(source) }
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|