convenient_service 0.17.0 → 0.18.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.
Files changed (406) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/lib/convenient_service/common/plugins/ensures_negated_j_send_result/middleware.rb +22 -0
  4. data/lib/convenient_service/common/plugins/ensures_negated_j_send_result.rb +3 -0
  5. data/lib/convenient_service/common/plugins/has_around_callbacks/concern.rb +8 -1
  6. data/lib/convenient_service/common/plugins/has_around_callbacks/middleware.rb +28 -7
  7. data/lib/convenient_service/common/plugins/has_callbacks/concern.rb +19 -9
  8. data/lib/convenient_service/common/plugins/has_callbacks/entities/callback_collection.rb +49 -1
  9. data/lib/convenient_service/common/plugins/has_callbacks/middleware.rb +21 -3
  10. data/lib/convenient_service/common/plugins/has_callbacks.rb +0 -1
  11. data/lib/convenient_service/common/plugins/has_instance_proxy/entities/instance_proxy.rb +1 -1
  12. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/concern.rb +12 -0
  13. data/lib/convenient_service/common/plugins.rb +1 -0
  14. data/lib/convenient_service/core/entities/config/exceptions.rb +2 -0
  15. data/lib/convenient_service/core/entities/config.rb +3 -0
  16. data/lib/convenient_service/dependencies.rb +11 -3
  17. data/lib/convenient_service/logger.rb +9 -1
  18. data/lib/convenient_service/rspec/matchers/classes/call_chain_next.rb +41 -0
  19. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb +46 -0
  20. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/delegation.rb +89 -0
  21. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb +223 -0
  22. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/outputs.rb +38 -0
  23. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb +157 -0
  24. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/apply_stub_to_track_delegations.rb +77 -0
  25. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb +94 -0
  26. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments.rb +89 -0
  27. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/base.rb +99 -0
  28. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_custom_value.rb +91 -0
  29. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_delegation_value.rb +129 -0
  30. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/with_any_arguments.rb +31 -0
  31. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/with_concrete_arguments.rb +31 -0
  32. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/without_arguments.rb +31 -0
  33. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers.rb +11 -0
  34. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities.rb +5 -1
  35. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/exceptions.rb +65 -0
  36. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to.rb +163 -41
  37. data/lib/convenient_service/service/configs/minimal.rb +85 -33
  38. data/lib/convenient_service/service/configs/standard/v1.rb +42 -24
  39. data/lib/convenient_service/service/configs/standard.rb +60 -46
  40. data/lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb +503 -0
  41. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb +133 -0
  42. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/base.rb +126 -0
  43. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/empty.rb +104 -0
  44. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/group.rb +118 -0
  45. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/not.rb +118 -0
  46. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb +145 -0
  47. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/scalar.rb +133 -0
  48. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions.rb +10 -0
  49. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb +217 -0
  50. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities.rb +4 -0
  51. data/lib/convenient_service/service/plugins/can_have_connected_steps/exceptions.rb +95 -0
  52. data/lib/convenient_service/service/plugins/can_have_connected_steps/middleware.rb +30 -0
  53. data/lib/convenient_service/service/plugins/can_have_connected_steps.rb +6 -0
  54. data/lib/convenient_service/service/plugins/can_have_sequential_steps/concern.rb +76 -0
  55. data/lib/convenient_service/service/plugins/{can_have_steps → can_have_sequential_steps}/entities/step_collection.rb +54 -10
  56. data/lib/convenient_service/service/plugins/can_have_sequential_steps/entities.rb +3 -0
  57. data/lib/convenient_service/service/plugins/{can_have_steps → can_have_sequential_steps}/middleware.rb +7 -3
  58. data/lib/convenient_service/service/plugins/can_have_sequential_steps.rb +5 -0
  59. data/lib/convenient_service/service/plugins/can_have_steps/concern.rb +4 -57
  60. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/define_method_in_container.rb +45 -26
  61. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/reassignment.rb +0 -2
  62. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/exceptions.rb +4 -24
  63. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/concern/instance_methods.rb +155 -80
  64. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/exceptions.rb +19 -0
  65. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/{can_be_result_step → can_be_method_step}/can_be_executed/exceptions.rb +1 -1
  66. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/can_be_executed/middleware.rb +64 -4
  67. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/can_be_executed.rb +1 -0
  68. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/concern.rb +7 -0
  69. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_alternative_steps.rb +3 -0
  70. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/concern.rb +0 -46
  71. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/middleware.rb +26 -2
  72. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_parent_result/middleware.rb +13 -1
  73. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/{can_be_result_step → has_result}/concern.rb +8 -4
  74. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result/middleware.rb +33 -0
  75. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result.rb +4 -0
  76. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +2 -1
  77. data/lib/convenient_service/service/plugins/can_have_steps/entities.rb +0 -1
  78. data/lib/convenient_service/service/plugins/can_have_steps.rb +0 -1
  79. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/concern.rb +2 -2
  80. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status.rb +0 -1
  81. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb +135 -2
  82. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern/instance_methods.rb +45 -17
  83. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/can_be_checked/concern.rb +38 -0
  84. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/can_be_checked/middleware.rb +51 -0
  85. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/can_be_checked.rb +4 -0
  86. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins.rb +1 -0
  87. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/exceptions.rb +15 -0
  88. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_negated_result/concern.rb +72 -0
  89. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_negated_result.rb +3 -0
  90. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/raises_on_not_checked_result_status/middleware.rb +1 -1
  91. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins.rb +1 -0
  92. data/lib/convenient_service/service/plugins/has_j_send_result.rb +0 -1
  93. data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_dry_validation/middleware.rb +4 -0
  94. data/lib/convenient_service/service/plugins/has_negated_j_send_result/concern.rb +23 -0
  95. data/lib/convenient_service/service/plugins/has_negated_j_send_result.rb +3 -0
  96. data/lib/convenient_service/service/plugins/has_negated_result/concern.rb +33 -0
  97. data/lib/convenient_service/service/plugins/{has_j_send_result → has_negated_result}/exceptions.rb +3 -3
  98. data/lib/convenient_service/service/plugins/has_negated_result.rb +4 -0
  99. data/lib/convenient_service/service/plugins/{wraps_result_in_db_transaction → wraps_result_in_d_b_transaction}/middleware.rb +1 -1
  100. data/lib/convenient_service/service/plugins.rb +7 -2
  101. data/lib/convenient_service/specification.rb +28 -0
  102. data/lib/convenient_service/support/backtrace_cleaner.rb +6 -1
  103. data/lib/convenient_service/support/cache/entities/caches/base.rb +3 -0
  104. data/lib/convenient_service/support/method_parameters.rb +121 -0
  105. data/lib/convenient_service/support/never_reach_here.rb +21 -0
  106. data/lib/convenient_service/support/unique_value.rb +3 -0
  107. data/lib/convenient_service/support/value.rb +78 -0
  108. data/lib/convenient_service/support.rb +3 -0
  109. data/lib/convenient_service/utils/array/find_last.rb +8 -3
  110. data/lib/convenient_service/utils/object/instance_variable_delete.rb +1 -1
  111. data/lib/convenient_service/version.rb +1 -1
  112. data/lib/convenient_service.rb +23 -0
  113. metadata +109 -308
  114. data/.dev/.tmuxinator.yml +0 -22
  115. data/.dockerignore +0 -1
  116. data/.gem_release.yml +0 -11
  117. data/.github/contributing.md +0 -15
  118. data/.github/issue_template.md +0 -35
  119. data/.github/pull_request_template.md +0 -31
  120. data/.github/workflows/cd.yml +0 -68
  121. data/.github/workflows/ci.yml +0 -212
  122. data/.gitignore +0 -66
  123. data/.inch.yml +0 -7
  124. data/.rspec +0 -3
  125. data/.rubocop.yml +0 -45
  126. data/.rubocop_rspec.yml +0 -58
  127. data/.ruby-version +0 -1
  128. data/.tool-versions +0 -1
  129. data/.vscode/CacheItsValue.code-snippets +0 -15
  130. data/.vscode/DelegateTo.code-snippets +0 -15
  131. data/.vscode/cache_its_value.code-snippets +0 -17
  132. data/.vscode/comparison.code-snippets +0 -41
  133. data/.vscode/delegate_to.code-snippets +0 -20
  134. data/.yardopts +0 -16
  135. data/Appraisals +0 -146
  136. data/CHANGELOG.md +0 -504
  137. data/Gemfile +0 -17
  138. data/ROADMAP.md +0 -92
  139. data/Rakefile +0 -54
  140. data/Taskfile.yml +0 -679
  141. data/benchmark/commit_config/ips.rb +0 -18
  142. data/benchmark/commit_config/profile.rb +0 -30
  143. data/benchmark/empty_service/ips.rb +0 -123
  144. data/benchmark/has_committed_config/ips.rb +0 -78
  145. data/benchmark/has_committed_config/profile.rb +0 -30
  146. data/convenient_service.gemspec +0 -233
  147. data/coverage/.gitkeep +0 -0
  148. data/docker/2.7/Dockerfile +0 -73
  149. data/docker/3.0/Dockerfile +0 -73
  150. data/docker/3.1/Dockerfile +0 -73
  151. data/docker/3.2/Dockerfile +0 -73
  152. data/docker/jruby-9.4/Dockerfile +0 -88
  153. data/docker/truffleruby-22.3/Dockerfile +0 -91
  154. data/docs/.gitkeep +0 -0
  155. data/docs/api/.gitkeep +0 -0
  156. data/env.rb +0 -23
  157. data/gemfiles/.gitkeep +0 -0
  158. data/lib/convenient_service/common/plugins/has_callbacks/container.rb +0 -17
  159. data/lib/convenient_service/examples/dry/gemfile/dry_service/config.rb +0 -45
  160. data/lib/convenient_service/examples/dry/gemfile/dry_service.rb +0 -3
  161. data/lib/convenient_service/examples/dry/gemfile/services/assert_file_exists.rb +0 -29
  162. data/lib/convenient_service/examples/dry/gemfile/services/assert_file_not_empty.rb +0 -29
  163. data/lib/convenient_service/examples/dry/gemfile/services/assert_node_available.rb +0 -26
  164. data/lib/convenient_service/examples/dry/gemfile/services/assert_npm_package_available.rb +0 -39
  165. data/lib/convenient_service/examples/dry/gemfile/services/assert_valid_ruby_syntax.rb +0 -41
  166. data/lib/convenient_service/examples/dry/gemfile/services/format.rb +0 -37
  167. data/lib/convenient_service/examples/dry/gemfile/services/format_body.rb +0 -93
  168. data/lib/convenient_service/examples/dry/gemfile/services/format_gems_with_envs.rb +0 -96
  169. data/lib/convenient_service/examples/dry/gemfile/services/format_gems_without_envs.rb +0 -84
  170. data/lib/convenient_service/examples/dry/gemfile/services/format_header.rb +0 -74
  171. data/lib/convenient_service/examples/dry/gemfile/services/parse_content.rb +0 -93
  172. data/lib/convenient_service/examples/dry/gemfile/services/print_shell_command.rb +0 -44
  173. data/lib/convenient_service/examples/dry/gemfile/services/read_file_content.rb +0 -31
  174. data/lib/convenient_service/examples/dry/gemfile/services/run_shell_command.rb +0 -45
  175. data/lib/convenient_service/examples/dry/gemfile/services/strip_comments.rb +0 -109
  176. data/lib/convenient_service/examples/dry/gemfile/services.rb +0 -18
  177. data/lib/convenient_service/examples/dry/gemfile.rb +0 -27
  178. data/lib/convenient_service/examples/dry/v1/gemfile/dry_service/config.rb +0 -47
  179. data/lib/convenient_service/examples/dry/v1/gemfile/dry_service.rb +0 -3
  180. data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_file_exists.rb +0 -31
  181. data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_file_not_empty.rb +0 -31
  182. data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_node_available.rb +0 -28
  183. data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_npm_package_available.rb +0 -41
  184. data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_valid_ruby_syntax.rb +0 -43
  185. data/lib/convenient_service/examples/dry/v1/gemfile/services/format.rb +0 -39
  186. data/lib/convenient_service/examples/dry/v1/gemfile/services/format_body.rb +0 -95
  187. data/lib/convenient_service/examples/dry/v1/gemfile/services/format_gems_with_envs.rb +0 -98
  188. data/lib/convenient_service/examples/dry/v1/gemfile/services/format_gems_without_envs.rb +0 -86
  189. data/lib/convenient_service/examples/dry/v1/gemfile/services/format_header.rb +0 -76
  190. data/lib/convenient_service/examples/dry/v1/gemfile/services/parse_content.rb +0 -95
  191. data/lib/convenient_service/examples/dry/v1/gemfile/services/read_file_content.rb +0 -33
  192. data/lib/convenient_service/examples/dry/v1/gemfile/services/run_shell_command.rb +0 -43
  193. data/lib/convenient_service/examples/dry/v1/gemfile/services/strip_comments.rb +0 -111
  194. data/lib/convenient_service/examples/dry/v1/gemfile/services.rb +0 -17
  195. data/lib/convenient_service/examples/dry/v1/gemfile.rb +0 -29
  196. data/lib/convenient_service/examples/rails/gemfile/rails_service/config.rb +0 -56
  197. data/lib/convenient_service/examples/rails/gemfile/rails_service.rb +0 -3
  198. data/lib/convenient_service/examples/rails/gemfile/services/assert_file_exists.rb +0 -25
  199. data/lib/convenient_service/examples/rails/gemfile/services/assert_file_not_empty.rb +0 -25
  200. data/lib/convenient_service/examples/rails/gemfile/services/assert_node_available.rb +0 -26
  201. data/lib/convenient_service/examples/rails/gemfile/services/assert_npm_package_available.rb +0 -35
  202. data/lib/convenient_service/examples/rails/gemfile/services/assert_valid_ruby_syntax.rb +0 -35
  203. data/lib/convenient_service/examples/rails/gemfile/services/format.rb +0 -66
  204. data/lib/convenient_service/examples/rails/gemfile/services/format_body.rb +0 -79
  205. data/lib/convenient_service/examples/rails/gemfile/services/format_gems_with_envs.rb +0 -82
  206. data/lib/convenient_service/examples/rails/gemfile/services/format_gems_without_envs.rb +0 -70
  207. data/lib/convenient_service/examples/rails/gemfile/services/format_header.rb +0 -68
  208. data/lib/convenient_service/examples/rails/gemfile/services/merge_sections.rb +0 -25
  209. data/lib/convenient_service/examples/rails/gemfile/services/parse_content.rb +0 -89
  210. data/lib/convenient_service/examples/rails/gemfile/services/print_shell_command.rb +0 -40
  211. data/lib/convenient_service/examples/rails/gemfile/services/read_file_content.rb +0 -27
  212. data/lib/convenient_service/examples/rails/gemfile/services/replace_file_content.rb +0 -37
  213. data/lib/convenient_service/examples/rails/gemfile/services/run_shell_command.rb +0 -40
  214. data/lib/convenient_service/examples/rails/gemfile/services/strip_comments.rb +0 -107
  215. data/lib/convenient_service/examples/rails/gemfile/services.rb +0 -21
  216. data/lib/convenient_service/examples/rails/gemfile.rb +0 -27
  217. data/lib/convenient_service/examples/rails/v1/gemfile/rails_service/config.rb +0 -58
  218. data/lib/convenient_service/examples/rails/v1/gemfile/rails_service.rb +0 -3
  219. data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_file_exists.rb +0 -27
  220. data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_file_not_empty.rb +0 -27
  221. data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_node_available.rb +0 -28
  222. data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_npm_package_available.rb +0 -37
  223. data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_valid_ruby_syntax.rb +0 -37
  224. data/lib/convenient_service/examples/rails/v1/gemfile/services/format.rb +0 -68
  225. data/lib/convenient_service/examples/rails/v1/gemfile/services/format_body.rb +0 -81
  226. data/lib/convenient_service/examples/rails/v1/gemfile/services/format_gems_with_envs.rb +0 -84
  227. data/lib/convenient_service/examples/rails/v1/gemfile/services/format_gems_without_envs.rb +0 -72
  228. data/lib/convenient_service/examples/rails/v1/gemfile/services/format_header.rb +0 -70
  229. data/lib/convenient_service/examples/rails/v1/gemfile/services/merge_sections.rb +0 -27
  230. data/lib/convenient_service/examples/rails/v1/gemfile/services/parse_content.rb +0 -91
  231. data/lib/convenient_service/examples/rails/v1/gemfile/services/read_file_content.rb +0 -29
  232. data/lib/convenient_service/examples/rails/v1/gemfile/services/replace_file_content.rb +0 -39
  233. data/lib/convenient_service/examples/rails/v1/gemfile/services/run_shell_command.rb +0 -38
  234. data/lib/convenient_service/examples/rails/v1/gemfile/services/strip_comments.rb +0 -109
  235. data/lib/convenient_service/examples/rails/v1/gemfile/services.rb +0 -20
  236. data/lib/convenient_service/examples/rails/v1/gemfile.rb +0 -29
  237. data/lib/convenient_service/examples/standard/cowsay/services/build_cloud.rb +0 -42
  238. data/lib/convenient_service/examples/standard/cowsay/services/build_cow.rb +0 -38
  239. data/lib/convenient_service/examples/standard/cowsay/services/print.rb +0 -32
  240. data/lib/convenient_service/examples/standard/cowsay/services.rb +0 -5
  241. data/lib/convenient_service/examples/standard/cowsay.rb +0 -26
  242. data/lib/convenient_service/examples/standard/date_time/services/safe_parse.rb +0 -31
  243. data/lib/convenient_service/examples/standard/date_time/services.rb +0 -3
  244. data/lib/convenient_service/examples/standard/date_time.rb +0 -25
  245. data/lib/convenient_service/examples/standard/factorial/services/calculate.rb +0 -55
  246. data/lib/convenient_service/examples/standard/factorial/services.rb +0 -3
  247. data/lib/convenient_service/examples/standard/factorial/utils/timeout/with_timeout.rb +0 -50
  248. data/lib/convenient_service/examples/standard/factorial/utils/timeout.rb +0 -21
  249. data/lib/convenient_service/examples/standard/factorial/utils.rb +0 -3
  250. data/lib/convenient_service/examples/standard/factorial.rb +0 -26
  251. data/lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb +0 -30
  252. data/lib/convenient_service/examples/standard/gemfile/services/assert_file_not_empty.rb +0 -30
  253. data/lib/convenient_service/examples/standard/gemfile/services/assert_node_available.rb +0 -26
  254. data/lib/convenient_service/examples/standard/gemfile/services/assert_npm_package_available.rb +0 -48
  255. data/lib/convenient_service/examples/standard/gemfile/services/assert_valid_ruby_syntax.rb +0 -39
  256. data/lib/convenient_service/examples/standard/gemfile/services/format.rb +0 -80
  257. data/lib/convenient_service/examples/standard/gemfile/services/format_body.rb +0 -83
  258. data/lib/convenient_service/examples/standard/gemfile/services/format_gems_with_envs.rb +0 -86
  259. data/lib/convenient_service/examples/standard/gemfile/services/format_gems_without_envs.rb +0 -74
  260. data/lib/convenient_service/examples/standard/gemfile/services/format_header.rb +0 -66
  261. data/lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb +0 -52
  262. data/lib/convenient_service/examples/standard/gemfile/services/parse_content.rb +0 -101
  263. data/lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb +0 -45
  264. data/lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb +0 -39
  265. data/lib/convenient_service/examples/standard/gemfile/services/replace_file_content.rb +0 -48
  266. data/lib/convenient_service/examples/standard/gemfile/services/run_shell_command.rb +0 -54
  267. data/lib/convenient_service/examples/standard/gemfile/services/strip_comments.rb +0 -111
  268. data/lib/convenient_service/examples/standard/gemfile/services.rb +0 -21
  269. data/lib/convenient_service/examples/standard/gemfile.rb +0 -26
  270. data/lib/convenient_service/examples/standard/request_params/constants.rb +0 -15
  271. data/lib/convenient_service/examples/standard/request_params/entities/description.rb +0 -40
  272. data/lib/convenient_service/examples/standard/request_params/entities/format.rb +0 -40
  273. data/lib/convenient_service/examples/standard/request_params/entities/id.rb +0 -47
  274. data/lib/convenient_service/examples/standard/request_params/entities/logger.rb +0 -21
  275. data/lib/convenient_service/examples/standard/request_params/entities/request.rb +0 -23
  276. data/lib/convenient_service/examples/standard/request_params/entities/source.rb +0 -40
  277. data/lib/convenient_service/examples/standard/request_params/entities/tag.rb +0 -40
  278. data/lib/convenient_service/examples/standard/request_params/entities/title.rb +0 -40
  279. data/lib/convenient_service/examples/standard/request_params/entities.rb +0 -11
  280. data/lib/convenient_service/examples/standard/request_params/services/apply_default_param_values.rb +0 -26
  281. data/lib/convenient_service/examples/standard/request_params/services/cast_params.rb +0 -38
  282. data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_body.rb +0 -70
  283. data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path.rb +0 -62
  284. data/lib/convenient_service/examples/standard/request_params/services/filter_out_unpermitted_params.rb +0 -26
  285. data/lib/convenient_service/examples/standard/request_params/services/log_request_params.rb +0 -54
  286. data/lib/convenient_service/examples/standard/request_params/services/merge_params.rb +0 -26
  287. data/lib/convenient_service/examples/standard/request_params/services/prepare.rb +0 -65
  288. data/lib/convenient_service/examples/standard/request_params/services/validate_casted_params.rb +0 -94
  289. data/lib/convenient_service/examples/standard/request_params/services/validate_uncasted_params.rb +0 -72
  290. data/lib/convenient_service/examples/standard/request_params/services.rb +0 -13
  291. data/lib/convenient_service/examples/standard/request_params/utils/array/wrap.rb +0 -46
  292. data/lib/convenient_service/examples/standard/request_params/utils/array.rb +0 -21
  293. data/lib/convenient_service/examples/standard/request_params/utils/http/request/parse_body.rb +0 -42
  294. data/lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb +0 -40
  295. data/lib/convenient_service/examples/standard/request_params/utils/http/request.rb +0 -28
  296. data/lib/convenient_service/examples/standard/request_params/utils/http.rb +0 -3
  297. data/lib/convenient_service/examples/standard/request_params/utils/integer/safe_parse.rb +0 -31
  298. data/lib/convenient_service/examples/standard/request_params/utils/integer.rb +0 -25
  299. data/lib/convenient_service/examples/standard/request_params/utils/json/safe_parse.rb +0 -40
  300. data/lib/convenient_service/examples/standard/request_params/utils/json.rb +0 -21
  301. data/lib/convenient_service/examples/standard/request_params/utils/object/blank.rb +0 -34
  302. data/lib/convenient_service/examples/standard/request_params/utils/object/present.rb +0 -31
  303. data/lib/convenient_service/examples/standard/request_params/utils/object.rb +0 -26
  304. data/lib/convenient_service/examples/standard/request_params/utils/url/valid.rb +0 -47
  305. data/lib/convenient_service/examples/standard/request_params/utils/url.rb +0 -21
  306. data/lib/convenient_service/examples/standard/request_params/utils.rb +0 -8
  307. data/lib/convenient_service/examples/standard/request_params.rb +0 -49
  308. data/lib/convenient_service/examples/standard/v1/cowsay/services/build_cloud.rb +0 -44
  309. data/lib/convenient_service/examples/standard/v1/cowsay/services/build_cow.rb +0 -40
  310. data/lib/convenient_service/examples/standard/v1/cowsay/services/print.rb +0 -34
  311. data/lib/convenient_service/examples/standard/v1/cowsay/services.rb +0 -5
  312. data/lib/convenient_service/examples/standard/v1/cowsay.rb +0 -26
  313. data/lib/convenient_service/examples/standard/v1/date_time/services/safe_parse.rb +0 -33
  314. data/lib/convenient_service/examples/standard/v1/date_time/services.rb +0 -3
  315. data/lib/convenient_service/examples/standard/v1/date_time.rb +0 -25
  316. data/lib/convenient_service/examples/standard/v1/factorial/services/calculate.rb +0 -51
  317. data/lib/convenient_service/examples/standard/v1/factorial/services.rb +0 -3
  318. data/lib/convenient_service/examples/standard/v1/factorial/utils/timeout/with_timeout.rb +0 -52
  319. data/lib/convenient_service/examples/standard/v1/factorial/utils/timeout.rb +0 -23
  320. data/lib/convenient_service/examples/standard/v1/factorial/utils.rb +0 -3
  321. data/lib/convenient_service/examples/standard/v1/factorial.rb +0 -26
  322. data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_exists.rb +0 -32
  323. data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_not_empty.rb +0 -32
  324. data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_node_available.rb +0 -28
  325. data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_npm_package_available.rb +0 -50
  326. data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_valid_ruby_syntax.rb +0 -41
  327. data/lib/convenient_service/examples/standard/v1/gemfile/services/format.rb +0 -82
  328. data/lib/convenient_service/examples/standard/v1/gemfile/services/format_body.rb +0 -85
  329. data/lib/convenient_service/examples/standard/v1/gemfile/services/format_gems_with_envs.rb +0 -88
  330. data/lib/convenient_service/examples/standard/v1/gemfile/services/format_gems_without_envs.rb +0 -76
  331. data/lib/convenient_service/examples/standard/v1/gemfile/services/format_header.rb +0 -68
  332. data/lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb +0 -54
  333. data/lib/convenient_service/examples/standard/v1/gemfile/services/parse_content.rb +0 -103
  334. data/lib/convenient_service/examples/standard/v1/gemfile/services/read_file_content.rb +0 -41
  335. data/lib/convenient_service/examples/standard/v1/gemfile/services/replace_file_content.rb +0 -50
  336. data/lib/convenient_service/examples/standard/v1/gemfile/services/run_shell_command.rb +0 -52
  337. data/lib/convenient_service/examples/standard/v1/gemfile/services/strip_comments.rb +0 -113
  338. data/lib/convenient_service/examples/standard/v1/gemfile/services.rb +0 -20
  339. data/lib/convenient_service/examples/standard/v1/gemfile.rb +0 -26
  340. data/lib/convenient_service/examples/standard/v1/request_params/constants.rb +0 -17
  341. data/lib/convenient_service/examples/standard/v1/request_params/entities/description.rb +0 -42
  342. data/lib/convenient_service/examples/standard/v1/request_params/entities/format.rb +0 -42
  343. data/lib/convenient_service/examples/standard/v1/request_params/entities/id.rb +0 -49
  344. data/lib/convenient_service/examples/standard/v1/request_params/entities/logger.rb +0 -23
  345. data/lib/convenient_service/examples/standard/v1/request_params/entities/request.rb +0 -25
  346. data/lib/convenient_service/examples/standard/v1/request_params/entities/source.rb +0 -42
  347. data/lib/convenient_service/examples/standard/v1/request_params/entities/tag.rb +0 -42
  348. data/lib/convenient_service/examples/standard/v1/request_params/entities/title.rb +0 -42
  349. data/lib/convenient_service/examples/standard/v1/request_params/entities.rb +0 -11
  350. data/lib/convenient_service/examples/standard/v1/request_params/services/apply_default_param_values.rb +0 -28
  351. data/lib/convenient_service/examples/standard/v1/request_params/services/cast_params.rb +0 -40
  352. data/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_body.rb +0 -72
  353. data/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_path.rb +0 -64
  354. data/lib/convenient_service/examples/standard/v1/request_params/services/filter_out_unpermitted_params.rb +0 -28
  355. data/lib/convenient_service/examples/standard/v1/request_params/services/log_request_params.rb +0 -56
  356. data/lib/convenient_service/examples/standard/v1/request_params/services/merge_params.rb +0 -28
  357. data/lib/convenient_service/examples/standard/v1/request_params/services/prepare.rb +0 -67
  358. data/lib/convenient_service/examples/standard/v1/request_params/services/validate_casted_params.rb +0 -96
  359. data/lib/convenient_service/examples/standard/v1/request_params/services/validate_uncasted_params.rb +0 -74
  360. data/lib/convenient_service/examples/standard/v1/request_params/services.rb +0 -13
  361. data/lib/convenient_service/examples/standard/v1/request_params/utils/array/wrap.rb +0 -48
  362. data/lib/convenient_service/examples/standard/v1/request_params/utils/array.rb +0 -23
  363. data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request/parse_body.rb +0 -44
  364. data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request/parse_path.rb +0 -42
  365. data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request.rb +0 -30
  366. data/lib/convenient_service/examples/standard/v1/request_params/utils/http.rb +0 -3
  367. data/lib/convenient_service/examples/standard/v1/request_params/utils/integer/safe_parse.rb +0 -33
  368. data/lib/convenient_service/examples/standard/v1/request_params/utils/integer.rb +0 -27
  369. data/lib/convenient_service/examples/standard/v1/request_params/utils/json/safe_parse.rb +0 -42
  370. data/lib/convenient_service/examples/standard/v1/request_params/utils/json.rb +0 -23
  371. data/lib/convenient_service/examples/standard/v1/request_params/utils/object/blank.rb +0 -36
  372. data/lib/convenient_service/examples/standard/v1/request_params/utils/object/present.rb +0 -33
  373. data/lib/convenient_service/examples/standard/v1/request_params/utils/object.rb +0 -28
  374. data/lib/convenient_service/examples/standard/v1/request_params/utils/url/valid.rb +0 -49
  375. data/lib/convenient_service/examples/standard/v1/request_params/utils/url.rb +0 -23
  376. data/lib/convenient_service/examples/standard/v1/request_params/utils.rb +0 -8
  377. data/lib/convenient_service/examples/standard/v1/request_params.rb +0 -49
  378. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/commands/generate_printable_method.rb +0 -50
  379. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments/commands/apply_stub_to_track_delegations.rb +0 -82
  380. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments/commands/generate_printable_arguments.rb +0 -100
  381. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments.rb +0 -95
  382. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/base.rb +0 -87
  383. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/return_its_value.rb +0 -132
  384. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/with_any_arguments.rb +0 -37
  385. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/with_concrete_arguments.rb +0 -37
  386. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/without_arguments.rb +0 -37
  387. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/base.rb +0 -41
  388. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/with_calling_original.rb +0 -30
  389. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/without_calling_original.rb +0 -30
  390. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings.rb +0 -12
  391. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings_collection/exceptions.rb +0 -57
  392. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings_collection.rb +0 -171
  393. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/delegation.rb +0 -79
  394. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities.rb +0 -5
  395. data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb +0 -276
  396. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/reassignment/commands/define_method_in_container.rb +0 -74
  397. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/reassignment/commands.rb +0 -3
  398. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_result_step/can_be_executed/middleware.rb +0 -72
  399. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_result_step/can_be_executed.rb +0 -4
  400. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_result_step.rb +0 -5
  401. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/middleware.rb +0 -43
  402. data/logo.png +0 -0
  403. data/minitest.rb +0 -30
  404. data/yard/yard-convenient_service_concern.rb +0 -45
  405. /data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/{entities/matcher/commands.rb → commands.rb} +0 -0
  406. /data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/{matcher/entities/chainings/sub_matchers → sub_matchers}/arguments/commands.rb +0 -0
@@ -16,34 +16,9 @@ module ConvenientService
16
16
  include Support::Delegate
17
17
 
18
18
  ##
19
- # @return [Boolean]
20
- #
21
- delegate :success?, to: :result
22
-
23
- ##
24
- # @return [Boolean]
19
+ # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status]
25
20
  #
26
- delegate :failure?, to: :result
27
-
28
- ##
29
- # @return [Boolean]
30
- #
31
- delegate :error?, to: :result
32
-
33
- ##
34
- # @return [Boolean]
35
- #
36
- delegate :not_success?, to: :result
37
-
38
- ##
39
- # @return [Boolean]
40
- #
41
- delegate :not_failure?, to: :result
42
-
43
- ##
44
- # @return [Boolean]
45
- #
46
- delegate :not_error?, to: :result
21
+ delegate :status, to: :result
47
22
 
48
23
  ##
49
24
  # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data]
@@ -107,66 +82,62 @@ module ConvenientService
107
82
  delegate :extra_kwargs, to: :params
108
83
 
109
84
  ##
110
- # @param args [Array<Object>]
111
- # @param kwargs [Hash{Symbol => Object}]
112
- # @return [void]
85
+ # @return [Boolean]
113
86
  #
114
- def initialize(*args, **kwargs)
115
- @args = args
116
- @kwargs = kwargs
117
- end
87
+ delegate :success?, to: :result
118
88
 
119
89
  ##
120
- # @param other [Object] Can be any type.
121
- # @return [Boolean, nil]
122
- #
123
- # @internal
124
- # TODO: Currently `==` does NOT compare `extra_kwargs`. Is it OK?
90
+ # @return [Boolean]
125
91
  #
126
- def ==(other)
127
- return unless other.instance_of?(self.class)
92
+ delegate :failure?, to: :result
128
93
 
129
- return false if service != other.service
130
- return false if inputs != other.inputs
131
- return false if outputs != other.outputs
132
- return false if index != other.index
133
- return false if container != other.container
134
- return false if organizer(raise_when_missing: false) != other.organizer(raise_when_missing: false)
94
+ ##
95
+ # @return [Boolean]
96
+ #
97
+ delegate :error?, to: :result
135
98
 
136
- true
137
- end
99
+ ##
100
+ # @return [Boolean]
101
+ #
102
+ delegate :not_success?, to: :result
138
103
 
139
104
  ##
140
105
  # @return [Boolean]
141
106
  #
142
- def has_organizer?
143
- Utils.to_bool(organizer(raise_when_missing: false))
144
- end
107
+ delegate :not_failure?, to: :result
145
108
 
146
109
  ##
147
110
  # @return [Boolean]
148
- # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
149
111
  #
150
- def has_reassignment?(name)
151
- outputs.any? { |output| output.reassignment?(name) }
152
- end
112
+ delegate :not_error?, to: :result
153
113
 
154
114
  ##
155
- # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method, nil]
156
- # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
115
+ # @api private
157
116
  #
158
- def reassignment(name)
159
- outputs.find { |output| output.reassignment?(name) }
117
+ # @param args [Array<Object>]
118
+ # @param kwargs [Hash{Symbol => Object}]
119
+ # @return [void]
120
+ #
121
+ def initialize(*args, **kwargs)
122
+ @args = args
123
+ @kwargs = kwargs
160
124
  end
161
125
 
162
126
  ##
127
+ # @api private
128
+ #
163
129
  # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Structs::Params]
164
130
  #
131
+ # @internal
132
+ # TODO: Direct specs.
133
+ #
165
134
  def params
166
135
  @params ||= resolve_params
167
136
  end
168
137
 
169
138
  ##
139
+ # @api private
140
+ #
170
141
  # @return [ConvenientService::Service]
171
142
  # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
172
143
  #
@@ -184,6 +155,8 @@ module ConvenientService
184
155
  end
185
156
 
186
157
  ##
158
+ # @api public
159
+ #
187
160
  # @return [Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method>]
188
161
  #
189
162
  def inputs
@@ -191,6 +164,8 @@ module ConvenientService
191
164
  end
192
165
 
193
166
  ##
167
+ # @api public
168
+ #
194
169
  # @return [Hash{Symbol => Object}]
195
170
  # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
196
171
  #
@@ -199,14 +174,28 @@ module ConvenientService
199
174
  end
200
175
 
201
176
  ##
177
+ # @api public
178
+ #
202
179
  # @return [Hash{Symbol => Object}]
203
- # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
180
+ # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer, ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepResultDataNotExistingDataAttribute]
204
181
  #
205
182
  def output_values
206
- @output_values ||= result.unsafe_data.to_h.slice(*outputs.map(&:key).map(&:to_sym))
183
+ @output_values ||= calculate_output_values
207
184
  end
208
185
 
209
186
  ##
187
+ # @api public
188
+ #
189
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method, nil]
190
+ # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
191
+ #
192
+ def reassignment(name)
193
+ outputs.find { |output| output.reassignment?(name) }
194
+ end
195
+
196
+ ##
197
+ # @api private
198
+ #
210
199
  # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
211
200
  # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
212
201
  #
@@ -215,26 +204,15 @@ module ConvenientService
215
204
  # @internal
216
205
  # IMPORTANT: `service.result(**input_values)` is the reason, why services should have only kwargs as arguments.
217
206
  #
218
- # NOTE: `service_result` returns a foreign result that is later converted to own result by `convert_to_step_result` in `result`.
207
+ # NOTE: `service_result` returns a foreign result that is later converted to own result by `HasResult` middleware.
219
208
  #
220
209
  def service_result
221
210
  service.klass.result(**input_values)
222
211
  end
223
212
 
224
213
  ##
225
- # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
226
- # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
214
+ # @api private
227
215
  #
228
- # @note `result` has middlewares.
229
- #
230
- # @internal
231
- # NOTE: Convents a foreign result received from `service_result` to own result.
232
- #
233
- def result
234
- convert_to_step_result(service_result)
235
- end
236
-
237
- ##
238
216
  # @return [String]
239
217
  #
240
218
  def printable_service
@@ -242,6 +220,8 @@ module ConvenientService
242
220
  end
243
221
 
244
222
  ##
223
+ # @api private
224
+ #
245
225
  # @return [Class]
246
226
  #
247
227
  def service_class
@@ -249,6 +229,27 @@ module ConvenientService
249
229
  end
250
230
 
251
231
  ##
232
+ # @api private
233
+ #
234
+ # @return [Boolean]
235
+ #
236
+ def has_organizer?
237
+ Utils.to_bool(organizer(raise_when_missing: false))
238
+ end
239
+
240
+ ##
241
+ # @api public
242
+ #
243
+ # @return [Boolean]
244
+ # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
245
+ #
246
+ def has_reassignment?(name)
247
+ outputs.any? { |output| output.reassignment?(name) }
248
+ end
249
+
250
+ ##
251
+ # @api private
252
+ #
252
253
  # @return [void]
253
254
  # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
254
255
  #
@@ -257,6 +258,33 @@ module ConvenientService
257
258
  end
258
259
 
259
260
  ##
261
+ # @api private
262
+ #
263
+ # @return [Boolean]
264
+ # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::MethodHasNoOrganizer]
265
+ #
266
+ # @internal
267
+ # TODO: Create `OutputMethod`. Move `save` into it.
268
+ #
269
+ def save_outputs_in_organizer!
270
+ output_values.each_pair { |key, value| organizer.internals.cache.scope(:step_output_values).write(key, value) }
271
+
272
+ true
273
+ end
274
+
275
+ ##
276
+ # @api private
277
+ #
278
+ # @param organizer [ConvenientService::Service]
279
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step]
280
+ #
281
+ def with_organizer(organizer)
282
+ copy(overrides: {kwargs: {organizer: organizer}})
283
+ end
284
+
285
+ ##
286
+ # @api private
287
+ #
260
288
  # @return [void]
261
289
  # @raise [ConvenientService::Error]
262
290
  #
@@ -269,6 +297,8 @@ module ConvenientService
269
297
  end
270
298
 
271
299
  ##
300
+ # @api private
301
+ #
272
302
  # @return [void]
273
303
  #
274
304
  def define!
@@ -278,6 +308,38 @@ module ConvenientService
278
308
  end
279
309
 
280
310
  ##
311
+ # @api private
312
+ #
313
+ # @param other [Object] Can be any type.
314
+ # @return [Boolean, nil]
315
+ #
316
+ def ==(other)
317
+ return unless other.instance_of?(self.class)
318
+
319
+ return false if service != other.service
320
+ return false if inputs != other.inputs
321
+ return false if outputs != other.outputs
322
+ return false if index != other.index
323
+ return false if container != other.container
324
+ return false if organizer(raise_when_missing: false) != other.organizer(raise_when_missing: false)
325
+ return false if extra_kwargs != other.extra_kwargs
326
+
327
+ true
328
+ end
329
+
330
+ ##
331
+ # @return [String]
332
+ #
333
+ # @internal
334
+ # TODO: Remove `printable_service` completely. Leave only `to_s`.
335
+ #
336
+ def to_s
337
+ printable_service
338
+ end
339
+
340
+ ##
341
+ # @api private
342
+ #
281
343
  # @return [Array<Object>]
282
344
  #
283
345
  def to_args
@@ -285,6 +347,8 @@ module ConvenientService
285
347
  end
286
348
 
287
349
  ##
350
+ # @api private
351
+ #
288
352
  # @return [Hash{Symbol => Object}]
289
353
  #
290
354
  def to_kwargs
@@ -292,10 +356,12 @@ module ConvenientService
292
356
  end
293
357
 
294
358
  ##
359
+ # @api private
360
+ #
295
361
  # @return [ConveninentService::Support::Arguments]
296
362
  #
297
363
  def to_arguments
298
- Support::Arguments.new(service, **kwargs.merge(in: inputs, out: outputs, index: index, container: container, organizer: organizer(raise_when_missing: false)))
364
+ Support::Arguments.new(service, **kwargs.merge(in: inputs, out: outputs, index: index, container: container, organizer: organizer(raise_when_missing: false), **extra_kwargs))
299
365
  end
300
366
 
301
367
  private
@@ -324,11 +390,20 @@ module ConvenientService
324
390
  end
325
391
 
326
392
  ##
327
- # @param result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
328
- # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
393
+ # @return [Hash{Symbol => Object}]
394
+ # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer, ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepResultDataNotExistingAttribute]
329
395
  #
330
- def convert_to_step_result(result)
331
- result.copy(overrides: {kwargs: {step: self, service: organizer}})
396
+ # @internal
397
+ # TODO: Commands instead of private methods.
398
+ # IMPORTANT: `status.unsafe_success?` is used instead of `success?` or `result.status?` in order to NOT mark result as checked.
399
+ # TODO: Create `OutputMethod`. Move `validate_as_output_for_result` into it.
400
+ #
401
+ def calculate_output_values
402
+ return {} unless status.unsafe_success?
403
+
404
+ outputs.each { |output| ::ConvenientService.raise Exceptions::StepResultDataNotExistingAttribute.new(step: self, key: output.key.to_sym) unless unsafe_data.has_attribute?(output.key.to_sym) }
405
+
406
+ outputs.reduce({}) { |values, output| values.merge(output.name.to_sym => unsafe_data[output.key.to_sym]) }
332
407
  end
333
408
 
334
409
  ##
@@ -18,6 +18,25 @@ module ConvenientService
18
18
  initialize(message)
19
19
  end
20
20
  end
21
+
22
+ class StepResultDataNotExistingAttribute < ::ConvenientService::Exception
23
+ ##
24
+ # @param key [Symbol]
25
+ # @param step [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step]
26
+ # @return [void]
27
+ #
28
+ def initialize_with_kwargs(key:, step:)
29
+ message = <<~TEXT
30
+ Step `#{step.printable_service}` result does NOT return `:#{key}` data attribute.
31
+
32
+ Maybe there is a typo in `out` definition?
33
+
34
+ Or `success` of `#{step.printable_service}` accepts a wrong key?
35
+ TEXT
36
+
37
+ initialize(message)
38
+ end
39
+ end
21
40
  end
22
41
  end
23
42
  end
@@ -7,7 +7,7 @@ module ConvenientService
7
7
  module Entities
8
8
  class Step
9
9
  module Plugins
10
- module CanBeResultStep
10
+ module CanBeMethodStep
11
11
  module CanBeExecuted
12
12
  module Exceptions
13
13
  class MethodForStepIsNotDefined < ::ConvenientService::Exception
@@ -10,19 +10,79 @@ module ConvenientService
10
10
  module CanBeMethodStep
11
11
  module CanBeExecuted
12
12
  class Middleware < MethodChainMiddleware
13
- intended_for :service_result, entity: :step
13
+ intended_for :result, entity: :step
14
14
 
15
15
  ##
16
16
  # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
17
- # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanBeResultStep::CanBeExecuted::Exceptions::MethodForStepIsNotDefined]
17
+ # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanBeMethodStep::CanBeExecuted::Exceptions::MethodForStepIsNotDefined]
18
18
  #
19
19
  # @internal
20
- # NOTE: `kwargs` are intentionally NOT passed to `object.__send__(method)`, since all the corresponding methods are available inside `entity.organizer.__send__(entity.method)` body.
20
+ # NOTE: `kwargs` are intentionally NOT passed to `own_method.call`, since all the corresponding methods are available inside `own_method` body.
21
21
  #
22
22
  def next(...)
23
23
  return chain.next(...) unless entity.method_step?
24
24
 
25
- entity.organizer.__send__(entity.method)
25
+ ::ConvenientService.raise Exceptions::MethodForStepIsNotDefined.new(service_class: organizer.class, method_name: method_name) unless own_method
26
+
27
+ call_method(own_method)
28
+ end
29
+
30
+ private
31
+
32
+ ##
33
+ # @param method [Method]
34
+ # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
35
+ #
36
+ # @internal
37
+ # TODO: Add specs.
38
+ #
39
+ def call_method(method)
40
+ params = Support::MethodParameters.new(method.parameters)
41
+
42
+ return method.call(**input_values) if params.has_rest_kwargs?
43
+
44
+ return method.call(**input_values.slice(*params.named_kwargs_keys)) if params.named_kwargs_keys.any?
45
+
46
+ method.call
47
+ end
48
+
49
+ ##
50
+ # @return [Method, nil]
51
+ #
52
+ # @internal
53
+ # TODO: A possible bottleneck. Should be removed if receives negative feedback.
54
+ #
55
+ # NOTE: `own_method.bind(organizer).call` is logically the same as `own_method.bind_call(organizer)`.
56
+ # - https://ruby-doc.org/core-2.7.1/UnboundMethod.html#method-i-bind_call
57
+ # - https://blog.saeloun.com/2019/10/17/ruby-2-7-adds-unboundmethod-bind_call-method.html
58
+ #
59
+ def own_method
60
+ method = Utils::Module.get_own_instance_method(organizer.class, method_name, private: true)
61
+
62
+ return unless method
63
+
64
+ method.bind(organizer)
65
+ end
66
+
67
+ ##
68
+ # @return [ConvenientService::Service]
69
+ #
70
+ def organizer
71
+ @organizer ||= entity.organizer
72
+ end
73
+
74
+ ##
75
+ # @return [Symbol]
76
+ #
77
+ def method_name
78
+ @method_name ||= entity.method
79
+ end
80
+
81
+ ##
82
+ # @return [Hash{Symbol => Object}]
83
+ #
84
+ def input_values
85
+ @input_values ||= entity.input_values
26
86
  end
27
87
  end
28
88
  end
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "can_be_executed/exceptions"
3
4
  require_relative "can_be_executed/middleware"
@@ -25,6 +25,13 @@ module ConvenientService
25
25
  def method_step?
26
26
  Utils.to_bool(method)
27
27
  end
28
+
29
+ ##
30
+ # @return [Boolean]
31
+ #
32
+ def result_step?
33
+ method_step? && method == :result
34
+ end
28
35
  end
29
36
  end
30
37
  end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "can_have_alternative_steps/middleware"
@@ -39,52 +39,6 @@ module ConvenientService
39
39
  def fallback_step?
40
40
  fallback_true_step? || fallback_failure_step? || fallback_error_step?
41
41
  end
42
-
43
- ##
44
- # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
45
- # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
46
- #
47
- # @note `service_fallback_failure_result` has middlewares.
48
- #
49
- # @internal
50
- # IMPORTANT: `service.klass.fallback_failure_result(**input_values)` is the reason, why services should have only kwargs as arguments.
51
- # TODO: Extract `StepDefinition`. This way `has_organizer?` check can be avoided completely.
52
- #
53
- def service_fallback_failure_result
54
- service.klass.fallback_failure_result(**input_values)
55
- end
56
-
57
- ##
58
- # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
59
- # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
60
- # @note `fallback_failure_result` has middlewares.
61
- #
62
- def fallback_failure_result
63
- convert_to_step_result(service_fallback_failure_result)
64
- end
65
-
66
- ##
67
- # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
68
- # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
69
- #
70
- # @note `service_fallback_error_result` has middlewares.
71
- #
72
- # @internal
73
- # IMPORTANT: `service.klass.fallback_error_result(**input_values)` is the reason, why services should have only kwargs as arguments.
74
- # TODO: Extract `StepDefinition`. This way `has_organizer?` check can be avoided completely.
75
- #
76
- def service_fallback_error_result
77
- service.klass.fallback_error_result(**input_values)
78
- end
79
-
80
- ##
81
- # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
82
- # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
83
- # @note `fallback_error_result` has middlewares.
84
- #
85
- def fallback_error_result
86
- convert_to_step_result(service_fallback_error_result)
87
- end
88
42
  end
89
43
  end
90
44
  end
@@ -21,9 +21,9 @@ module ConvenientService
21
21
  when :success
22
22
  result
23
23
  when :failure
24
- fallback_failure_step? ? entity.fallback_failure_result(...) : result
24
+ fallback_failure_step? ? fallback_failure_result(...) : result
25
25
  when :error
26
- fallback_error_step? ? entity.fallback_error_result(...) : result
26
+ fallback_error_step? ? fallback_error_result(...) : result
27
27
  end
28
28
  end
29
29
 
@@ -63,6 +63,30 @@ module ConvenientService
63
63
  def fallback_true_status
64
64
  middleware_arguments.kwargs.fetch(:fallback_true_status) { :failure }
65
65
  end
66
+
67
+ ##
68
+ # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
69
+ # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
70
+ #
71
+ # @internal
72
+ # IMPORTANT: `service.klass.fallback_failure_result(**input_values)` is the reason, why services should have only kwargs as arguments.
73
+ # TODO: `entity.service.fallback_failure_result`.
74
+ #
75
+ def fallback_failure_result
76
+ entity.service.klass.fallback_failure_result(**entity.input_values)
77
+ end
78
+
79
+ ##
80
+ # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
81
+ # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
82
+ #
83
+ # @internal
84
+ # IMPORTANT: `service.klass.fallback_error_result(**input_values)` is the reason, why services should have only kwargs as arguments.
85
+ # TODO: `entity.service.fallback_error_result`.
86
+ #
87
+ def fallback_error_result
88
+ entity.service.klass.fallback_error_result(**entity.input_values)
89
+ end
66
90
  end
67
91
  end
68
92
  end
@@ -11,8 +11,20 @@ module ConvenientService
11
11
  class Middleware < MethodChainMiddleware
12
12
  intended_for :result, entity: :step
13
13
 
14
+ ##
15
+ # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
16
+ # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
17
+ #
18
+ # @internal
19
+ # IMPORTANT: `CanHaveParentResult` middleware MUST be placed after `HasResult` middleware.
20
+ #
21
+ # NOTE: `result` at the moment of this middleware is still a `service_result` (or `method_result`). It is only later converted to `step_result` by `HasResult` middleware.
22
+ # That is why `result` is used as `parent` here.
23
+ #
14
24
  def next(...)
15
- chain.next(...).copy(overrides: {kwargs: {parent: entity.service_result}})
25
+ result = chain.next(...)
26
+
27
+ result.copy(overrides: {kwargs: {parent: result}})
16
28
  end
17
29
  end
18
30
  end
@@ -7,16 +7,20 @@ module ConvenientService
7
7
  module Entities
8
8
  class Step
9
9
  module Plugins
10
- module CanBeResultStep
10
+ module HasResult
11
11
  module Concern
12
12
  include Support::Concern
13
13
 
14
14
  instance_methods do
15
15
  ##
16
- # @return [Boolean]
16
+ # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
17
+ # @raise [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer]
17
18
  #
18
- def result_step?
19
- method_step? && method == :result
19
+ # @internal
20
+ # TODO: `service.result`.
21
+ #
22
+ def result
23
+ service_result
20
24
  end
21
25
  end
22
26
  end