convenient_service 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dev/.tmuxinator.yml +2 -1
- data/.github/workflows/ci.yml +21 -1
- data/CHANGELOG.md +67 -0
- data/Gemfile +6 -0
- data/README.md +4 -2
- data/Taskfile.yml +94 -0
- data/convenient_service.gemspec +40 -2
- data/docker/2.7/Dockerfile +3 -3
- data/docker/3.0/Dockerfile +2 -2
- data/docker/3.1/Dockerfile +2 -2
- data/docker/3.2/Dockerfile +73 -0
- data/docker/jruby-9.4/Dockerfile +88 -0
- data/docker/truffleruby-22.3/Dockerfile +91 -0
- data/lib/convenient_service/common/plugins/aliases.rb +0 -1
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_active_model_attribute_assignment/middleware.rb +12 -8
- data/lib/convenient_service/common/plugins/caches_return_value/middleware.rb +3 -3
- data/lib/convenient_service/common/plugins/can_have_user_provided_entity/errors.rb +2 -2
- data/lib/convenient_service/common/plugins/has_around_callbacks/errors.rb +1 -1
- data/lib/convenient_service/common/plugins/has_callbacks/entities/callback.rb +7 -7
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/aliases.rb +7 -0
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins.rb +2 -0
- data/lib/convenient_service/configs/minimal.rb +19 -10
- data/lib/convenient_service/core/class_methods.rb +24 -9
- data/lib/convenient_service/core/constants.rb +36 -0
- data/lib/convenient_service/core/entities/config/commands/track_method_missing_commit_trigger.rb +69 -0
- data/lib/convenient_service/core/entities/config/commands.rb +3 -0
- data/lib/convenient_service/core/entities/config/entities/concerns/entities/stack.rb +10 -10
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/chain.rb +3 -3
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middleware.rb +18 -1
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middleware_creator.rb +62 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/stack.rb +12 -12
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities.rb +1 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares.rb +1 -1
- data/lib/convenient_service/core/entities/config/errors.rb +38 -1
- data/lib/convenient_service/core/entities/config.rb +14 -4
- data/lib/convenient_service/core/instance_methods.rb +6 -4
- data/lib/convenient_service/core.rb +1 -0
- data/lib/convenient_service/dependencies/built_in.rb +7 -0
- data/lib/convenient_service/dependencies/extractions/active_support_concern/concern.rb +18 -2
- data/lib/convenient_service/dependencies/extractions/active_support_concern.rb +4 -0
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/builder.rb +7 -1
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/logger.rb +7 -1
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/runner.rb +15 -1
- data/lib/convenient_service/dependencies/extractions/ruby_middleware/middleware.rb +8 -1
- data/lib/convenient_service/dependencies/extractions/ruby_middleware.rb +3 -2
- data/lib/convenient_service/dependencies.rb +16 -15
- data/lib/convenient_service/examples/dry/gemfile.rb +4 -4
- data/lib/convenient_service/examples/rails/gemfile.rb +4 -4
- data/lib/convenient_service/examples/standard/cowsay.rb +4 -4
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb +1 -1
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_not_empty.rb +1 -1
- data/lib/convenient_service/examples/standard/gemfile/services/assert_node_available.rb +0 -9
- data/lib/convenient_service/examples/standard/gemfile/services/assert_npm_package_available.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile/services/format.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile/services/parse_content.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile/services/replace_file_content.rb +0 -10
- data/lib/convenient_service/examples/standard/gemfile.rb +4 -4
- data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_body.rb +0 -10
- data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path.rb +0 -10
- data/lib/convenient_service/examples/standard/request_params/services/validate_casted_params.rb +0 -10
- data/lib/convenient_service/examples/standard/request_params/services/validate_uncasted_params.rb +0 -10
- data/lib/convenient_service/examples/standard/request_params.rb +4 -4
- data/lib/convenient_service/feature.rb +12 -0
- data/lib/convenient_service/logger.rb +6 -5
- data/lib/convenient_service/rspec/helpers/custom/in_threads.rb +74 -0
- data/lib/convenient_service/rspec/helpers/custom/stub_service/constants.rb +20 -0
- data/lib/convenient_service/rspec/helpers/custom/stub_service/entities/stubbed_service.rb +4 -4
- data/lib/convenient_service/rspec/helpers/custom/stub_service.rb +1 -0
- data/lib/convenient_service/rspec/helpers/custom/wrap_method/entities/wrapped_method.rb +3 -3
- data/lib/convenient_service/rspec/helpers/custom/wrap_method/errors.rb +1 -1
- data/lib/convenient_service/rspec/helpers/custom.rb +1 -0
- data/lib/convenient_service/rspec/helpers/in_threads.rb +13 -0
- data/lib/convenient_service/rspec/helpers.rb +2 -0
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/chainings_collection/errors.rb +3 -3
- data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher/entities/delegation.rb +3 -3
- data/lib/convenient_service/rspec/matchers/custom/export.rb +82 -0
- data/lib/convenient_service/rspec/matchers/custom/results/base/constants.rb +22 -0
- data/lib/convenient_service/rspec/matchers/custom/results/base/errors.rb +1 -1
- data/lib/convenient_service/rspec/matchers/custom/results/base.rb +2 -1
- data/lib/convenient_service/rspec/matchers/custom.rb +1 -0
- data/lib/convenient_service/rspec/matchers/export.rb +13 -0
- data/lib/convenient_service/rspec/matchers.rb +2 -0
- data/lib/convenient_service/service/plugins/aliases.rb +0 -2
- data/lib/convenient_service/service/plugins/can_have_method_steps/middleware.rb +2 -2
- data/lib/convenient_service/service/plugins/can_have_result_step/middleware.rb +2 -2
- data/lib/convenient_service/service/plugins/can_have_steps/concern.rb +2 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method.rb +46 -11
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_direction.rb +29 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_factory.rb +113 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands.rb +1 -3
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/base.rb +62 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/base.rb +35 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/proc_value.rb +42 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/raw_value.rb +42 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/reassignment_value.rb +42 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/string_value.rb +42 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash/symbol_value.rb +42 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/hash.rb +8 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/method.rb +40 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/reassignment.rb +40 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/string.rb +40 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/symbol.rb +40 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories.rb +8 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities.rb +1 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/errors.rb +7 -7
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/errors.rb +12 -8
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/aliases.rb +7 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +2 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb +37 -8
- data/lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb +19 -11
- data/lib/convenient_service/service/plugins/can_have_stubbed_result/middleware.rb +3 -3
- data/lib/convenient_service/service/plugins/has_result/concern/instance_methods.rb +3 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/aliases.rb +7 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result/concern.rb +12 -5
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes/concern/class_methods.rb → can_have_parent_result/constants.rb} +3 -4
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_have_parent_result.rb +1 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes/commands/cast_jsend_attributes.rb → has_j_send_status_and_attributes/commands/cast_j_send_attributes.rb} +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_code_class.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_data_class.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_message_class.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands/create_status_class.rb +49 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/commands.rb +7 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/concern/class_methods.rb +69 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/concern/instance_methods.rb +9 -9
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities/code/concern/class_methods.rb +2 -2
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities/code/concern/instance_methods.rb +3 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities/code/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities/code.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/class_methods.rb +38 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb +94 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern.rb +36 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data.rb +25 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/concern/class_methods.rb +40 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/concern/instance_methods.rb +58 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/concern.rb +36 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message.rb +25 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern/class_methods.rb +40 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern/instance_methods.rb +115 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern.rb +36 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status.rb +25 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/errors.rb +6 -2
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/middleware.rb +4 -4
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes/structs/jsend_attributes.rb → has_j_send_status_and_attributes/structs/j_send_attributes.rb} +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes/structs.rb +3 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_j_send_status_and_attributes.rb +8 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax/concern.rb +3 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/raises_on_not_checked_result_status/errors.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins.rb +3 -1
- data/lib/convenient_service/service/plugins/has_result/errors.rb +2 -2
- data/lib/convenient_service/service/plugins/has_result_status_check_short_syntax/concern.rb +16 -0
- data/lib/convenient_service/service/plugins/raises_on_double_result/errors.rb +1 -1
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb +1 -1
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_exception.rb +11 -10
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb +14 -7
- data/lib/convenient_service/services/run_own_method_in_organizer.rb +1 -1
- data/lib/convenient_service/support/abstract_method/errors.rb +1 -1
- data/lib/convenient_service/support/arguments.rb +3 -3
- data/lib/convenient_service/support/cache/key.rb +3 -3
- data/lib/convenient_service/support/cache.rb +1 -1
- data/lib/convenient_service/support/castable/errors.rb +2 -2
- data/lib/convenient_service/support/counter.rb +212 -0
- data/lib/convenient_service/support/dependency_container/commands/assert_valid_container.rb +33 -0
- data/lib/convenient_service/support/dependency_container/commands/assert_valid_method.rb +58 -0
- data/lib/convenient_service/support/dependency_container/commands/assert_valid_scope.rb +4 -3
- data/lib/convenient_service/support/dependency_container/commands/define_entry.rb +49 -0
- data/lib/convenient_service/support/dependency_container/commands.rb +3 -0
- data/lib/convenient_service/support/dependency_container/container.rb +23 -0
- data/lib/convenient_service/support/dependency_container/entry.rb +22 -0
- data/lib/convenient_service/support/dependency_container/errors.rb +5 -5
- data/lib/convenient_service/support/dependency_container/import.rb +3 -3
- data/lib/convenient_service/support/dependency_container.rb +3 -0
- data/lib/convenient_service/support/finite_loop.rb +37 -2
- data/lib/convenient_service/support/middleware/stack_builder.rb +1 -1
- data/lib/convenient_service/support/not_passed.rb +4 -3
- data/lib/convenient_service/support/ruby.rb +31 -0
- data/lib/convenient_service/support/safe_method.rb +65 -0
- data/lib/convenient_service/support/thread_safe_counter.rb +119 -0
- data/lib/convenient_service/support/undefined.rb +4 -3
- data/lib/convenient_service/support/unique_value.rb +69 -0
- data/lib/convenient_service/support.rb +4 -0
- data/lib/convenient_service/utils/array/errors.rb +1 -1
- data/lib/convenient_service/utils/array/find_last.rb +1 -1
- data/lib/convenient_service/utils/array/find_yield.rb +1 -1
- data/lib/convenient_service/utils/object/resolve_class.rb +56 -0
- data/lib/convenient_service/utils/object.rb +9 -0
- data/lib/convenient_service/version.rb +1 -1
- data/lib/convenient_service.rb +6 -0
- metadata +75 -34
- data/lib/convenient_service/factories/arguments.rb +0 -43
- data/lib/convenient_service/factories/results.rb +0 -214
- data/lib/convenient_service/factories/services.rb +0 -229
- data/lib/convenient_service/factories/step/instance.rb +0 -42
- data/lib/convenient_service/factories/step.rb +0 -3
- data/lib/convenient_service/factories/steps.rb +0 -126
- data/lib/convenient_service/factories.rb +0 -22
- data/lib/convenient_service/factory.rb +0 -21
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_caller.rb +0 -74
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_key.rb +0 -78
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_name.rb +0 -78
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands.rb +0 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data/class_methods.rb +0 -32
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data.rb +0 -74
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message/class_methods.rb +0 -34
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message.rb +0 -45
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status/class_methods.rb +0 -34
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb +0 -77
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs.rb +0 -3
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes.rb +0 -8
- /data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/{has_jsend_status_and_attributes → has_j_send_status_and_attributes}/entities.rb +0 -0
data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path.rb
CHANGED
@@ -8,16 +8,6 @@ module ConvenientService
|
|
8
8
|
class ExtractParamsFromPath
|
9
9
|
include ConvenientService::Standard::Config
|
10
10
|
|
11
|
-
##
|
12
|
-
# IMPORTANT:
|
13
|
-
# - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
|
14
|
-
# - It will be reenabled after the introduction of thread-safety specs.
|
15
|
-
# - Do not use it in production yet.
|
16
|
-
#
|
17
|
-
middlewares :step, scope: :class do
|
18
|
-
use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
|
19
|
-
end
|
20
|
-
|
21
11
|
attr_reader :request, :pattern
|
22
12
|
|
23
13
|
step :parse_path, in: :request, out: :path
|
data/lib/convenient_service/examples/standard/request_params/services/validate_casted_params.rb
CHANGED
@@ -8,16 +8,6 @@ module ConvenientService
|
|
8
8
|
class ValidateCastedParams
|
9
9
|
include ConvenientService::Standard::Config
|
10
10
|
|
11
|
-
##
|
12
|
-
# IMPORTANT:
|
13
|
-
# - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
|
14
|
-
# - It will be reenabled after the introduction of thread-safety specs.
|
15
|
-
# - Do not use it in production yet.
|
16
|
-
#
|
17
|
-
middlewares :step, scope: :class do
|
18
|
-
use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
|
19
|
-
end
|
20
|
-
|
21
11
|
attr_reader \
|
22
12
|
:original_id,
|
23
13
|
:original_format,
|
data/lib/convenient_service/examples/standard/request_params/services/validate_uncasted_params.rb
CHANGED
@@ -8,16 +8,6 @@ module ConvenientService
|
|
8
8
|
class ValidateUncastedParams
|
9
9
|
include ConvenientService::Standard::Config
|
10
10
|
|
11
|
-
##
|
12
|
-
# IMPORTANT:
|
13
|
-
# - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
|
14
|
-
# - It will be reenabled after the introduction of thread-safety specs.
|
15
|
-
# - Do not use it in production yet.
|
16
|
-
#
|
17
|
-
middlewares :step, scope: :class do
|
18
|
-
use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
|
19
|
-
end
|
20
|
-
|
21
11
|
attr_reader :id, :format, :title, :description, :tags, :sources
|
22
12
|
|
23
13
|
step :validate_id, in: :id
|
@@ -37,10 +37,10 @@ module ConvenientService
|
|
37
37
|
module Examples
|
38
38
|
module Standard
|
39
39
|
module RequestParams
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
include ConvenientService::Feature
|
41
|
+
|
42
|
+
entry :prepare do |request|
|
43
|
+
Services::Prepare[request: request]
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -23,15 +23,16 @@ module ConvenientService
|
|
23
23
|
private
|
24
24
|
|
25
25
|
##
|
26
|
-
#
|
27
|
-
#
|
26
|
+
# @internal
|
27
|
+
# NOTE: `super` is `Logger.new`.
|
28
|
+
# - https://ruby-doc.org/stdlib-3.1.0/libdoc/logger/rdoc/Logger.html#method-c-new
|
28
29
|
#
|
29
30
|
# rubocop:disable Style/GlobalStdStream
|
30
31
|
def new
|
31
|
-
super(STDOUT).tap do |logger|
|
32
|
-
logger.level = ENV["
|
32
|
+
super(::STDOUT).tap do |logger|
|
33
|
+
logger.level = ::ENV["CONVENIENT_SERVICE_LOGGER_LEVEL"] || "INFO"
|
33
34
|
|
34
|
-
logger.formatter = colored_formatter if ENV["
|
35
|
+
logger.formatter = colored_formatter if ::ENV["CONVENIENT_SERVICE_LOGGER_ENABLE_COLORS"] == "true"
|
35
36
|
end
|
36
37
|
end
|
37
38
|
# rubocop:enable Style/GlobalStdStream
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module RSpec
|
5
|
+
module Helpers
|
6
|
+
module Custom
|
7
|
+
# @internal
|
8
|
+
# TODO: Specs.
|
9
|
+
#
|
10
|
+
class InThreads < Support::Command
|
11
|
+
##
|
12
|
+
# @!attribute [r] n
|
13
|
+
# @return [Integer] Amount of threads.
|
14
|
+
#
|
15
|
+
attr_reader :n
|
16
|
+
|
17
|
+
##
|
18
|
+
# @!attribute [r] args
|
19
|
+
# @return [Array<Object>] Args passed to `Thread.new`.
|
20
|
+
#
|
21
|
+
# @internal
|
22
|
+
# NOTE: More info about `args`.
|
23
|
+
# - https://ruby-doc.org/core-2.7.0/Thread.html#method-c-new
|
24
|
+
#
|
25
|
+
attr_reader :args
|
26
|
+
|
27
|
+
##
|
28
|
+
# @!attribute [r] block
|
29
|
+
# @return [Proc] Block passed to `Thread.new`.
|
30
|
+
#
|
31
|
+
# @internal
|
32
|
+
# NOTE: More info about `block`.
|
33
|
+
# - https://ruby-doc.org/core-2.7.0/Thread.html#method-c-new
|
34
|
+
#
|
35
|
+
attr_reader :block
|
36
|
+
|
37
|
+
##
|
38
|
+
# @param n [Integer] Amount of threads.
|
39
|
+
# @param args [Array<Object>] Args passed to `Thread.new`.
|
40
|
+
# @param block [Proc, nil] Block passed to `Thread.new`.
|
41
|
+
# @return [void]
|
42
|
+
#
|
43
|
+
def initialize(n, *args, &block)
|
44
|
+
@n = n
|
45
|
+
@args = args
|
46
|
+
@block = block
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# @return [Array<Object>] Thread values. Can be any type.
|
51
|
+
#
|
52
|
+
# @internal
|
53
|
+
# NOTE: `thread.value` calls `thread.join` under the hood. That is why it is missed here.
|
54
|
+
# - https://ruby-doc.org/core-2.7.0/Thread.html#method-i-value
|
55
|
+
#
|
56
|
+
# TODO: Thread pool? Why?
|
57
|
+
# - https://github.com/toy/in_threads/blob/master/lib/in_threads.rb
|
58
|
+
#
|
59
|
+
def call
|
60
|
+
threads = []
|
61
|
+
|
62
|
+
##
|
63
|
+
# NOTE: CRuby has GIL, so the specs are almost always successful for simple cases.
|
64
|
+
# NOTE: JRuby or TruffleRuby use real threads, so NOT thread-safe code starts to fail even for the simplest cases.
|
65
|
+
#
|
66
|
+
n.times { threads << ::Thread.new(*args, &block) }
|
67
|
+
|
68
|
+
threads.map(&:value)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module RSpec
|
5
|
+
module Helpers
|
6
|
+
module Custom
|
7
|
+
class StubService < Support::Command
|
8
|
+
module Constants
|
9
|
+
module Triggers
|
10
|
+
##
|
11
|
+
# @return [ConvenientService::Support::UniqueValue]
|
12
|
+
#
|
13
|
+
STUB_SERVICE = Support::UniqueValue.new("STUB_SERVICE")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,7 +6,7 @@ module ConvenientService
|
|
6
6
|
module Custom
|
7
7
|
class StubService < Support::Command
|
8
8
|
module Entities
|
9
|
-
class StubbedService
|
9
|
+
class StubbedService
|
10
10
|
##
|
11
11
|
# @param service_class [Class]
|
12
12
|
# @return [void]
|
@@ -17,8 +17,8 @@ module ConvenientService
|
|
17
17
|
end
|
18
18
|
|
19
19
|
##
|
20
|
-
# @param args [Array]
|
21
|
-
# @param kwargs [Hash]
|
20
|
+
# @param args [Array<Object>]
|
21
|
+
# @param kwargs [Hash{Symbol => Object}]
|
22
22
|
# @param block [Block]
|
23
23
|
# @return [ConvenientService::RSpec::Helpers::Custom::StubService::Entities::StubService]
|
24
24
|
#
|
@@ -44,7 +44,7 @@ module ConvenientService
|
|
44
44
|
def to(result_spec)
|
45
45
|
@result_spec = result_spec
|
46
46
|
|
47
|
-
service_class.commit_config!
|
47
|
+
service_class.commit_config!(trigger: Constants::Triggers::STUB_SERVICE)
|
48
48
|
|
49
49
|
service_class.stubbed_results[key] = result_value
|
50
50
|
|
@@ -60,9 +60,9 @@ module ConvenientService
|
|
60
60
|
end
|
61
61
|
|
62
62
|
##
|
63
|
-
# @param args [Array]
|
64
|
-
# @param kwargs [Hash]
|
65
|
-
# @param block [Proc]
|
63
|
+
# @param args [Array<Object>]
|
64
|
+
# @param kwargs [Hash{Symbol => Object}]
|
65
|
+
# @param block [Proc, nil]
|
66
66
|
# @return [Object] Can be any type.
|
67
67
|
#
|
68
68
|
def call(*args, **kwargs, &block)
|
@@ -6,7 +6,7 @@ module ConvenientService
|
|
6
6
|
module Custom
|
7
7
|
class WrapMethod < Support::Command
|
8
8
|
module Errors
|
9
|
-
class ChainAttributePreliminaryAccess < ConvenientService::Error
|
9
|
+
class ChainAttributePreliminaryAccess < ::ConvenientService::Error
|
10
10
|
##
|
11
11
|
# @param attribute [Symbol]
|
12
12
|
# @return [void]
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative "helpers/custom"
|
4
4
|
|
5
5
|
require_relative "helpers/ignoring_error"
|
6
|
+
require_relative "helpers/in_threads"
|
6
7
|
require_relative "helpers/stub_service"
|
7
8
|
require_relative "helpers/wrap_method"
|
8
9
|
|
@@ -13,6 +14,7 @@ module ConvenientService
|
|
13
14
|
|
14
15
|
included do
|
15
16
|
include Helpers::IgnoringError
|
17
|
+
include Helpers::InThreads
|
16
18
|
include Helpers::StubService
|
17
19
|
include Helpers::WrapMethod
|
18
20
|
end
|
@@ -10,7 +10,7 @@ module ConvenientService
|
|
10
10
|
module Entities
|
11
11
|
class ChainingsCollection
|
12
12
|
module Errors
|
13
|
-
class CallOriginalChainingIsAlreadySet < ConvenientService::Error
|
13
|
+
class CallOriginalChainingIsAlreadySet < ::ConvenientService::Error
|
14
14
|
def initialize
|
15
15
|
message = <<~TEXT
|
16
16
|
Call original chaining is already set.
|
@@ -22,7 +22,7 @@ module ConvenientService
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
class ArgumentsChainingIsAlreadySet < ConvenientService::Error
|
25
|
+
class ArgumentsChainingIsAlreadySet < ::ConvenientService::Error
|
26
26
|
def initialize
|
27
27
|
message = <<~TEXT
|
28
28
|
Arguments chaining is already set.
|
@@ -34,7 +34,7 @@ module ConvenientService
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
class ReturnItsValueChainingIsAlreadySet < ConvenientService::Error
|
37
|
+
class ReturnItsValueChainingIsAlreadySet < ::ConvenientService::Error
|
38
38
|
def initialize
|
39
39
|
message = <<~TEXT
|
40
40
|
Returns its value chaining is already set.
|
@@ -30,9 +30,9 @@ module ConvenientService
|
|
30
30
|
##
|
31
31
|
# @param object [Object] Can be any type.
|
32
32
|
# @param method [Symbol]
|
33
|
-
# @param args [Array]
|
34
|
-
# @param kwargs [Hash]
|
35
|
-
# @param block [Proc]
|
33
|
+
# @param args [Array<Object>]
|
34
|
+
# @param kwargs [Hash{Symbol => Object}]
|
35
|
+
# @param block [Proc, nil]
|
36
36
|
# @return [void]
|
37
37
|
#
|
38
38
|
def initialize(object:, method:, args:, kwargs:, block:)
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module RSpec
|
5
|
+
module Matchers
|
6
|
+
module Custom
|
7
|
+
class Export
|
8
|
+
include ConvenientService::DependencyContainer::Import
|
9
|
+
|
10
|
+
import :"constants.DEFAULT_SCOPE", from: ConvenientService::Support::DependencyContainer::Container
|
11
|
+
import :"commands.AssertValidContainer", from: ConvenientService::Support::DependencyContainer::Container
|
12
|
+
import :"commands.AssertValidScope", from: ConvenientService::Support::DependencyContainer::Container
|
13
|
+
|
14
|
+
##
|
15
|
+
# @param full_name [Symbol, String]
|
16
|
+
# @param scope [Symbol]
|
17
|
+
# @return [void]
|
18
|
+
#
|
19
|
+
def initialize(full_name, scope: constants.DEFAULT_SCOPE)
|
20
|
+
@full_name = full_name
|
21
|
+
@scope = scope
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# @param container [Module]
|
26
|
+
# @return [Boolean]
|
27
|
+
#
|
28
|
+
def matches?(container)
|
29
|
+
@container = container
|
30
|
+
|
31
|
+
commands.AssertValidContainer.call(container: container)
|
32
|
+
|
33
|
+
commands.AssertValidScope.call(scope: scope)
|
34
|
+
|
35
|
+
Utils::Bool.to_bool(container.exported_methods.find_by(full_name: full_name, scope: scope))
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# @return [String]
|
40
|
+
#
|
41
|
+
def description
|
42
|
+
"export `#{full_name}` with scope `#{scope}`"
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# @return [String]
|
47
|
+
#
|
48
|
+
def failure_message
|
49
|
+
"expected `#{container}` to export `#{full_name}` with scope `#{scope}`"
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# @return [String]
|
54
|
+
#
|
55
|
+
def failure_message_when_negated
|
56
|
+
"expected `#{container}` NOT to export `#{full_name}` with scope `#{scope}`"
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
##
|
62
|
+
# @!attribute [r] full_name
|
63
|
+
# @return [Symbol, String]
|
64
|
+
#
|
65
|
+
attr_reader :full_name
|
66
|
+
|
67
|
+
##
|
68
|
+
# @!attribute [r] scope
|
69
|
+
# @return [Symbol]
|
70
|
+
#
|
71
|
+
attr_reader :scope
|
72
|
+
|
73
|
+
##
|
74
|
+
# @!attribute [r] container
|
75
|
+
# @return [Module]
|
76
|
+
#
|
77
|
+
attr_reader :container
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module RSpec
|
5
|
+
module Matchers
|
6
|
+
module Custom
|
7
|
+
module Results
|
8
|
+
class Base
|
9
|
+
module Constants
|
10
|
+
module Triggers
|
11
|
+
##
|
12
|
+
# @return [ConvenientService::Support::UniqueValue]
|
13
|
+
#
|
14
|
+
BE_RESULT = Support::UniqueValue.new("BE_RESULT")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "base/commands"
|
4
|
+
require_relative "base/constants"
|
4
5
|
require_relative "base/errors"
|
5
6
|
|
6
7
|
module ConvenientService
|
@@ -28,7 +29,7 @@ module ConvenientService
|
|
28
29
|
##
|
29
30
|
# IMPORTANT: Makes `result.class.include?` from the following line idempotent.
|
30
31
|
#
|
31
|
-
result.commit_config! if result.respond_to?(:commit_config!)
|
32
|
+
result.commit_config!(trigger: Constants::Triggers::BE_RESULT) if result.respond_to?(:commit_config!)
|
32
33
|
|
33
34
|
rules << ->(result) { result.class.include?(Service::Plugins::HasResult::Entities::Result::Concern) }
|
34
35
|
|
@@ -5,6 +5,7 @@ require_relative "custom/be_direct_descendant_of"
|
|
5
5
|
require_relative "custom/cache_its_value"
|
6
6
|
require_relative "custom/call_chain_next"
|
7
7
|
require_relative "custom/delegate_to"
|
8
|
+
require_relative "custom/export"
|
8
9
|
require_relative "custom/extend_module"
|
9
10
|
require_relative "custom/have_abstract_method"
|
10
11
|
require_relative "custom/have_alias_method"
|
@@ -7,6 +7,7 @@ require_relative "matchers/be_direct_descendant_of"
|
|
7
7
|
require_relative "matchers/cache_its_value"
|
8
8
|
require_relative "matchers/call_chain_next"
|
9
9
|
require_relative "matchers/delegate_to"
|
10
|
+
require_relative "matchers/export"
|
10
11
|
require_relative "matchers/extend_module"
|
11
12
|
require_relative "matchers/have_abstract_method"
|
12
13
|
require_relative "matchers/have_alias_method"
|
@@ -29,6 +30,7 @@ module ConvenientService
|
|
29
30
|
include Matchers::CacheItsValue
|
30
31
|
include Matchers::CallChainNext
|
31
32
|
include Matchers::DelegateTo
|
33
|
+
include Matchers::Export
|
32
34
|
include Matchers::ExtendModule
|
33
35
|
include Matchers::HaveAbstractMethod
|
34
36
|
include Matchers::HaveAliasMethod
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module ConvenientService
|
4
4
|
module Plugins
|
5
|
-
Result = ::ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins
|
6
5
|
Service = ::ConvenientService::Service::Plugins
|
7
|
-
Step = ::ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins
|
8
6
|
end
|
9
7
|
end
|
@@ -6,8 +6,8 @@ module ConvenientService
|
|
6
6
|
module CanHaveMethodSteps
|
7
7
|
class Middleware < Core::MethodChainMiddleware
|
8
8
|
##
|
9
|
-
# @param args [Array]
|
10
|
-
# @param kwargs [Hash]
|
9
|
+
# @param args [Array<Object>]
|
10
|
+
# @param kwargs [Hash{Symbol => Object}]
|
11
11
|
# @param block [Proc, nil]
|
12
12
|
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result]
|
13
13
|
#
|
@@ -6,8 +6,8 @@ module ConvenientService
|
|
6
6
|
module CanHaveResultStep
|
7
7
|
class Middleware < Core::MethodChainMiddleware
|
8
8
|
##
|
9
|
-
# @param args [Array]
|
10
|
-
# @param kwargs [Hash]
|
9
|
+
# @param args [Array<Object>]
|
10
|
+
# @param kwargs [Hash{Symbol => Object}]
|
11
11
|
# @param block [Proc, nil]
|
12
12
|
# @return [ConvenientService::Service::Plugins::HasResult::Entities::Result]
|
13
13
|
#
|
@@ -39,8 +39,8 @@ module ConvenientService
|
|
39
39
|
##
|
40
40
|
# Registers a step (step definition).
|
41
41
|
#
|
42
|
-
# @param args [Array]
|
43
|
-
# @param kwargs [Hash]
|
42
|
+
# @param args [Array<Object>]
|
43
|
+
# @param kwargs [Hash{Symbol => Object}]
|
44
44
|
# @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step]
|
45
45
|
#
|
46
46
|
def step(*args, **kwargs)
|
data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method.rb
CHANGED
@@ -7,45 +7,80 @@ module ConvenientService
|
|
7
7
|
module Entities
|
8
8
|
class Method
|
9
9
|
module Commands
|
10
|
-
##
|
11
|
-
# TODO: Abstract factory.
|
12
|
-
#
|
13
10
|
class CastMethod < Support::Command
|
14
|
-
|
11
|
+
##
|
12
|
+
# @!attribute [r] options
|
13
|
+
# @return [Object] Can be any type.
|
14
|
+
#
|
15
|
+
attr_reader :other
|
15
16
|
|
17
|
+
##
|
18
|
+
# @!attribute [r] options
|
19
|
+
# @return [Hash]
|
20
|
+
#
|
21
|
+
attr_reader :options
|
22
|
+
|
23
|
+
##
|
24
|
+
# @param other [Object] Can be any type.
|
25
|
+
# @param options [Hash]
|
26
|
+
#
|
16
27
|
def initialize(other:, options:)
|
17
28
|
@other = other
|
18
29
|
@options = options
|
19
30
|
end
|
20
31
|
|
32
|
+
##
|
33
|
+
# @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method, nil]
|
34
|
+
#
|
35
|
+
# @internal
|
36
|
+
# NOTE: Read more about Composition over Inheritance.
|
37
|
+
# - https://en.wikipedia.org/wiki/Composition_over_inheritance
|
38
|
+
#
|
21
39
|
def call
|
40
|
+
return unless factory
|
22
41
|
return unless key
|
23
42
|
return unless name
|
24
43
|
return unless caller
|
25
44
|
return unless direction
|
26
45
|
|
27
|
-
##
|
28
|
-
# https://en.wikipedia.org/wiki/Composition_over_inheritance
|
29
|
-
#
|
30
46
|
Method.new(key: key, name: name, caller: caller, direction: direction)
|
31
47
|
end
|
32
48
|
|
33
49
|
private
|
34
50
|
|
51
|
+
##
|
52
|
+
# @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method::Entities::Factories::Base]
|
53
|
+
#
|
54
|
+
def factory
|
55
|
+
Utils::Object.memoize_including_falsy_values(self, :@factory) { Commands::CastMethodFactory.call(other: other) }
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method::Entities::Key]
|
60
|
+
#
|
35
61
|
def key
|
36
|
-
|
62
|
+
Utils::Object.memoize_including_falsy_values(self, :@key) { factory&.create_key }
|
37
63
|
end
|
38
64
|
|
65
|
+
##
|
66
|
+
# @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method::Entities::Name]
|
67
|
+
#
|
39
68
|
def name
|
40
|
-
|
69
|
+
Utils::Object.memoize_including_falsy_values(self, :@name) { factory&.create_name }
|
41
70
|
end
|
42
71
|
|
72
|
+
##
|
73
|
+
# @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method::Entities::Callers::Base]
|
74
|
+
#
|
43
75
|
def caller
|
44
|
-
|
76
|
+
Utils::Object.memoize_including_falsy_values(self, :@caller) { factory&.create_caller }
|
45
77
|
end
|
46
78
|
|
79
|
+
##
|
80
|
+
# @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method::Entities::Direction::Base]
|
81
|
+
#
|
47
82
|
def direction
|
48
|
-
|
83
|
+
Utils::Object.memoize_including_falsy_values(self, :@direction) { Commands::CastMethodDirection.call(other: other, options: options) }
|
49
84
|
end
|
50
85
|
end
|
51
86
|
end
|