convenient_service 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -0
- data/lib/convenient_service/configs/minimal.rb +1 -1
- data/lib/convenient_service/configs/standard/aliases.rb +9 -0
- data/lib/convenient_service/configs/standard/v1.rb +183 -0
- data/lib/convenient_service/configs/standard.rb +35 -9
- data/lib/convenient_service/dependencies.rb +13 -10
- 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/parse_content.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile/services/print_shell_command.rb +3 -3
- data/lib/convenient_service/examples/dry/gemfile/services/read_file_content.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile/services/run_shell_command.rb +1 -1
- data/lib/convenient_service/examples/dry/gemfile/services/strip_comments.rb +1 -1
- data/lib/convenient_service/examples/dry/v1/gemfile/dry_service/config.rb +47 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/dry_service.rb +3 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_file_exists.rb +31 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_file_not_empty.rb +31 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_node_available.rb +28 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_npm_package_available.rb +41 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_valid_ruby_syntax.rb +43 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format.rb +39 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_body.rb +95 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_gems_with_envs.rb +98 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_gems_without_envs.rb +86 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_header.rb +76 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/parse_content.rb +95 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/read_file_content.rb +33 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/run_shell_command.rb +43 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services/strip_comments.rb +111 -0
- data/lib/convenient_service/examples/dry/v1/gemfile/services.rb +17 -0
- data/lib/convenient_service/examples/dry/v1/gemfile.rb +27 -0
- data/lib/convenient_service/examples/rails/gemfile/services/assert_file_exists.rb +1 -1
- data/lib/convenient_service/examples/rails/gemfile/services/assert_file_not_empty.rb +1 -1
- data/lib/convenient_service/examples/rails/gemfile/services/parse_content.rb +1 -1
- data/lib/convenient_service/examples/rails/gemfile/services/print_shell_command.rb +3 -3
- data/lib/convenient_service/examples/rails/gemfile/services/read_file_content.rb +1 -1
- data/lib/convenient_service/examples/rails/gemfile/services/run_shell_command.rb +1 -1
- data/lib/convenient_service/examples/rails/gemfile/services/strip_comments.rb +1 -1
- data/lib/convenient_service/examples/rails/v1/gemfile/rails_service/config.rb +58 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/rails_service.rb +3 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_file_exists.rb +27 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_file_not_empty.rb +27 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_node_available.rb +28 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_npm_package_available.rb +37 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_valid_ruby_syntax.rb +37 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format.rb +68 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_body.rb +81 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_gems_with_envs.rb +84 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_gems_without_envs.rb +72 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_header.rb +70 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/merge_sections.rb +27 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/parse_content.rb +91 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/read_file_content.rb +29 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/replace_file_content.rb +39 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/run_shell_command.rb +38 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services/strip_comments.rb +109 -0
- data/lib/convenient_service/examples/rails/v1/gemfile/services.rb +20 -0
- data/lib/convenient_service/examples/rails/v1/gemfile.rb +27 -0
- data/lib/convenient_service/examples/standard/date_time/services/safe_parse.rb +1 -1
- data/lib/convenient_service/examples/standard/factorial/services/calculate.rb +9 -3
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb +3 -3
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_not_empty.rb +3 -3
- data/lib/convenient_service/examples/standard/gemfile/services/assert_npm_package_available.rb +2 -2
- data/lib/convenient_service/examples/standard/gemfile/services/format.rb +4 -4
- data/lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb +4 -4
- data/lib/convenient_service/examples/standard/gemfile/services/parse_content.rb +3 -3
- data/lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb +4 -4
- data/lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb +3 -3
- data/lib/convenient_service/examples/standard/gemfile/services/replace_file_content.rb +3 -3
- data/lib/convenient_service/examples/standard/gemfile/services/run_shell_command.rb +3 -3
- data/lib/convenient_service/examples/standard/gemfile/services/strip_comments.rb +1 -1
- data/lib/convenient_service/examples/standard/v1/cowsay/services/build_cloud.rb +44 -0
- data/lib/convenient_service/examples/standard/v1/cowsay/services/build_cow.rb +40 -0
- data/lib/convenient_service/examples/standard/v1/cowsay/services/print.rb +34 -0
- data/lib/convenient_service/examples/standard/v1/cowsay/services.rb +5 -0
- data/lib/convenient_service/examples/standard/v1/cowsay.rb +26 -0
- data/lib/convenient_service/examples/standard/v1/date_time/services/safe_parse.rb +33 -0
- data/lib/convenient_service/examples/standard/v1/date_time/services.rb +3 -0
- data/lib/convenient_service/examples/standard/v1/date_time.rb +25 -0
- data/lib/convenient_service/examples/standard/v1/factorial/services/calculate.rb +51 -0
- data/lib/convenient_service/examples/standard/v1/factorial/services.rb +3 -0
- data/lib/convenient_service/examples/standard/v1/factorial/utils/timeout/with_timeout.rb +52 -0
- data/lib/convenient_service/examples/standard/v1/factorial/utils/timeout.rb +23 -0
- data/lib/convenient_service/examples/standard/v1/factorial/utils.rb +3 -0
- data/lib/convenient_service/examples/standard/v1/factorial.rb +26 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_exists.rb +32 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_not_empty.rb +32 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_node_available.rb +28 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_npm_package_available.rb +50 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_valid_ruby_syntax.rb +41 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format.rb +82 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_body.rb +85 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_gems_with_envs.rb +88 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_gems_without_envs.rb +76 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_header.rb +68 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb +54 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/parse_content.rb +103 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/print_shell_command.rb +47 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/read_file_content.rb +41 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/replace_file_content.rb +50 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/run_shell_command.rb +52 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services/strip_comments.rb +113 -0
- data/lib/convenient_service/examples/standard/v1/gemfile/services.rb +20 -0
- data/lib/convenient_service/examples/standard/v1/gemfile.rb +26 -0
- data/lib/convenient_service/examples/standard/v1/request_params/constants.rb +17 -0
- data/lib/convenient_service/examples/standard/v1/request_params/entities/description.rb +42 -0
- data/lib/convenient_service/examples/standard/v1/request_params/entities/format.rb +42 -0
- data/lib/convenient_service/examples/standard/v1/request_params/entities/id.rb +49 -0
- data/lib/convenient_service/examples/standard/v1/request_params/entities/logger.rb +23 -0
- data/lib/convenient_service/examples/standard/v1/request_params/entities/request.rb +25 -0
- data/lib/convenient_service/examples/standard/v1/request_params/entities/source.rb +42 -0
- data/lib/convenient_service/examples/standard/v1/request_params/entities/tag.rb +42 -0
- data/lib/convenient_service/examples/standard/v1/request_params/entities/title.rb +42 -0
- data/lib/convenient_service/examples/standard/v1/request_params/entities.rb +11 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services/apply_default_param_values.rb +28 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services/cast_params.rb +40 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_body.rb +72 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_path.rb +64 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services/filter_out_unpermitted_params.rb +28 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services/log_request_params.rb +56 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services/merge_params.rb +28 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services/prepare.rb +67 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services/validate_casted_params.rb +96 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services/validate_uncasted_params.rb +74 -0
- data/lib/convenient_service/examples/standard/v1/request_params/services.rb +13 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/array/wrap.rb +48 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/array.rb +23 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request/parse_body.rb +44 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request/parse_path.rb +42 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request.rb +30 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http.rb +3 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/integer/safe_parse.rb +33 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/integer.rb +27 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/json/safe_parse.rb +42 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/json.rb +23 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/object/blank.rb +36 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/object/present.rb +33 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/object.rb +28 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/url/valid.rb +49 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils/url.rb +23 -0
- data/lib/convenient_service/examples/standard/v1/request_params/utils.rb +8 -0
- data/lib/convenient_service/examples/standard/v1/request_params.rb +50 -0
- data/lib/convenient_service/rspec/matchers/custom/results/base/entities/printers/error/commands/generate_got_jsend_attributes_part.rb +15 -6
- data/lib/convenient_service/rspec/matchers/custom/results/base/entities/printers/failure/commands/generate_got_jsend_attributes_part.rb +24 -16
- data/lib/convenient_service/rspec/matchers/custom/results/base/entities/printers/success/commands/generate_got_jsend_attributes_part.rb +37 -4
- data/lib/convenient_service/rspec/matchers/results/be_result.rb +31 -0
- data/lib/convenient_service/rspec/matchers/results.rb +4 -0
- data/lib/convenient_service/service/plugins/{can_have_fallback → can_have_fallbacks}/concern.rb +29 -17
- data/lib/convenient_service/service/plugins/{can_have_fallback → can_have_fallbacks}/exceptions.rb +7 -7
- data/lib/convenient_service/service/plugins/can_have_fallbacks/middleware.rb +36 -0
- data/lib/convenient_service/service/plugins/can_have_fallbacks.rb +5 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/concern.rb +97 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/middleware.rb +74 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks.rb +4 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/commands.rb +0 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/concern/class_methods.rb +10 -17
- data/lib/convenient_service/service/plugins/has_j_send_result/concern/instance_methods.rb +0 -9
- data/lib/convenient_service/service/plugins/has_j_send_result/constants.rb +4 -4
- data/lib/convenient_service/service/plugins/has_j_send_result/container.rb +8 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/{can_have_fallback → can_have_fallbacks}/concern.rb +16 -2
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_fallbacks.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_awesome_print_inspect/concern.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_inspect/concern.rb +9 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb +7 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/concern/instance_methods.rb +7 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_active_model_validations/middleware.rb +18 -7
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_dry_validation/middleware.rb +26 -4
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/exceptions.rb +41 -0
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/middleware.rb +33 -6
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error.rb +0 -1
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/failure/exceptions.rb +67 -6
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/failure/middleware.rb +36 -3
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/failure.rb +0 -1
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/commands/refute_kwargs_contain_j_send_and_extra_keys.rb +67 -0
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/commands.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/exceptions.rb +15 -2
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/middleware.rb +8 -2
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb +11 -3
- data/lib/convenient_service/service/plugins.rb +1 -1
- data/lib/convenient_service/version.rb +1 -1
- metadata +125 -18
- data/lib/convenient_service/service/plugins/can_have_fallback/middleware.rb +0 -30
- data/lib/convenient_service/service/plugins/can_have_fallback.rb +0 -5
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallback/concern.rb +0 -53
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallback/middleware.rb +0 -34
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallback.rb +0 -4
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_fallback.rb +0 -3
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/commands/assert_args_count_lower_than_three.rb +0 -25
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/commands/assert_either_args_or_kwargs_are_passed.rb +0 -26
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/commands.rb +0 -4
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/failure/commands/assert_kwargs_contain_only_j_send_keys.rb +0 -53
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/failure/commands.rb +0 -3
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/commands/refute_kwargs_contain_data_and_extra_keys.rb +0 -29
- /data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/{can_have_fallback → can_have_fallbacks}/result.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e849e1385e9637d36289bfeb4e78eccddd53b22f5f9e828c5a35c8c90967954d
|
4
|
+
data.tar.gz: 9538a0fb396cbe7a9f04879845a25287145021b4bfa17ea78eaf4e54643552d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4cc32889e3c0958bc5acebc744a01b9fc80c0fa2c7a7c3a609ffd4a9d8254822d0ad4a8c1d75fd2ce39472b2ededc2ef69b3d899edcda406f1eff99b06df2b8
|
7
|
+
data.tar.gz: 30bf372859ef693d1d67058a886065eb7db3b3dddb530cc585e471417a94ccedfac1c86d17df56881c3f5849b04d6a0a64b752746209afa5d860f9f35f3b3689
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,50 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.14.0](https://github.com/marian13/convenient_service/compare/v0.13.0...v0.14.0) (2023-09-20)
|
4
|
+
|
5
|
+
|
6
|
+
### ⚠ BREAKING CHANGES
|
7
|
+
|
8
|
+
* **has_j_send_result_params_validations:** return errors on validation issues
|
9
|
+
* **has_j_send_result_params_validations:** return errors on validation issues
|
10
|
+
* **can_have_fallbacks:** fallback only failures by default
|
11
|
+
* **be_result:** update got part
|
12
|
+
* **has_j_send_result_short:** update constants
|
13
|
+
* **fallbacks:** create separate fallbacks failures and errors, run only error fallback when true
|
14
|
+
|
15
|
+
### Features
|
16
|
+
|
17
|
+
* **be_result:** introduce be_result ([f8fc85b](https://github.com/marian13/convenient_service/commit/f8fc85bb9141851c130a040731e4bb99114050d2))
|
18
|
+
* **can_have_fallbacks:** allow to pass fallback_true_status ([584dabe](https://github.com/marian13/convenient_service/commit/584dabe83f87c2d794ea779a3e5c7f0b0ea97f65))
|
19
|
+
* **can_have_fallbacks:** fallback only failures by default ([58650a7](https://github.com/marian13/convenient_service/commit/58650a736be0a4daaf283c6eef9e0867a34d44d4))
|
20
|
+
* **configs:** create copy of v1 ([bb039c8](https://github.com/marian13/convenient_service/commit/bb039c83f53607c4cf59f634c662fc604f13ff7b))
|
21
|
+
* **examples:** create copy of v1 ([70bd3fe](https://github.com/marian13/convenient_service/commit/70bd3febc4a88ebe7e7c3d33c7dd2e1c03331ccb))
|
22
|
+
* **has_awesome_print_inspect:** add message and data keys ([14e0a3f](https://github.com/marian13/convenient_service/commit/14e0a3f088edf8ea8565ba7ff06ca0212c4116e9))
|
23
|
+
* **has_inspect:** add message and data keys ([8f30b7a](https://github.com/marian13/convenient_service/commit/8f30b7a905b8a953d514061ed381a404b65c81af))
|
24
|
+
* **has_j_send_result_params_validations:** return errors on validation issues ([e25e1a4](https://github.com/marian13/convenient_service/commit/e25e1a4f94cc309035533220dbcfbfccbb94cc94))
|
25
|
+
* **has_j_send_result_params_validations:** return errors on validation issues ([09a9b94](https://github.com/marian13/convenient_service/commit/09a9b948070f3132818d1da9ef009d1d15655ab9))
|
26
|
+
* **has_j_send_result_short_syntax:** allow to pass data, message, code to all results ([aabf2f9](https://github.com/marian13/convenient_service/commit/aabf2f98d32407616159cbcd2bcc6349a9a3b98f))
|
27
|
+
* **has_j_send_result_short_syntax:** allow to pass message and code to short form of error ([1af3153](https://github.com/marian13/convenient_service/commit/1af3153aa1bf385eadcf73f30e13a3cc5126d793))
|
28
|
+
* **has_j_send_result_short_syntax:** allow to pass message and code to short form of failure ([7390630](https://github.com/marian13/convenient_service/commit/73906300f94ec6488f312d4a611f433d8c850691))
|
29
|
+
* **has_j_send_result_short_syntax:** allow to pass message and code to short form of success ([fdf2ab2](https://github.com/marian13/convenient_service/commit/fdf2ab23ade8941ed2c6dd10d17769eaebecc855))
|
30
|
+
* **has_j_send_status_and_attributes:** introduce Data#keys ([27f43e1](https://github.com/marian13/convenient_service/commit/27f43e1594988cc523e9bb3608e90a40e4c2b442))
|
31
|
+
* **has_j_send_status_and_attributes:** introduce Message#empty? ([6c1452d](https://github.com/marian13/convenient_service/commit/6c1452d99d71be45bb6cb95159a2fd32ffca668e))
|
32
|
+
* **rescues_result_unhandled_exceptions:** allow to pass status ([2ef85f2](https://github.com/marian13/convenient_service/commit/2ef85f2970dd56802bd22f467529da6242faf967))
|
33
|
+
* **using_active_model_validations:** allow to pass status to middleware ([bc5bb70](https://github.com/marian13/convenient_service/commit/bc5bb7027fe94724a8d28a3770b68c731b37ff10))
|
34
|
+
* **using_dry_validation:** allow to pass status to middleware ([3a5ef12](https://github.com/marian13/convenient_service/commit/3a5ef120219a8a94b1d15bb7226f265db967ce9e))
|
35
|
+
|
36
|
+
|
37
|
+
### Miscellaneous Chores
|
38
|
+
|
39
|
+
* release 0.14.0 ([c7cef07](https://github.com/marian13/convenient_service/commit/c7cef0721d8360329c19b8ad4d636bcec83805c6))
|
40
|
+
|
41
|
+
|
42
|
+
### Code Refactoring
|
43
|
+
|
44
|
+
* **be_result:** update got part ([428280a](https://github.com/marian13/convenient_service/commit/428280a8eb2aed09f49bd949f84b7e10ef933708))
|
45
|
+
* **fallbacks:** create separate fallbacks failures and errors, run only error fallback when true ([bbab564](https://github.com/marian13/convenient_service/commit/bbab5647d09ecdba9c9727bef3e2dc6b8138710b))
|
46
|
+
* **has_j_send_result_short:** update constants ([2074acd](https://github.com/marian13/convenient_service/commit/2074acd001115dd4c60d432e71a4fef58794c881))
|
47
|
+
|
3
48
|
## 0.13.0 (2023-08-27)
|
4
49
|
|
5
50
|
|
@@ -18,7 +18,7 @@ module ConvenientService
|
|
18
18
|
# # ...
|
19
19
|
# end
|
20
20
|
#
|
21
|
-
# In turn, `:fallback_result` is added by `use Plugins::Service::
|
21
|
+
# In turn, `:fallback_result` is added by `use Plugins::Service::CanHaveFallbacks::Concern` in `Standard`.
|
22
22
|
# That is why it is the responsibility of the `Standard` config, to define:
|
23
23
|
#
|
24
24
|
# middlewares :fallback_result do
|
@@ -0,0 +1,183 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Configs
|
5
|
+
##
|
6
|
+
# Default configuration for the user-defined services.
|
7
|
+
#
|
8
|
+
module Standard
|
9
|
+
module V1
|
10
|
+
include Support::Concern
|
11
|
+
|
12
|
+
##
|
13
|
+
# @internal
|
14
|
+
# IMPORTANT: Order of plugins matters.
|
15
|
+
#
|
16
|
+
# NOTE: `class_exec` (that is used under the hood by `included`) defines `class Result` in the global namespace.
|
17
|
+
# That is why `class self::Result` is used.
|
18
|
+
# - https://stackoverflow.com/a/51965126/12201472
|
19
|
+
#
|
20
|
+
# rubocop:disable Lint/ConstantDefinitionInBlock
|
21
|
+
included do
|
22
|
+
include Configs::Minimal
|
23
|
+
|
24
|
+
concerns do
|
25
|
+
use Plugins::Common::CachesConstructorArguments::Concern
|
26
|
+
use Plugins::Common::CanBeCopied::Concern
|
27
|
+
use Plugins::Service::CanRecalculateResult::Concern
|
28
|
+
use Plugins::Service::HasJSendResultShortSyntax::Concern
|
29
|
+
use Plugins::Service::HasJSendResultStatusCheckShortSyntax::Concern
|
30
|
+
|
31
|
+
use Plugins::Common::HasCallbacks::Concern
|
32
|
+
use Plugins::Common::HasAroundCallbacks::Concern
|
33
|
+
|
34
|
+
use Plugins::Service::HasMermaidFlowchart::Concern
|
35
|
+
end
|
36
|
+
|
37
|
+
middlewares :initialize do
|
38
|
+
use Plugins::Service::CollectsServicesInException::Middleware
|
39
|
+
use Plugins::Common::CachesConstructorArguments::Middleware
|
40
|
+
end
|
41
|
+
|
42
|
+
middlewares :result do
|
43
|
+
insert_after \
|
44
|
+
Plugins::Common::NormalizesEnv::Middleware,
|
45
|
+
Plugins::Service::CollectsServicesInException::Middleware
|
46
|
+
|
47
|
+
insert_before \
|
48
|
+
Plugins::Service::RaisesOnNotResultReturnValue::Middleware,
|
49
|
+
Plugins::Common::HasCallbacks::Middleware
|
50
|
+
|
51
|
+
insert_after \
|
52
|
+
Plugins::Common::HasCallbacks::Middleware,
|
53
|
+
Plugins::Common::HasAroundCallbacks::Middleware
|
54
|
+
|
55
|
+
##
|
56
|
+
# TODO: Rewrite. This plugin does NOT do what it states. Probably I was NOT with a clear mind while writing it (facepalm).
|
57
|
+
#
|
58
|
+
# use Plugins::Service::RaisesOnDoubleResult::Middleware
|
59
|
+
|
60
|
+
insert_before \
|
61
|
+
Plugins::Service::RaisesOnNotResultReturnValue::Middleware,
|
62
|
+
Plugins::Service::SetsParentToForeignResult::Middleware
|
63
|
+
end
|
64
|
+
|
65
|
+
middlewares :step do
|
66
|
+
use Plugins::Common::HasCallbacks::Middleware
|
67
|
+
use Plugins::Common::HasAroundCallbacks::Middleware
|
68
|
+
end
|
69
|
+
|
70
|
+
middlewares :success do
|
71
|
+
use Plugins::Service::HasJSendResultShortSyntax::Success::Middleware
|
72
|
+
end
|
73
|
+
|
74
|
+
middlewares :failure do
|
75
|
+
use Plugins::Service::HasJSendResultShortSyntax::Failure::Middleware
|
76
|
+
end
|
77
|
+
|
78
|
+
middlewares :error do
|
79
|
+
use Plugins::Service::HasJSendResultShortSyntax::Error::Middleware
|
80
|
+
end
|
81
|
+
|
82
|
+
class self::Result
|
83
|
+
concerns do
|
84
|
+
use Plugins::Common::HasJSendResultDuckShortSyntax::Concern
|
85
|
+
use Plugins::Result::CanRecalculateResult::Concern
|
86
|
+
|
87
|
+
use Plugins::Result::CanHaveStep::Concern
|
88
|
+
use Plugins::Result::CanBeOwnResult::Concern
|
89
|
+
use Plugins::Result::CanHaveParentResult::Concern
|
90
|
+
use Plugins::Result::CanHaveCheckedStatus::Concern
|
91
|
+
end
|
92
|
+
|
93
|
+
middlewares :success? do
|
94
|
+
use Plugins::Result::CanHaveCheckedStatus::Middleware
|
95
|
+
end
|
96
|
+
|
97
|
+
middlewares :failure? do
|
98
|
+
use Plugins::Result::CanHaveCheckedStatus::Middleware
|
99
|
+
end
|
100
|
+
|
101
|
+
middlewares :error? do
|
102
|
+
use Plugins::Result::CanHaveCheckedStatus::Middleware
|
103
|
+
end
|
104
|
+
|
105
|
+
middlewares :not_success? do
|
106
|
+
use Plugins::Result::CanHaveCheckedStatus::Middleware
|
107
|
+
end
|
108
|
+
|
109
|
+
middlewares :not_failure? do
|
110
|
+
use Plugins::Result::CanHaveCheckedStatus::Middleware
|
111
|
+
end
|
112
|
+
|
113
|
+
middlewares :not_error? do
|
114
|
+
use Plugins::Result::CanHaveCheckedStatus::Middleware
|
115
|
+
end
|
116
|
+
|
117
|
+
middlewares :data do
|
118
|
+
use Plugins::Result::RaisesOnNotCheckedResultStatus::Middleware
|
119
|
+
end
|
120
|
+
|
121
|
+
middlewares :message do
|
122
|
+
use Plugins::Result::RaisesOnNotCheckedResultStatus::Middleware
|
123
|
+
end
|
124
|
+
|
125
|
+
middlewares :code do
|
126
|
+
use Plugins::Result::RaisesOnNotCheckedResultStatus::Middleware
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
class self::Step
|
131
|
+
concerns do
|
132
|
+
use Plugins::Common::HasJSendResultDuckShortSyntax::Concern
|
133
|
+
end
|
134
|
+
|
135
|
+
middlewares :result do
|
136
|
+
use Plugins::Step::CanHaveParentResult::Middleware
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
if Dependencies.rspec.loaded?
|
141
|
+
concerns do
|
142
|
+
insert_before 0, Plugins::Service::CanHaveStubbedResults::Concern
|
143
|
+
end
|
144
|
+
|
145
|
+
middlewares :result do
|
146
|
+
insert_after \
|
147
|
+
Plugins::Common::NormalizesEnv::Middleware,
|
148
|
+
Plugins::Service::CanHaveStubbedResults::Middleware
|
149
|
+
|
150
|
+
insert_before \
|
151
|
+
Plugins::Service::CanHaveStubbedResults::Middleware,
|
152
|
+
Plugins::Service::CountsStubbedResultsInvocations::Middleware
|
153
|
+
end
|
154
|
+
|
155
|
+
middlewares :result, scope: :class do
|
156
|
+
insert_after \
|
157
|
+
Plugins::Common::NormalizesEnv::Middleware,
|
158
|
+
Plugins::Service::CanHaveStubbedResults::Middleware
|
159
|
+
|
160
|
+
insert_before \
|
161
|
+
Plugins::Service::CanHaveStubbedResults::Middleware,
|
162
|
+
Plugins::Service::CountsStubbedResultsInvocations::Middleware
|
163
|
+
end
|
164
|
+
|
165
|
+
class self::Result
|
166
|
+
concerns do
|
167
|
+
use Plugins::Result::CanBeStubbedResult::Concern
|
168
|
+
use Plugins::Result::HasStubbedResultInvocationsCounter::Concern
|
169
|
+
end
|
170
|
+
|
171
|
+
middlewares :initialize do
|
172
|
+
insert_before \
|
173
|
+
Plugins::Result::HasJSendStatusAndAttributes::Middleware,
|
174
|
+
Plugins::Result::HasStubbedResultInvocationsCounter::Middleware
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
# rubocop:enable Lint/ConstantDefinitionInBlock
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "standard/v1"
|
4
|
+
require_relative "standard/aliases"
|
5
|
+
|
3
6
|
module ConvenientService
|
4
7
|
module Configs
|
5
8
|
##
|
@@ -30,7 +33,7 @@ module ConvenientService
|
|
30
33
|
use Plugins::Common::HasCallbacks::Concern
|
31
34
|
use Plugins::Common::HasAroundCallbacks::Concern
|
32
35
|
|
33
|
-
use Plugins::Service::
|
36
|
+
use Plugins::Service::CanHaveFallbacks::Concern
|
34
37
|
use Plugins::Service::HasMermaidFlowchart::Concern
|
35
38
|
end
|
36
39
|
|
@@ -64,15 +67,28 @@ module ConvenientService
|
|
64
67
|
|
65
68
|
##
|
66
69
|
# @internal
|
67
|
-
# NOTE: Check `Minimal` docs to understand why `use Plugins::Common::NormalizesEnv::Middleware` for `:
|
70
|
+
# NOTE: Check `Minimal` docs to understand why `use Plugins::Common::NormalizesEnv::Middleware` for `:fallback_failure_result` is used in `Standard`, not in `Minimal` config.
|
68
71
|
#
|
69
|
-
middlewares :
|
72
|
+
middlewares :fallback_failure_result do
|
70
73
|
use Plugins::Common::NormalizesEnv::Middleware
|
71
74
|
use Plugins::Service::CollectsServicesInException::Middleware
|
72
75
|
use Plugins::Common::CachesReturnValue::Middleware
|
73
76
|
|
74
77
|
use Plugins::Service::RaisesOnNotResultReturnValue::Middleware
|
75
|
-
use Plugins::Service::
|
78
|
+
use Plugins::Service::CanHaveFallbacks::Middleware.with(status: :failure)
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# @internal
|
83
|
+
# NOTE: Check `Minimal` docs to understand why `use Plugins::Common::NormalizesEnv::Middleware` for `:fallback_error_result` is used in `Standard`, not in `Minimal` config.
|
84
|
+
#
|
85
|
+
middlewares :fallback_error_result do
|
86
|
+
use Plugins::Common::NormalizesEnv::Middleware
|
87
|
+
use Plugins::Service::CollectsServicesInException::Middleware
|
88
|
+
use Plugins::Common::CachesReturnValue::Middleware
|
89
|
+
|
90
|
+
use Plugins::Service::RaisesOnNotResultReturnValue::Middleware
|
91
|
+
use Plugins::Service::CanHaveFallbacks::Middleware.with(status: :error)
|
76
92
|
end
|
77
93
|
|
78
94
|
middlewares :step do
|
@@ -99,7 +115,7 @@ module ConvenientService
|
|
99
115
|
|
100
116
|
use Plugins::Result::CanHaveStep::Concern
|
101
117
|
use Plugins::Result::CanBeOwnResult::Concern
|
102
|
-
use Plugins::Result::
|
118
|
+
use Plugins::Result::CanHaveFallbacks::Concern
|
103
119
|
use Plugins::Result::CanHaveParentResult::Concern
|
104
120
|
use Plugins::Result::CanHaveCheckedStatus::Concern
|
105
121
|
end
|
@@ -144,20 +160,30 @@ module ConvenientService
|
|
144
160
|
class self::Step
|
145
161
|
concerns do
|
146
162
|
use Plugins::Common::HasJSendResultDuckShortSyntax::Concern
|
147
|
-
use Plugins::Step::
|
163
|
+
use Plugins::Step::CanHaveFallbacks::Concern
|
148
164
|
end
|
149
165
|
|
150
166
|
middlewares :result do
|
151
|
-
use Plugins::Step::
|
167
|
+
use Plugins::Step::CanHaveFallbacks::Middleware.with(fallback_true_status: :failure)
|
152
168
|
use Plugins::Step::CanHaveParentResult::Middleware
|
153
169
|
end
|
154
170
|
|
155
|
-
middlewares :
|
171
|
+
middlewares :service_fallback_failure_result do
|
172
|
+
use Plugins::Common::NormalizesEnv::Middleware
|
173
|
+
use Plugins::Common::CachesReturnValue::Middleware
|
174
|
+
end
|
175
|
+
|
176
|
+
middlewares :fallback_failure_result do
|
177
|
+
use Plugins::Common::NormalizesEnv::Middleware
|
178
|
+
use Plugins::Common::CachesReturnValue::Middleware
|
179
|
+
end
|
180
|
+
|
181
|
+
middlewares :service_fallback_error_result do
|
156
182
|
use Plugins::Common::NormalizesEnv::Middleware
|
157
183
|
use Plugins::Common::CachesReturnValue::Middleware
|
158
184
|
end
|
159
185
|
|
160
|
-
middlewares :
|
186
|
+
middlewares :fallback_error_result do
|
161
187
|
use Plugins::Common::NormalizesEnv::Middleware
|
162
188
|
use Plugins::Common::CachesReturnValue::Middleware
|
163
189
|
end
|
@@ -292,9 +292,10 @@ module ConvenientService
|
|
292
292
|
#
|
293
293
|
# Loads standard config examples.
|
294
294
|
#
|
295
|
+
# @param version [String]
|
295
296
|
# @return [Boolean]
|
296
297
|
#
|
297
|
-
def require_standard_examples
|
298
|
+
def require_standard_examples(version: "")
|
298
299
|
##
|
299
300
|
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/date/rdoc/Date.html
|
300
301
|
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/date/rdoc/DateTime.html
|
@@ -325,11 +326,11 @@ module ConvenientService
|
|
325
326
|
#
|
326
327
|
require "uri"
|
327
328
|
|
328
|
-
require_relative "examples
|
329
|
-
require_relative "examples
|
330
|
-
require_relative "examples
|
331
|
-
require_relative "examples
|
332
|
-
require_relative "examples
|
329
|
+
require_relative ::File.join("examples", "standard", version, "cowsay")
|
330
|
+
require_relative ::File.join("examples", "standard", version, "date_time")
|
331
|
+
require_relative ::File.join("examples", "standard", version, "factorial")
|
332
|
+
require_relative ::File.join("examples", "standard", version, "gemfile")
|
333
|
+
require_relative ::File.join("examples", "standard", version, "request_params")
|
333
334
|
end
|
334
335
|
|
335
336
|
##
|
@@ -337,9 +338,10 @@ module ConvenientService
|
|
337
338
|
#
|
338
339
|
# Loads rails config examples.
|
339
340
|
#
|
341
|
+
# @param version [String]
|
340
342
|
# @return [Boolean]
|
341
343
|
#
|
342
|
-
def require_rails_examples
|
344
|
+
def require_rails_examples(version: "")
|
343
345
|
##
|
344
346
|
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html
|
345
347
|
# - https://github.com/flori/json
|
@@ -357,7 +359,7 @@ module ConvenientService
|
|
357
359
|
#
|
358
360
|
require "webrick"
|
359
361
|
|
360
|
-
require_relative "examples
|
362
|
+
require_relative ::File.join("examples", "rails", version, "gemfile")
|
361
363
|
end
|
362
364
|
|
363
365
|
##
|
@@ -365,9 +367,10 @@ module ConvenientService
|
|
365
367
|
#
|
366
368
|
# Loads dry config examples.
|
367
369
|
#
|
370
|
+
# @param version [String]
|
368
371
|
# @return [Boolean]
|
369
372
|
#
|
370
|
-
def require_dry_examples
|
373
|
+
def require_dry_examples(version: "")
|
371
374
|
##
|
372
375
|
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html
|
373
376
|
# - https://github.com/flori/json
|
@@ -385,7 +388,7 @@ module ConvenientService
|
|
385
388
|
#
|
386
389
|
require "webrick"
|
387
390
|
|
388
|
-
require_relative "examples
|
391
|
+
require_relative ::File.join("examples", "dry", version, "gemfile")
|
389
392
|
end
|
390
393
|
|
391
394
|
##
|
@@ -3,7 +3,7 @@
|
|
3
3
|
##
|
4
4
|
# Usage example:
|
5
5
|
#
|
6
|
-
# ConvenientService::Examples::Dry::Gemfile::Services::PrintShellCommand.result(
|
6
|
+
# ConvenientService::Examples::Dry::Gemfile::Services::PrintShellCommand.result(command: "ls -a")
|
7
7
|
#
|
8
8
|
module ConvenientService
|
9
9
|
module Examples
|
@@ -24,7 +24,7 @@ module ConvenientService
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def result
|
27
|
-
return
|
27
|
+
return failure("Printing of shell command `#{command}` is skipped") if skip
|
28
28
|
|
29
29
|
out.puts
|
30
30
|
|
@@ -33,7 +33,7 @@ module ConvenientService
|
|
33
33
|
success
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def fallback_failure_result
|
37
37
|
success
|
38
38
|
end
|
39
39
|
end
|
@@ -28,7 +28,7 @@ module ConvenientService
|
|
28
28
|
step :result, in: :file_without_comments, out: :content_without_comments
|
29
29
|
|
30
30
|
def result
|
31
|
-
success(
|
31
|
+
success(content_without_comments: file_without_comments.read)
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
# Usage example:
|
5
|
+
#
|
6
|
+
# result = ConvenientService::Examples::Dry::V1::Gemfile.format(path: "Gemfile")
|
7
|
+
# result = ConvenientService::Examples::Dry::V1::Gemfile.format(path: "spec/cli/gemfile/format/fixtures/Gemfile")
|
8
|
+
#
|
9
|
+
module ConvenientService
|
10
|
+
module Examples
|
11
|
+
module Dry
|
12
|
+
module V1
|
13
|
+
class Gemfile
|
14
|
+
class DryService
|
15
|
+
module Config
|
16
|
+
include Support::Concern
|
17
|
+
|
18
|
+
included do
|
19
|
+
include ConvenientService::Standard::V1::Config
|
20
|
+
|
21
|
+
##
|
22
|
+
# NOTE: `AssignsAttributesInConstructor::UsingDryInitializer` plugin.
|
23
|
+
#
|
24
|
+
concerns do
|
25
|
+
use ConvenientService::Plugins::Common::AssignsAttributesInConstructor::UsingDryInitializer::Concern
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# NOTE: `HasJSendResultParamsValidations::UsingDryValidation` plugin.
|
30
|
+
#
|
31
|
+
concerns do
|
32
|
+
use ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingDryValidation::Concern
|
33
|
+
end
|
34
|
+
|
35
|
+
middlewares :result do
|
36
|
+
insert_before \
|
37
|
+
ConvenientService::Plugins::Service::RaisesOnNotResultReturnValue::Middleware,
|
38
|
+
ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingDryValidation::Middleware.with(status: :failure)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Examples
|
5
|
+
module Dry
|
6
|
+
module V1
|
7
|
+
class Gemfile
|
8
|
+
module Services
|
9
|
+
class AssertFileExists
|
10
|
+
include DryService::Config
|
11
|
+
|
12
|
+
option :path
|
13
|
+
|
14
|
+
contract do
|
15
|
+
schema do
|
16
|
+
required(:path).filled(:string)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def result
|
21
|
+
return error("File with path `#{path}` does NOT exist") unless ::File.exist?(path)
|
22
|
+
|
23
|
+
success
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Examples
|
5
|
+
module Dry
|
6
|
+
module V1
|
7
|
+
class Gemfile
|
8
|
+
module Services
|
9
|
+
class AssertFileNotEmpty
|
10
|
+
include DryService::Config
|
11
|
+
|
12
|
+
option :path
|
13
|
+
|
14
|
+
contract do
|
15
|
+
schema do
|
16
|
+
required(:path).filled(:string)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def result
|
21
|
+
return error(message: "File with path `#{path}` is empty") if ::File.zero?(path)
|
22
|
+
|
23
|
+
success
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
# Usage example:
|
5
|
+
#
|
6
|
+
# ConvenientService::Examples::Dry::V1::Gemfile::Services::AssertNodeAvailable.result
|
7
|
+
#
|
8
|
+
module ConvenientService
|
9
|
+
module Examples
|
10
|
+
module Dry
|
11
|
+
module V1
|
12
|
+
class Gemfile
|
13
|
+
module Services
|
14
|
+
class AssertNodeAvailable
|
15
|
+
include DryService::Config
|
16
|
+
|
17
|
+
##
|
18
|
+
# NOTE: `> /dev/null 2>&1` is used to hide output.
|
19
|
+
# https://unix.stackexchange.com/a/119650/394253
|
20
|
+
#
|
21
|
+
step Services::RunShellCommand, in: {command: -> { "which node > /dev/null 2>&1" }}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|