convenient_service 0.17.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- # Usage example:
5
- #
6
- # result = ConvenientService::Examples::Dry::V1::Gemfile::Services::ParseContent.result(
7
- # content: <<~'RUBY'
8
- # ruby "3.0.1"
9
- # source "https://rubygems.org"
10
-
11
- # git_source(:github) { |repo| "https://github.com/#{repo}.git" }
12
-
13
- # gem "bootsnap", ">= 1.4.4", require: false
14
-
15
- # group :development do
16
- # gem "listen", "~> 3.3"
17
- # end
18
-
19
- # group :development, :test do
20
- # gem "rspec-rails"
21
- # end
22
- # RUBY
23
- # )
24
- #
25
- # NOTE: Check the corresponding spec file to see more examples.
26
- #
27
- module ConvenientService
28
- module Examples
29
- module Dry
30
- module V1
31
- class Gemfile
32
- module Services
33
- class ParseContent
34
- RUBY_REGEX = /\A\s*ruby/
35
- SOURCE_REGEX = /\A\s*source/
36
- GIT_SOURCE_REGEX = /\A\s*git_source/
37
- GROUP_REGEX = /\A\s*group/
38
- GEM_REGEX = /\A\s*gem/
39
- BLOCK_END_REGEX = /\A\s*end/
40
- ENV_SCAN_REGEX = /:(\w+)/
41
-
42
- include DryService::Config
43
-
44
- option :content
45
-
46
- contract do
47
- schema do
48
- required(:content).filled(:string)
49
- end
50
- end
51
-
52
- step Services::AssertValidRubySyntax, in: :content
53
- step :result, in: :content, out: :parsed_content
54
-
55
- def result
56
- success(data: {parsed_content: parse_content})
57
- end
58
-
59
- def parse_content
60
- hash = ::Hash.new { |h, k| h[k] = [] }
61
-
62
- ::StringIO.open(content) do |io|
63
- envs = []
64
-
65
- until io.eof?
66
- line = io.readline.rstrip
67
-
68
- case line
69
- when RUBY_REGEX
70
- hash[:ruby] << line
71
- when SOURCE_REGEX
72
- hash[:source] << line
73
- when GIT_SOURCE_REGEX
74
- hash[:git_source] << line
75
- when GROUP_REGEX
76
- envs = line.scan(ENV_SCAN_REGEX).map(&:first).map(&:to_sym)
77
- when GEM_REGEX
78
- hash[:gems] << {envs: envs, line: line.lstrip}
79
- when BLOCK_END_REGEX
80
- envs = []
81
- else
82
- hash[:rest] << line
83
- end
84
- end
85
- end
86
-
87
- hash
88
- end
89
- end
90
- end
91
- end
92
- end
93
- end
94
- end
95
- end
@@ -1,33 +0,0 @@
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 ReadFileContent
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
- step Services::AssertFileExists, in: :path
21
- step Services::AssertFileNotEmpty, in: :path
22
- step :result, in: :path, out: :content
23
-
24
- def result
25
- success(data: {content: ::File.read(path)})
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,43 +0,0 @@
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 RunShellCommand
10
- include DryService::Config
11
-
12
- option :command
13
- option :debug, default: -> { false }
14
-
15
- contract do
16
- schema do
17
- required(:command).filled(:string)
18
- optional(:debug).value(:bool)
19
- end
20
- end
21
-
22
- step :result,
23
- in: :command
24
-
25
- def result
26
- ##
27
- # NOTE: When the command exit code is 0, `system` return `true`, and `false` otherwise.
28
- # - https://ruby-doc.org/core-3.1.2/Kernel.html#method-i-system
29
- # - https://stackoverflow.com/a/37329716/12201472
30
- #
31
- if system(command)
32
- success
33
- else
34
- error(message: "#{command} returned non-zero exit code")
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- # Usage:
5
- #
6
- # ConvenientService::Examples::Dry::V1::Gemfile::Services::StripComments.result(content: "abc")
7
- #
8
- module ConvenientService
9
- module Examples
10
- module Dry
11
- module V1
12
- class Gemfile
13
- module Services
14
- class StripComments
15
- include DryService::Config
16
-
17
- option :content
18
-
19
- contract do
20
- schema do
21
- required(:content).filled(:string)
22
- end
23
- end
24
-
25
- alias_method :content_with_comments, :content
26
-
27
- step Services::AssertNpmPackageAvailable, in: {name: -> { "strip-comments" }}
28
- step Services::RunShellCommand, in: {command: -> { "node -e '#{js_script}' #{file_with_comments.path} #{file_without_comments.path}" }}
29
- step :result, in: :file_without_comments, out: :content_without_comments
30
-
31
- def result
32
- success(data: {content_without_comments: file_without_comments.read})
33
- end
34
-
35
- private
36
-
37
- ##
38
- # NOTE: When you have no time to do something well, delegate that task to someone who already works with it all the time.
39
- # That is why `strip-comments` npm package is used to remove comments.
40
- #
41
- def js_script
42
- ##
43
- # NOTE: `main` function is created in order to have an ability to use early returns.
44
- #
45
- # IMPORTANT: Use only double quotes inside this JS script, since it is later consumed by `node -e` option wrapped by single quoutes.
46
- #
47
- # TODO: Consider to use WeakRef if memory is a concern.
48
- # https://ruby-doc.org/stdlib-2.5.1/libdoc/weakref/rdoc/WeakRef.html
49
- #
50
- # TODO: Jest tests for JS script.
51
- #
52
- @js_script ||= <<~JAVASCRIPT.gsub(/\n\s*/, " ")
53
- const main = () => {
54
- const process = require("process");
55
- const fs = require("fs");
56
- const strip = require("strip-comments");
57
-
58
- const fileWithCommentsPath = process.argv[1];
59
- const fileWithoutCommentsPath = process.argv[2];
60
- const language = process.argv[3] || "ruby";
61
-
62
- if (!fileWithCommentsPath) {
63
- console.log("Error: Input file path is NOT passed.");
64
-
65
- process.exit(1);
66
- }
67
-
68
- if (!fileWithoutCommentsPath) {
69
- console.log("Error: Output file path is NOT passed.");
70
-
71
- process.exit(1);
72
- }
73
-
74
- if (!["ruby", "javascript"].includes(language)) {
75
- console.log("Error: Language " + language + " is NOT supported.");
76
-
77
- process.exit(1);
78
- }
79
-
80
- const fileWithCommentsContent = fs.readFileSync(fileWithCommentsPath, { encoding: "utf8" });
81
- const fileWithoutCommentsContent = strip(fileWithCommentsContent, { language });
82
-
83
- fs.writeFileSync(fileWithoutCommentsPath, fileWithoutCommentsContent, { encoding: "utf8" });
84
-
85
- process.exit(0);
86
- };
87
-
88
- main();
89
- JAVASCRIPT
90
- end
91
-
92
- def file_with_comments
93
- ##
94
- # NOTE: Tempfile is used to avoid issues with escaping of quotes inside JS script.
95
- #
96
- @file_with_comments ||= ::Tempfile.new.tap { |tempfile| tempfile.write(content_with_comments) }.tap(&:close)
97
- end
98
-
99
- def file_without_comments
100
- ##
101
- # NOTE: JS script tries to fill content of the file without comments.
102
- #
103
- @file_without_comments ||= ::Tempfile.new
104
- end
105
- end
106
- end
107
- end
108
- end
109
- end
110
- end
111
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "services/run_shell_command"
4
-
5
- require_relative "services/assert_file_exists"
6
- require_relative "services/assert_file_not_empty"
7
- require_relative "services/assert_node_available"
8
- require_relative "services/assert_npm_package_available"
9
- require_relative "services/assert_valid_ruby_syntax"
10
- require_relative "services/read_file_content"
11
- require_relative "services/strip_comments"
12
- require_relative "services/parse_content"
13
- require_relative "services/format_header"
14
- require_relative "services/format_gems_without_envs"
15
- require_relative "services/format_gems_with_envs"
16
- require_relative "services/format_body"
17
- require_relative "services/format"
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "gemfile/dry_service"
4
- require_relative "gemfile/services"
5
-
6
- ##
7
- # @internal
8
- # Usage example:
9
- #
10
- # result = ConvenientService::Examples::Dry::V1::Gemfile.format("Gemfile")
11
- # result = ConvenientService::Examples::Dry::V1::Gemfile.format("spec/cli/gemfile/format/fixtures/Gemfile")
12
- #
13
- module ConvenientService
14
- module Examples
15
- module Dry
16
- module V1
17
- class Gemfile
18
- include ConvenientService::Feature::Standard::Config
19
-
20
- entry :format
21
-
22
- def format(path)
23
- Services::Format[path: path]
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- # Usage example:
5
- #
6
- # result = ConvenientService::Examples::Rails::Gemfile.format(path: "Gemfile")
7
- # result = ConvenientService::Examples::Rails::Gemfile.format(path: "spec/cli/gemfile/format/fixtures/Gemfile")
8
- #
9
- module ConvenientService
10
- module Examples
11
- module Rails
12
- class Gemfile
13
- class RailsService
14
- module Config
15
- include Support::Concern
16
-
17
- included do
18
- include ConvenientService::Standard::Config
19
-
20
- ##
21
- # NOTE: `AssignsAttributesInConstructor::UsingActiveModelAttributeAssignment` plugin.
22
- #
23
- concerns do
24
- use ConvenientService::Plugins::Common::AssignsAttributesInConstructor::UsingActiveModelAttributeAssignment::Concern
25
- end
26
-
27
- middlewares :initialize do
28
- use ConvenientService::Plugins::Common::AssignsAttributesInConstructor::UsingActiveModelAttributeAssignment::Middleware
29
- end
30
-
31
- ##
32
- # NOTE: `HasAttributes::UsingActiveModelAttributes` plugin.
33
- #
34
- concerns do
35
- use ConvenientService::Plugins::Common::HasAttributes::UsingActiveModelAttributes::Concern
36
- end
37
-
38
- ##
39
- # NOTE: `HasJSendResultParamsValidations::UsingActiveModelValidations` plugin.
40
- #
41
- concerns do
42
- use ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingActiveModelValidations::Concern
43
- end
44
-
45
- middlewares :result do
46
- insert_before \
47
- ConvenientService::Plugins::Service::RaisesOnNotResultReturnValue::Middleware,
48
- ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingActiveModelValidations::Middleware
49
- end
50
- end
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "rails_service/config"
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Examples
5
- module Rails
6
- class Gemfile
7
- module Services
8
- class AssertFileExists
9
- include RailsService::Config
10
-
11
- attribute :path, :string
12
-
13
- validates :path, presence: true if ConvenientService::Dependencies.support_has_j_send_result_params_validations_using_active_model_validations?
14
-
15
- def result
16
- return failure("File with path `#{path}` does NOT exist") unless ::File.exist?(path)
17
-
18
- success
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Examples
5
- module Rails
6
- class Gemfile
7
- module Services
8
- class AssertFileNotEmpty
9
- include RailsService::Config
10
-
11
- attribute :path, :string
12
-
13
- validates :path, presence: true if ConvenientService::Dependencies.support_has_j_send_result_params_validations_using_active_model_validations?
14
-
15
- def result
16
- return failure("File with path `#{path}` is empty") if ::File.zero?(path)
17
-
18
- success
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- # Usage example:
5
- #
6
- # ConvenientService::Examples::Rails::Gemfile::Services::AssertNodeAvailable.result
7
- #
8
- module ConvenientService
9
- module Examples
10
- module Rails
11
- class Gemfile
12
- module Services
13
- class AssertNodeAvailable
14
- include RailsService::Config
15
-
16
- ##
17
- # NOTE: `> /dev/null 2>&1` is used to hide output.
18
- # https://unix.stackexchange.com/a/119650/394253
19
- #
20
- step Services::RunShellCommand, in: {command: -> { "which node > /dev/null 2>&1" }}
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- # Usage example:
5
- #
6
- # ConvenientService::Examples::Rails::Gemfile::Services::AssertNpmPackageAvailable.result(name: "lodash")
7
- #
8
- module ConvenientService
9
- module Examples
10
- module Rails
11
- class Gemfile
12
- module Services
13
- class AssertNpmPackageAvailable
14
- include RailsService::Config
15
-
16
- attribute :name, :string
17
-
18
- validates :name, presence: true if ConvenientService::Dependencies.support_has_j_send_result_params_validations_using_active_model_validations?
19
-
20
- step Services::AssertNodeAvailable
21
-
22
- ##
23
- # NOTE: `> /dev/null 2>&1` is used to hide output.
24
- # https://unix.stackexchange.com/a/119650/394253
25
- #
26
- # NOTE: For `npm list` and its options docs, see
27
- # https://docs.npmjs.com/cli/v7/commands/npm-ls
28
- #
29
- step Services::RunShellCommand, in: {command: -> { "npm list #{name} --depth=0 > /dev/null 2>&1" }}
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Examples
5
- module Rails
6
- class Gemfile
7
- module Services
8
- class AssertValidRubySyntax
9
- include RailsService::Config
10
-
11
- attribute :content, :string
12
-
13
- def result
14
- ##
15
- # NOTE: `> /dev/null 2>&1` is used to hide output.
16
- # https://unix.stackexchange.com/a/119650/394253
17
- #
18
- check_ruby_syntax_result = Services::RunShellCommand.result(command: "ruby -c #{file.path} > /dev/null 2>&1")
19
-
20
- return error("`#{content}` contains invalid Ruby syntax") unless check_ruby_syntax_result.success?
21
-
22
- success
23
- end
24
-
25
- private
26
-
27
- def file
28
- @file ||= ::Tempfile.new.tap { |tempfile| tempfile.write(content) }.tap(&:close)
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- # Usage example:
5
- #
6
- # result = ConvenientService::Examples::Rails::Gemfile::Services::Format.result(path: "Gemfile")
7
- # result = ConvenientService::Examples::Rails::Gemfile::Services::Format.result(path: "spec/cli/gemfile/format/fixtures/Gemfile")
8
- #
9
- module ConvenientService
10
- module Examples
11
- module Rails
12
- class Gemfile
13
- module Services
14
- class Format
15
- include RailsService::Config
16
-
17
- attribute :path, :string
18
-
19
- validates :path, presence: true if ConvenientService::Dependencies.support_has_j_send_result_params_validations_using_active_model_validations?
20
-
21
- step Services::ReadFileContent,
22
- in: :path,
23
- out: :content
24
-
25
- step Services::StripComments,
26
- in: :content,
27
- out: :content_without_comments
28
-
29
- step Services::ParseContent,
30
- in: {content: :content_without_comments},
31
- out: :parsed_content
32
-
33
- step Services::FormatHeader,
34
- in: :parsed_content,
35
- out: {formatted_content: :formatted_header_content}
36
-
37
- step Services::FormatBody,
38
- in: :parsed_content,
39
- out: {formatted_content: :formatted_body_content}
40
-
41
- step Services::MergeSections,
42
- in: [
43
- {header: :formatted_header_content},
44
- {body: :formatted_body_content}
45
- ],
46
- out: :merged_sections
47
-
48
- step Services::ReplaceFileContent,
49
- in: [
50
- :path,
51
- {content: :merged_sections}
52
- ]
53
-
54
- before :result do
55
- @progressbar = ::ProgressBar.create(title: "Formatting", total: steps.count)
56
- end
57
-
58
- after :step do |step|
59
- @progressbar.increment
60
- end
61
- end
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- # Usage example:
5
- #
6
- # result = ConvenientService::Examples::Rails::Gemfile::Services::FormatBody.result(
7
- # parsed_content: {
8
- # gems: [
9
- # {
10
- # envs: [],
11
- # line: %(gem "bootsnap", ">= 1.4.4", require: false)
12
- # },
13
- # {
14
- # envs: [],
15
- # line: %(gem "pg")
16
- # },
17
- # {
18
- # envs: [:development],
19
- # line: %(gem "listen", "~> 3.3")
20
- # },
21
- # {
22
- # envs: [:development],
23
- # line: %(gem "web-console", ">= 4.1.0")
24
- # },
25
- # {
26
- # envs: [:development, :test],
27
- # line: %(gem "rspec-rails")
28
- # },
29
- # {
30
- # envs: [:test],
31
- # line: %(gem "simplecov", require: false)
32
- # },
33
- # {
34
- # envs: [],
35
- # line: %(gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby])
36
- # }
37
- # ]
38
- # }
39
- # )
40
- #
41
- # NOTE: Check the corresponding spec file to see more examples.
42
- #
43
- module ConvenientService
44
- module Examples
45
- module Rails
46
- class Gemfile
47
- module Services
48
- class FormatBody
49
- include RailsService::Config
50
-
51
- attr_accessor :parsed_content
52
-
53
- step Services::FormatGemsWithoutEnvs,
54
- in: :parsed_content,
55
- out: [{formatted_content: :formatted_gems_without_envs_content}]
56
-
57
- step Services::FormatGemsWithEnvs,
58
- in: :parsed_content,
59
- out: [{formatted_content: :formatted_gems_with_envs_content}]
60
-
61
- step :result,
62
- in: [:formatted_gems_without_envs_content, :formatted_gems_with_envs_content],
63
- out: :formatted_content
64
-
65
- def result
66
- success(formatted_content: format_content)
67
- end
68
-
69
- private
70
-
71
- def format_content
72
- [formatted_gems_without_envs_content, formatted_gems_with_envs_content].reject(&:empty?).join("\n")
73
- end
74
- end
75
- end
76
- end
77
- end
78
- end
79
- end