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.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/convenient_service/common/plugins/ensures_negated_j_send_result/middleware.rb +22 -0
- data/lib/convenient_service/common/plugins/ensures_negated_j_send_result.rb +3 -0
- data/lib/convenient_service/common/plugins/has_around_callbacks/concern.rb +8 -1
- data/lib/convenient_service/common/plugins/has_around_callbacks/middleware.rb +28 -7
- data/lib/convenient_service/common/plugins/has_callbacks/concern.rb +19 -9
- data/lib/convenient_service/common/plugins/has_callbacks/entities/callback_collection.rb +49 -1
- data/lib/convenient_service/common/plugins/has_callbacks/middleware.rb +21 -3
- data/lib/convenient_service/common/plugins/has_callbacks.rb +0 -1
- data/lib/convenient_service/common/plugins/has_instance_proxy/entities/instance_proxy.rb +1 -1
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/concern.rb +12 -0
- data/lib/convenient_service/common/plugins.rb +1 -0
- data/lib/convenient_service/core/entities/config/exceptions.rb +2 -0
- data/lib/convenient_service/core/entities/config.rb +3 -0
- data/lib/convenient_service/dependencies.rb +11 -3
- data/lib/convenient_service/logger.rb +9 -1
- data/lib/convenient_service/rspec/matchers/classes/call_chain_next.rb +41 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb +46 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/delegation.rb +89 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb +223 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/outputs.rb +38 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb +157 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/apply_stub_to_track_delegations.rb +77 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb +94 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments.rb +89 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/base.rb +99 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_custom_value.rb +91 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_delegation_value.rb +129 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/with_any_arguments.rb +31 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/with_concrete_arguments.rb +31 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/without_arguments.rb +31 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers.rb +11 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities.rb +5 -1
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/exceptions.rb +65 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to.rb +163 -41
- data/lib/convenient_service/service/configs/minimal.rb +85 -33
- data/lib/convenient_service/service/configs/standard/v1.rb +42 -24
- data/lib/convenient_service/service/configs/standard.rb +60 -46
- data/lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb +503 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb +133 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/base.rb +126 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/empty.rb +104 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/group.rb +118 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/not.rb +118 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb +145 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/scalar.rb +133 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions.rb +10 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb +217 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities.rb +4 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/exceptions.rb +95 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/middleware.rb +30 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps.rb +6 -0
- data/lib/convenient_service/service/plugins/can_have_sequential_steps/concern.rb +76 -0
- data/lib/convenient_service/service/plugins/{can_have_steps → can_have_sequential_steps}/entities/step_collection.rb +54 -10
- data/lib/convenient_service/service/plugins/can_have_sequential_steps/entities.rb +3 -0
- data/lib/convenient_service/service/plugins/{can_have_steps → can_have_sequential_steps}/middleware.rb +7 -3
- data/lib/convenient_service/service/plugins/can_have_sequential_steps.rb +5 -0
- data/lib/convenient_service/service/plugins/can_have_steps/concern.rb +4 -57
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/define_method_in_container.rb +45 -26
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/reassignment.rb +0 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/exceptions.rb +4 -24
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/concern/instance_methods.rb +155 -80
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/exceptions.rb +19 -0
- 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
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/can_be_executed/middleware.rb +64 -4
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/can_be_executed.rb +1 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/concern.rb +7 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_alternative_steps.rb +3 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/concern.rb +0 -46
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/middleware.rb +26 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_parent_result/middleware.rb +13 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/{can_be_result_step → has_result}/concern.rb +8 -4
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result/middleware.rb +33 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result.rb +4 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +2 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities.rb +0 -1
- data/lib/convenient_service/service/plugins/can_have_steps.rb +0 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/concern.rb +2 -2
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status.rb +0 -1
- 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
- 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
- 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
- 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
- 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
- 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
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/exceptions.rb +15 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_negated_result/concern.rb +72 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_negated_result.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/raises_on_not_checked_result_status/middleware.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins.rb +1 -0
- data/lib/convenient_service/service/plugins/has_j_send_result.rb +0 -1
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_dry_validation/middleware.rb +4 -0
- data/lib/convenient_service/service/plugins/has_negated_j_send_result/concern.rb +23 -0
- data/lib/convenient_service/service/plugins/has_negated_j_send_result.rb +3 -0
- data/lib/convenient_service/service/plugins/has_negated_result/concern.rb +33 -0
- data/lib/convenient_service/service/plugins/{has_j_send_result → has_negated_result}/exceptions.rb +3 -3
- data/lib/convenient_service/service/plugins/has_negated_result.rb +4 -0
- data/lib/convenient_service/service/plugins/{wraps_result_in_db_transaction → wraps_result_in_d_b_transaction}/middleware.rb +1 -1
- data/lib/convenient_service/service/plugins.rb +7 -2
- data/lib/convenient_service/specification.rb +28 -0
- data/lib/convenient_service/support/backtrace_cleaner.rb +6 -1
- data/lib/convenient_service/support/cache/entities/caches/base.rb +3 -0
- data/lib/convenient_service/support/method_parameters.rb +121 -0
- data/lib/convenient_service/support/never_reach_here.rb +21 -0
- data/lib/convenient_service/support/unique_value.rb +3 -0
- data/lib/convenient_service/support/value.rb +78 -0
- data/lib/convenient_service/support.rb +3 -0
- data/lib/convenient_service/utils/array/find_last.rb +8 -3
- data/lib/convenient_service/utils/object/instance_variable_delete.rb +1 -1
- data/lib/convenient_service/version.rb +1 -1
- data/lib/convenient_service.rb +23 -0
- metadata +109 -308
- data/.dev/.tmuxinator.yml +0 -22
- data/.dockerignore +0 -1
- data/.gem_release.yml +0 -11
- data/.github/contributing.md +0 -15
- data/.github/issue_template.md +0 -35
- data/.github/pull_request_template.md +0 -31
- data/.github/workflows/cd.yml +0 -68
- data/.github/workflows/ci.yml +0 -212
- data/.gitignore +0 -66
- data/.inch.yml +0 -7
- data/.rspec +0 -3
- data/.rubocop.yml +0 -45
- data/.rubocop_rspec.yml +0 -58
- data/.ruby-version +0 -1
- data/.tool-versions +0 -1
- data/.vscode/CacheItsValue.code-snippets +0 -15
- data/.vscode/DelegateTo.code-snippets +0 -15
- data/.vscode/cache_its_value.code-snippets +0 -17
- data/.vscode/comparison.code-snippets +0 -41
- data/.vscode/delegate_to.code-snippets +0 -20
- data/.yardopts +0 -16
- data/Appraisals +0 -146
- data/CHANGELOG.md +0 -504
- data/Gemfile +0 -17
- data/ROADMAP.md +0 -92
- data/Rakefile +0 -54
- data/Taskfile.yml +0 -679
- data/benchmark/commit_config/ips.rb +0 -18
- data/benchmark/commit_config/profile.rb +0 -30
- data/benchmark/empty_service/ips.rb +0 -123
- data/benchmark/has_committed_config/ips.rb +0 -78
- data/benchmark/has_committed_config/profile.rb +0 -30
- data/convenient_service.gemspec +0 -233
- data/coverage/.gitkeep +0 -0
- data/docker/2.7/Dockerfile +0 -73
- data/docker/3.0/Dockerfile +0 -73
- data/docker/3.1/Dockerfile +0 -73
- data/docker/3.2/Dockerfile +0 -73
- data/docker/jruby-9.4/Dockerfile +0 -88
- data/docker/truffleruby-22.3/Dockerfile +0 -91
- data/docs/.gitkeep +0 -0
- data/docs/api/.gitkeep +0 -0
- data/env.rb +0 -23
- data/gemfiles/.gitkeep +0 -0
- data/lib/convenient_service/common/plugins/has_callbacks/container.rb +0 -17
- data/lib/convenient_service/examples/dry/gemfile/dry_service/config.rb +0 -45
- data/lib/convenient_service/examples/dry/gemfile/dry_service.rb +0 -3
- data/lib/convenient_service/examples/dry/gemfile/services/assert_file_exists.rb +0 -29
- data/lib/convenient_service/examples/dry/gemfile/services/assert_file_not_empty.rb +0 -29
- data/lib/convenient_service/examples/dry/gemfile/services/assert_node_available.rb +0 -26
- data/lib/convenient_service/examples/dry/gemfile/services/assert_npm_package_available.rb +0 -39
- data/lib/convenient_service/examples/dry/gemfile/services/assert_valid_ruby_syntax.rb +0 -41
- data/lib/convenient_service/examples/dry/gemfile/services/format.rb +0 -37
- data/lib/convenient_service/examples/dry/gemfile/services/format_body.rb +0 -93
- data/lib/convenient_service/examples/dry/gemfile/services/format_gems_with_envs.rb +0 -96
- data/lib/convenient_service/examples/dry/gemfile/services/format_gems_without_envs.rb +0 -84
- data/lib/convenient_service/examples/dry/gemfile/services/format_header.rb +0 -74
- data/lib/convenient_service/examples/dry/gemfile/services/parse_content.rb +0 -93
- data/lib/convenient_service/examples/dry/gemfile/services/print_shell_command.rb +0 -44
- data/lib/convenient_service/examples/dry/gemfile/services/read_file_content.rb +0 -31
- data/lib/convenient_service/examples/dry/gemfile/services/run_shell_command.rb +0 -45
- data/lib/convenient_service/examples/dry/gemfile/services/strip_comments.rb +0 -109
- data/lib/convenient_service/examples/dry/gemfile/services.rb +0 -18
- data/lib/convenient_service/examples/dry/gemfile.rb +0 -27
- data/lib/convenient_service/examples/dry/v1/gemfile/dry_service/config.rb +0 -47
- data/lib/convenient_service/examples/dry/v1/gemfile/dry_service.rb +0 -3
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_file_exists.rb +0 -31
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_file_not_empty.rb +0 -31
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_node_available.rb +0 -28
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_npm_package_available.rb +0 -41
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_valid_ruby_syntax.rb +0 -43
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format.rb +0 -39
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_body.rb +0 -95
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_gems_with_envs.rb +0 -98
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_gems_without_envs.rb +0 -86
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_header.rb +0 -76
- data/lib/convenient_service/examples/dry/v1/gemfile/services/parse_content.rb +0 -95
- data/lib/convenient_service/examples/dry/v1/gemfile/services/read_file_content.rb +0 -33
- data/lib/convenient_service/examples/dry/v1/gemfile/services/run_shell_command.rb +0 -43
- data/lib/convenient_service/examples/dry/v1/gemfile/services/strip_comments.rb +0 -111
- data/lib/convenient_service/examples/dry/v1/gemfile/services.rb +0 -17
- data/lib/convenient_service/examples/dry/v1/gemfile.rb +0 -29
- data/lib/convenient_service/examples/rails/gemfile/rails_service/config.rb +0 -56
- data/lib/convenient_service/examples/rails/gemfile/rails_service.rb +0 -3
- data/lib/convenient_service/examples/rails/gemfile/services/assert_file_exists.rb +0 -25
- data/lib/convenient_service/examples/rails/gemfile/services/assert_file_not_empty.rb +0 -25
- data/lib/convenient_service/examples/rails/gemfile/services/assert_node_available.rb +0 -26
- data/lib/convenient_service/examples/rails/gemfile/services/assert_npm_package_available.rb +0 -35
- data/lib/convenient_service/examples/rails/gemfile/services/assert_valid_ruby_syntax.rb +0 -35
- data/lib/convenient_service/examples/rails/gemfile/services/format.rb +0 -66
- data/lib/convenient_service/examples/rails/gemfile/services/format_body.rb +0 -79
- data/lib/convenient_service/examples/rails/gemfile/services/format_gems_with_envs.rb +0 -82
- data/lib/convenient_service/examples/rails/gemfile/services/format_gems_without_envs.rb +0 -70
- data/lib/convenient_service/examples/rails/gemfile/services/format_header.rb +0 -68
- data/lib/convenient_service/examples/rails/gemfile/services/merge_sections.rb +0 -25
- data/lib/convenient_service/examples/rails/gemfile/services/parse_content.rb +0 -89
- data/lib/convenient_service/examples/rails/gemfile/services/print_shell_command.rb +0 -40
- data/lib/convenient_service/examples/rails/gemfile/services/read_file_content.rb +0 -27
- data/lib/convenient_service/examples/rails/gemfile/services/replace_file_content.rb +0 -37
- data/lib/convenient_service/examples/rails/gemfile/services/run_shell_command.rb +0 -40
- data/lib/convenient_service/examples/rails/gemfile/services/strip_comments.rb +0 -107
- data/lib/convenient_service/examples/rails/gemfile/services.rb +0 -21
- data/lib/convenient_service/examples/rails/gemfile.rb +0 -27
- data/lib/convenient_service/examples/rails/v1/gemfile/rails_service/config.rb +0 -58
- data/lib/convenient_service/examples/rails/v1/gemfile/rails_service.rb +0 -3
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_file_exists.rb +0 -27
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_file_not_empty.rb +0 -27
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_node_available.rb +0 -28
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_npm_package_available.rb +0 -37
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_valid_ruby_syntax.rb +0 -37
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format.rb +0 -68
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_body.rb +0 -81
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_gems_with_envs.rb +0 -84
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_gems_without_envs.rb +0 -72
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_header.rb +0 -70
- data/lib/convenient_service/examples/rails/v1/gemfile/services/merge_sections.rb +0 -27
- data/lib/convenient_service/examples/rails/v1/gemfile/services/parse_content.rb +0 -91
- data/lib/convenient_service/examples/rails/v1/gemfile/services/read_file_content.rb +0 -29
- data/lib/convenient_service/examples/rails/v1/gemfile/services/replace_file_content.rb +0 -39
- data/lib/convenient_service/examples/rails/v1/gemfile/services/run_shell_command.rb +0 -38
- data/lib/convenient_service/examples/rails/v1/gemfile/services/strip_comments.rb +0 -109
- data/lib/convenient_service/examples/rails/v1/gemfile/services.rb +0 -20
- data/lib/convenient_service/examples/rails/v1/gemfile.rb +0 -29
- data/lib/convenient_service/examples/standard/cowsay/services/build_cloud.rb +0 -42
- data/lib/convenient_service/examples/standard/cowsay/services/build_cow.rb +0 -38
- data/lib/convenient_service/examples/standard/cowsay/services/print.rb +0 -32
- data/lib/convenient_service/examples/standard/cowsay/services.rb +0 -5
- data/lib/convenient_service/examples/standard/cowsay.rb +0 -26
- data/lib/convenient_service/examples/standard/date_time/services/safe_parse.rb +0 -31
- data/lib/convenient_service/examples/standard/date_time/services.rb +0 -3
- data/lib/convenient_service/examples/standard/date_time.rb +0 -25
- data/lib/convenient_service/examples/standard/factorial/services/calculate.rb +0 -55
- data/lib/convenient_service/examples/standard/factorial/services.rb +0 -3
- data/lib/convenient_service/examples/standard/factorial/utils/timeout/with_timeout.rb +0 -50
- data/lib/convenient_service/examples/standard/factorial/utils/timeout.rb +0 -21
- data/lib/convenient_service/examples/standard/factorial/utils.rb +0 -3
- data/lib/convenient_service/examples/standard/factorial.rb +0 -26
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb +0 -30
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_not_empty.rb +0 -30
- data/lib/convenient_service/examples/standard/gemfile/services/assert_node_available.rb +0 -26
- data/lib/convenient_service/examples/standard/gemfile/services/assert_npm_package_available.rb +0 -48
- data/lib/convenient_service/examples/standard/gemfile/services/assert_valid_ruby_syntax.rb +0 -39
- data/lib/convenient_service/examples/standard/gemfile/services/format.rb +0 -80
- data/lib/convenient_service/examples/standard/gemfile/services/format_body.rb +0 -83
- data/lib/convenient_service/examples/standard/gemfile/services/format_gems_with_envs.rb +0 -86
- data/lib/convenient_service/examples/standard/gemfile/services/format_gems_without_envs.rb +0 -74
- data/lib/convenient_service/examples/standard/gemfile/services/format_header.rb +0 -66
- data/lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb +0 -52
- data/lib/convenient_service/examples/standard/gemfile/services/parse_content.rb +0 -101
- data/lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb +0 -45
- data/lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb +0 -39
- data/lib/convenient_service/examples/standard/gemfile/services/replace_file_content.rb +0 -48
- data/lib/convenient_service/examples/standard/gemfile/services/run_shell_command.rb +0 -54
- data/lib/convenient_service/examples/standard/gemfile/services/strip_comments.rb +0 -111
- data/lib/convenient_service/examples/standard/gemfile/services.rb +0 -21
- data/lib/convenient_service/examples/standard/gemfile.rb +0 -26
- data/lib/convenient_service/examples/standard/request_params/constants.rb +0 -15
- data/lib/convenient_service/examples/standard/request_params/entities/description.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/entities/format.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/entities/id.rb +0 -47
- data/lib/convenient_service/examples/standard/request_params/entities/logger.rb +0 -21
- data/lib/convenient_service/examples/standard/request_params/entities/request.rb +0 -23
- data/lib/convenient_service/examples/standard/request_params/entities/source.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/entities/tag.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/entities/title.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/entities.rb +0 -11
- data/lib/convenient_service/examples/standard/request_params/services/apply_default_param_values.rb +0 -26
- data/lib/convenient_service/examples/standard/request_params/services/cast_params.rb +0 -38
- data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_body.rb +0 -70
- data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path.rb +0 -62
- data/lib/convenient_service/examples/standard/request_params/services/filter_out_unpermitted_params.rb +0 -26
- data/lib/convenient_service/examples/standard/request_params/services/log_request_params.rb +0 -54
- data/lib/convenient_service/examples/standard/request_params/services/merge_params.rb +0 -26
- data/lib/convenient_service/examples/standard/request_params/services/prepare.rb +0 -65
- data/lib/convenient_service/examples/standard/request_params/services/validate_casted_params.rb +0 -94
- data/lib/convenient_service/examples/standard/request_params/services/validate_uncasted_params.rb +0 -72
- data/lib/convenient_service/examples/standard/request_params/services.rb +0 -13
- data/lib/convenient_service/examples/standard/request_params/utils/array/wrap.rb +0 -46
- data/lib/convenient_service/examples/standard/request_params/utils/array.rb +0 -21
- data/lib/convenient_service/examples/standard/request_params/utils/http/request/parse_body.rb +0 -42
- data/lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/utils/http/request.rb +0 -28
- data/lib/convenient_service/examples/standard/request_params/utils/http.rb +0 -3
- data/lib/convenient_service/examples/standard/request_params/utils/integer/safe_parse.rb +0 -31
- data/lib/convenient_service/examples/standard/request_params/utils/integer.rb +0 -25
- data/lib/convenient_service/examples/standard/request_params/utils/json/safe_parse.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/utils/json.rb +0 -21
- data/lib/convenient_service/examples/standard/request_params/utils/object/blank.rb +0 -34
- data/lib/convenient_service/examples/standard/request_params/utils/object/present.rb +0 -31
- data/lib/convenient_service/examples/standard/request_params/utils/object.rb +0 -26
- data/lib/convenient_service/examples/standard/request_params/utils/url/valid.rb +0 -47
- data/lib/convenient_service/examples/standard/request_params/utils/url.rb +0 -21
- data/lib/convenient_service/examples/standard/request_params/utils.rb +0 -8
- data/lib/convenient_service/examples/standard/request_params.rb +0 -49
- data/lib/convenient_service/examples/standard/v1/cowsay/services/build_cloud.rb +0 -44
- data/lib/convenient_service/examples/standard/v1/cowsay/services/build_cow.rb +0 -40
- data/lib/convenient_service/examples/standard/v1/cowsay/services/print.rb +0 -34
- data/lib/convenient_service/examples/standard/v1/cowsay/services.rb +0 -5
- data/lib/convenient_service/examples/standard/v1/cowsay.rb +0 -26
- data/lib/convenient_service/examples/standard/v1/date_time/services/safe_parse.rb +0 -33
- data/lib/convenient_service/examples/standard/v1/date_time/services.rb +0 -3
- data/lib/convenient_service/examples/standard/v1/date_time.rb +0 -25
- data/lib/convenient_service/examples/standard/v1/factorial/services/calculate.rb +0 -51
- data/lib/convenient_service/examples/standard/v1/factorial/services.rb +0 -3
- data/lib/convenient_service/examples/standard/v1/factorial/utils/timeout/with_timeout.rb +0 -52
- data/lib/convenient_service/examples/standard/v1/factorial/utils/timeout.rb +0 -23
- data/lib/convenient_service/examples/standard/v1/factorial/utils.rb +0 -3
- data/lib/convenient_service/examples/standard/v1/factorial.rb +0 -26
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_exists.rb +0 -32
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_not_empty.rb +0 -32
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_node_available.rb +0 -28
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_npm_package_available.rb +0 -50
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_valid_ruby_syntax.rb +0 -41
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format.rb +0 -82
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_body.rb +0 -85
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_gems_with_envs.rb +0 -88
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_gems_without_envs.rb +0 -76
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_header.rb +0 -68
- data/lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb +0 -54
- data/lib/convenient_service/examples/standard/v1/gemfile/services/parse_content.rb +0 -103
- data/lib/convenient_service/examples/standard/v1/gemfile/services/read_file_content.rb +0 -41
- data/lib/convenient_service/examples/standard/v1/gemfile/services/replace_file_content.rb +0 -50
- data/lib/convenient_service/examples/standard/v1/gemfile/services/run_shell_command.rb +0 -52
- data/lib/convenient_service/examples/standard/v1/gemfile/services/strip_comments.rb +0 -113
- data/lib/convenient_service/examples/standard/v1/gemfile/services.rb +0 -20
- data/lib/convenient_service/examples/standard/v1/gemfile.rb +0 -26
- data/lib/convenient_service/examples/standard/v1/request_params/constants.rb +0 -17
- data/lib/convenient_service/examples/standard/v1/request_params/entities/description.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/entities/format.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/entities/id.rb +0 -49
- data/lib/convenient_service/examples/standard/v1/request_params/entities/logger.rb +0 -23
- data/lib/convenient_service/examples/standard/v1/request_params/entities/request.rb +0 -25
- data/lib/convenient_service/examples/standard/v1/request_params/entities/source.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/entities/tag.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/entities/title.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/entities.rb +0 -11
- data/lib/convenient_service/examples/standard/v1/request_params/services/apply_default_param_values.rb +0 -28
- data/lib/convenient_service/examples/standard/v1/request_params/services/cast_params.rb +0 -40
- data/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_body.rb +0 -72
- data/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_path.rb +0 -64
- data/lib/convenient_service/examples/standard/v1/request_params/services/filter_out_unpermitted_params.rb +0 -28
- data/lib/convenient_service/examples/standard/v1/request_params/services/log_request_params.rb +0 -56
- data/lib/convenient_service/examples/standard/v1/request_params/services/merge_params.rb +0 -28
- data/lib/convenient_service/examples/standard/v1/request_params/services/prepare.rb +0 -67
- data/lib/convenient_service/examples/standard/v1/request_params/services/validate_casted_params.rb +0 -96
- data/lib/convenient_service/examples/standard/v1/request_params/services/validate_uncasted_params.rb +0 -74
- data/lib/convenient_service/examples/standard/v1/request_params/services.rb +0 -13
- data/lib/convenient_service/examples/standard/v1/request_params/utils/array/wrap.rb +0 -48
- data/lib/convenient_service/examples/standard/v1/request_params/utils/array.rb +0 -23
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request/parse_body.rb +0 -44
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request/parse_path.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request.rb +0 -30
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http.rb +0 -3
- data/lib/convenient_service/examples/standard/v1/request_params/utils/integer/safe_parse.rb +0 -33
- data/lib/convenient_service/examples/standard/v1/request_params/utils/integer.rb +0 -27
- data/lib/convenient_service/examples/standard/v1/request_params/utils/json/safe_parse.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/utils/json.rb +0 -23
- data/lib/convenient_service/examples/standard/v1/request_params/utils/object/blank.rb +0 -36
- data/lib/convenient_service/examples/standard/v1/request_params/utils/object/present.rb +0 -33
- data/lib/convenient_service/examples/standard/v1/request_params/utils/object.rb +0 -28
- data/lib/convenient_service/examples/standard/v1/request_params/utils/url/valid.rb +0 -49
- data/lib/convenient_service/examples/standard/v1/request_params/utils/url.rb +0 -23
- data/lib/convenient_service/examples/standard/v1/request_params/utils.rb +0 -8
- data/lib/convenient_service/examples/standard/v1/request_params.rb +0 -49
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/commands/generate_printable_method.rb +0 -50
- 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
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments/commands/generate_printable_arguments.rb +0 -100
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments.rb +0 -95
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/base.rb +0 -87
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/return_its_value.rb +0 -132
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/with_any_arguments.rb +0 -37
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/with_concrete_arguments.rb +0 -37
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/without_arguments.rb +0 -37
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/base.rb +0 -41
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/with_calling_original.rb +0 -30
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/without_calling_original.rb +0 -30
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings.rb +0 -12
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings_collection/exceptions.rb +0 -57
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings_collection.rb +0 -171
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/delegation.rb +0 -79
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities.rb +0 -5
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb +0 -276
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/reassignment/commands/define_method_in_container.rb +0 -74
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/reassignment/commands.rb +0 -3
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_result_step/can_be_executed/middleware.rb +0 -72
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_result_step/can_be_executed.rb +0 -4
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_result_step.rb +0 -5
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/middleware.rb +0 -43
- data/logo.png +0 -0
- data/minitest.rb +0 -30
- data/yard/yard-convenient_service_concern.rb +0 -45
- /data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/{entities/matcher/commands.rb → commands.rb} +0 -0
- /data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/{matcher/entities/chainings/sub_matchers → sub_matchers}/arguments/commands.rb +0 -0
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "date_time/services"
|
4
|
-
|
5
|
-
##
|
6
|
-
# @internal
|
7
|
-
# Usage examples:
|
8
|
-
#
|
9
|
-
# result = ConvenientService::Examples::Standard::V1::DateTime.safe_parse("24-02-2024", "%d-%m-%Y")
|
10
|
-
#
|
11
|
-
module ConvenientService
|
12
|
-
module Examples
|
13
|
-
module Standard
|
14
|
-
module V1
|
15
|
-
class DateTime
|
16
|
-
include ConvenientService::Feature::Standard::Config
|
17
|
-
|
18
|
-
entry :safe_parse do |string, format|
|
19
|
-
Services::SafeParse[string: string, format: format]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ConvenientService
|
4
|
-
module Examples
|
5
|
-
module Standard
|
6
|
-
module V1
|
7
|
-
class Factorial
|
8
|
-
module Services
|
9
|
-
class Calculate
|
10
|
-
include ConvenientService::Standard::V1::Config
|
11
|
-
|
12
|
-
attr_reader :number, :timeout_seconds
|
13
|
-
|
14
|
-
def initialize(number:, timeout_seconds: 10)
|
15
|
-
@number = number
|
16
|
-
@timeout_seconds = timeout_seconds
|
17
|
-
end
|
18
|
-
|
19
|
-
def result
|
20
|
-
return failure(number: "is `nil`") if number.nil?
|
21
|
-
return failure(number: "is NOT an integer") unless number.instance_of?(::Integer)
|
22
|
-
return failure(number: "is lower than `0`") if number < 0
|
23
|
-
|
24
|
-
return error("Timeout (`#{timeout_seconds}` seconds) is exceeded for `#{number}`") if factorial.timeout?
|
25
|
-
|
26
|
-
success(factorial: factorial.value)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def factorial
|
32
|
-
@factorial ||= Utils::Timeout.with_timeout(timeout_seconds) { calculate_factorial }
|
33
|
-
end
|
34
|
-
|
35
|
-
##
|
36
|
-
# @internal
|
37
|
-
# NOTE: What is a Factorial?
|
38
|
-
# - https://en.wikipedia.org/wiki/Factorial
|
39
|
-
#
|
40
|
-
def calculate_factorial
|
41
|
-
return 1 if [0, 1].include?(number)
|
42
|
-
|
43
|
-
1.upto(number).reduce(1) { |prev_value, next_value| prev_value * next_value }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ConvenientService
|
4
|
-
module Examples
|
5
|
-
module Standard
|
6
|
-
module V1
|
7
|
-
class Factorial
|
8
|
-
module Utils
|
9
|
-
module Timeout
|
10
|
-
class WithTimeout < ConvenientService::Command
|
11
|
-
ReturnStruct = ::Struct.new(:timeout?, :value, keyword_init: true)
|
12
|
-
|
13
|
-
attr_reader :seconds, :block
|
14
|
-
|
15
|
-
def initialize(seconds, &block)
|
16
|
-
@seconds = seconds
|
17
|
-
@block = block
|
18
|
-
end
|
19
|
-
|
20
|
-
##
|
21
|
-
# @internal
|
22
|
-
# NOTE: Prefer to avoid `Timeout.timeout` if you are NOT absolutely 100% sure what you are doing. See the following articles for details.
|
23
|
-
# - https://github.com/ruby/timeout/blob/master/lib/timeout.rb
|
24
|
-
# - https://adamhooper.medium.com/in-ruby-dont-use-timeout-77d9d4e5a001
|
25
|
-
# - https://flushentitypacket.github.io/ruby/2015/02/21/ruby-timeout-how-does-it-even-work.html
|
26
|
-
# - https://www.exceptionalcreatures.com/bestiary/Timeout/Error
|
27
|
-
# - https://github.com/ankane/the-ultimate-guide-to-ruby-timeouts#regexp
|
28
|
-
#
|
29
|
-
def call
|
30
|
-
return struct(timeout?: false, value: block.call) if seconds.nil?
|
31
|
-
return struct(timeout?: true, value: nil) if seconds.zero?
|
32
|
-
|
33
|
-
begin
|
34
|
-
struct(timeout?: false, value: ::Timeout.timeout(seconds, &block))
|
35
|
-
rescue ::Timeout::Error
|
36
|
-
struct(timeout?: true, value: nil)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def struct(**kwargs)
|
43
|
-
ReturnStruct.new(**kwargs)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "timeout/with_timeout"
|
4
|
-
|
5
|
-
module ConvenientService
|
6
|
-
module Examples
|
7
|
-
module Standard
|
8
|
-
module V1
|
9
|
-
class Factorial
|
10
|
-
module Utils
|
11
|
-
module Timeout
|
12
|
-
class << self
|
13
|
-
def with_timeout(...)
|
14
|
-
WithTimeout.call(...)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "factorial/services"
|
4
|
-
require_relative "factorial/utils"
|
5
|
-
|
6
|
-
##
|
7
|
-
# @internal
|
8
|
-
# Usage examples:
|
9
|
-
#
|
10
|
-
# result = ConvenientService::Examples::Standard::V1::Factorial.calculate(10)
|
11
|
-
#
|
12
|
-
module ConvenientService
|
13
|
-
module Examples
|
14
|
-
module Standard
|
15
|
-
module V1
|
16
|
-
class Factorial
|
17
|
-
include ConvenientService::Feature::Standard::Config
|
18
|
-
|
19
|
-
entry :calculate do |number|
|
20
|
-
Services::Calculate[number: number]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ConvenientService
|
4
|
-
module Examples
|
5
|
-
module Standard
|
6
|
-
module V1
|
7
|
-
class Gemfile
|
8
|
-
module Services
|
9
|
-
class AssertFileExists
|
10
|
-
include ConvenientService::Standard::V1::Config
|
11
|
-
|
12
|
-
attr_reader :path
|
13
|
-
|
14
|
-
def initialize(path:)
|
15
|
-
@path = path
|
16
|
-
end
|
17
|
-
|
18
|
-
def result
|
19
|
-
return failure(path: "Path is `nil`") if path.nil?
|
20
|
-
return failure(path: "Path is empty") if path.empty?
|
21
|
-
|
22
|
-
return error("File with path `#{path}` does NOT exist") unless ::File.exist?(path)
|
23
|
-
|
24
|
-
success
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ConvenientService
|
4
|
-
module Examples
|
5
|
-
module Standard
|
6
|
-
module V1
|
7
|
-
class Gemfile
|
8
|
-
module Services
|
9
|
-
class AssertFileNotEmpty
|
10
|
-
include ConvenientService::Standard::V1::Config
|
11
|
-
|
12
|
-
attr_reader :path
|
13
|
-
|
14
|
-
def initialize(path:)
|
15
|
-
@path = path
|
16
|
-
end
|
17
|
-
|
18
|
-
def result
|
19
|
-
return failure(data: {path: "Path is `nil`"}) if path.nil?
|
20
|
-
return failure(data: {path: "Path is empty"}) if path.empty?
|
21
|
-
|
22
|
-
return error(message: "File with path `#{path}` is empty") if ::File.zero?(path)
|
23
|
-
|
24
|
-
success
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
##
|
4
|
-
# Usage example:
|
5
|
-
#
|
6
|
-
# ConvenientService::Examples::Standard::V1::Gemfile::Services::AssertNodeAvailable.result
|
7
|
-
#
|
8
|
-
module ConvenientService
|
9
|
-
module Examples
|
10
|
-
module Standard
|
11
|
-
module V1
|
12
|
-
class Gemfile
|
13
|
-
module Services
|
14
|
-
class AssertNodeAvailable
|
15
|
-
include ConvenientService::Standard::V1::Config
|
16
|
-
|
17
|
-
##
|
18
|
-
# NOTE: `> /dev/null 2>&1` is used to hide output.
|
19
|
-
# https://unix.stackexchange.com/a/119650/394253
|
20
|
-
#
|
21
|
-
step Services::RunShellCommand, in: {command: -> { "which node > /dev/null 2>&1" }}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_npm_package_available.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
##
|
4
|
-
# Usage example:
|
5
|
-
#
|
6
|
-
# ConvenientService::Examples::Standard::V1::Gemfile::Services::AssertNpmPackageAvailable.result(name: "lodash")
|
7
|
-
#
|
8
|
-
module ConvenientService
|
9
|
-
module Examples
|
10
|
-
module Standard
|
11
|
-
module V1
|
12
|
-
class Gemfile
|
13
|
-
module Services
|
14
|
-
class AssertNpmPackageAvailable
|
15
|
-
include ConvenientService::Standard::V1::Config
|
16
|
-
|
17
|
-
attr_reader :name
|
18
|
-
|
19
|
-
step :validate_name
|
20
|
-
|
21
|
-
step Services::AssertNodeAvailable
|
22
|
-
|
23
|
-
##
|
24
|
-
# NOTE: `> /dev/null 2>&1` is used to hide output.
|
25
|
-
# https://unix.stackexchange.com/a/119650/394253
|
26
|
-
#
|
27
|
-
# NOTE: For `npm list` and its options docs, see
|
28
|
-
# https://docs.npmjs.com/cli/v7/commands/npm-ls
|
29
|
-
#
|
30
|
-
step Services::RunShellCommand, in: {command: -> { "npm list #{name} --depth=0 > /dev/null 2>&1" }}
|
31
|
-
|
32
|
-
def initialize(name:)
|
33
|
-
@name = name
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def validate_name
|
39
|
-
return failure(name: "Name is `nil`") if name.nil?
|
40
|
-
return failure(name: "Name is empty") if name.empty?
|
41
|
-
|
42
|
-
success
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_valid_ruby_syntax.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ConvenientService
|
4
|
-
module Examples
|
5
|
-
module Standard
|
6
|
-
module V1
|
7
|
-
class Gemfile
|
8
|
-
module Services
|
9
|
-
class AssertValidRubySyntax
|
10
|
-
include ConvenientService::Standard::V1::Config
|
11
|
-
|
12
|
-
attr_reader :content
|
13
|
-
|
14
|
-
def initialize(content:)
|
15
|
-
@content = content
|
16
|
-
end
|
17
|
-
|
18
|
-
def result
|
19
|
-
##
|
20
|
-
# NOTE: `> /dev/null 2>&1` is used to hide output.
|
21
|
-
# https://unix.stackexchange.com/a/119650/394253
|
22
|
-
#
|
23
|
-
check_ruby_syntax_result = Services::RunShellCommand.result(command: "ruby -c #{file.path} > /dev/null 2>&1")
|
24
|
-
|
25
|
-
return error("`#{content}` contains invalid Ruby syntax") unless check_ruby_syntax_result.success?
|
26
|
-
|
27
|
-
success
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def file
|
33
|
-
@file ||= ::Tempfile.new.tap { |tempfile| tempfile.write(content) }.tap(&:close)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
##
|
4
|
-
# Usage example:
|
5
|
-
#
|
6
|
-
# result = ConvenientService::Examples::Standard::V1::Gemfile::Services::Format.result(path: "Gemfile")
|
7
|
-
# result = ConvenientService::Examples::Standard::V1::Gemfile::Services::Format.result(path: "spec/cli/gemfile/format/fixtures/Gemfile")
|
8
|
-
#
|
9
|
-
module ConvenientService
|
10
|
-
module Examples
|
11
|
-
module Standard
|
12
|
-
module V1
|
13
|
-
class Gemfile
|
14
|
-
module Services
|
15
|
-
class Format
|
16
|
-
include ConvenientService::Standard::V1::Config
|
17
|
-
|
18
|
-
attr_reader :path
|
19
|
-
|
20
|
-
step :validate_path,
|
21
|
-
in: :path
|
22
|
-
|
23
|
-
step Services::ReadFileContent,
|
24
|
-
in: :path,
|
25
|
-
out: :content
|
26
|
-
|
27
|
-
step Services::StripComments,
|
28
|
-
in: :content,
|
29
|
-
out: :content_without_comments
|
30
|
-
|
31
|
-
step Services::ParseContent,
|
32
|
-
in: {content: :content_without_comments},
|
33
|
-
out: :parsed_content
|
34
|
-
|
35
|
-
step Services::FormatHeader,
|
36
|
-
in: :parsed_content,
|
37
|
-
out: {formatted_content: :formatted_header_content}
|
38
|
-
|
39
|
-
step Services::FormatBody,
|
40
|
-
in: :parsed_content,
|
41
|
-
out: {formatted_content: :formatted_body_content}
|
42
|
-
|
43
|
-
step Services::MergeSections,
|
44
|
-
in: [
|
45
|
-
{header: :formatted_header_content},
|
46
|
-
{body: :formatted_body_content}
|
47
|
-
],
|
48
|
-
out: :merged_sections
|
49
|
-
|
50
|
-
step Services::ReplaceFileContent,
|
51
|
-
in: [
|
52
|
-
:path,
|
53
|
-
{content: :merged_sections}
|
54
|
-
]
|
55
|
-
|
56
|
-
before :result do
|
57
|
-
@progressbar = ::ProgressBar.create(title: "Formatting", total: steps.count)
|
58
|
-
end
|
59
|
-
|
60
|
-
after :step do |step|
|
61
|
-
@progressbar.increment
|
62
|
-
end
|
63
|
-
|
64
|
-
def initialize(path:)
|
65
|
-
@path = path
|
66
|
-
end
|
67
|
-
|
68
|
-
private
|
69
|
-
|
70
|
-
def validate_path
|
71
|
-
return failure(path: "Path is `nil`") if path.nil?
|
72
|
-
return failure(path: "Path is empty") if path.empty?
|
73
|
-
|
74
|
-
success
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
##
|
4
|
-
# Usage example:
|
5
|
-
#
|
6
|
-
# result = ConvenientService::Examples::Standard::V1::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 Standard
|
46
|
-
module V1
|
47
|
-
class Gemfile
|
48
|
-
module Services
|
49
|
-
class FormatBody
|
50
|
-
include ConvenientService::Standard::V1::Config
|
51
|
-
|
52
|
-
attr_reader :parsed_content
|
53
|
-
|
54
|
-
step Services::FormatGemsWithoutEnvs,
|
55
|
-
in: :parsed_content,
|
56
|
-
out: [{formatted_content: :formatted_gems_without_envs_content}]
|
57
|
-
|
58
|
-
step Services::FormatGemsWithEnvs,
|
59
|
-
in: :parsed_content,
|
60
|
-
out: [{formatted_content: :formatted_gems_with_envs_content}]
|
61
|
-
|
62
|
-
step :result,
|
63
|
-
in: [:formatted_gems_without_envs_content, :formatted_gems_with_envs_content],
|
64
|
-
out: :formatted_content
|
65
|
-
|
66
|
-
def initialize(parsed_content:)
|
67
|
-
@parsed_content = parsed_content
|
68
|
-
end
|
69
|
-
|
70
|
-
def result
|
71
|
-
success(formatted_content: format_content)
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
def format_content
|
77
|
-
[formatted_gems_without_envs_content, formatted_gems_with_envs_content].reject(&:empty?).join("\n")
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
##
|
4
|
-
# Usage example:
|
5
|
-
#
|
6
|
-
# result = ConvenientService::Examples::Standard::V1::Gemfile::Services::FormatGemsWithEnvs.result(
|
7
|
-
# parsed_content: {
|
8
|
-
# gems: [
|
9
|
-
# {
|
10
|
-
# envs: [:development],
|
11
|
-
# line: %(gem "listen", "~> 3.3")
|
12
|
-
# },
|
13
|
-
# {
|
14
|
-
# envs: [:development],
|
15
|
-
# line: %(gem "web-console", ">= 4.1.0")
|
16
|
-
# },
|
17
|
-
# {
|
18
|
-
# envs: [:development, :test],
|
19
|
-
# line: %(gem "rspec-rails")
|
20
|
-
# },
|
21
|
-
# {
|
22
|
-
# envs: [:test],
|
23
|
-
# line: %(gem "simplecov", require: false)
|
24
|
-
# }
|
25
|
-
# ]
|
26
|
-
# }
|
27
|
-
# )
|
28
|
-
#
|
29
|
-
# NOTE: Check the corresponding spec file to see more examples.
|
30
|
-
#
|
31
|
-
module ConvenientService
|
32
|
-
module Examples
|
33
|
-
module Standard
|
34
|
-
module V1
|
35
|
-
class Gemfile
|
36
|
-
module Services
|
37
|
-
class FormatGemsWithEnvs
|
38
|
-
BLOCK_END = "end"
|
39
|
-
BLOCK_DO = "do"
|
40
|
-
COMMA_WITH_SPACE = ", "
|
41
|
-
EMPTY_LINE = ""
|
42
|
-
ENTER = "\n"
|
43
|
-
GROUP = "group"
|
44
|
-
SPACE = " "
|
45
|
-
TAB = " "
|
46
|
-
|
47
|
-
include ConvenientService::Standard::V1::Config
|
48
|
-
|
49
|
-
attr_reader :parsed_content
|
50
|
-
|
51
|
-
def initialize(parsed_content:)
|
52
|
-
@parsed_content = parsed_content
|
53
|
-
end
|
54
|
-
|
55
|
-
def result
|
56
|
-
success(formatted_content: format_content)
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def format_content
|
62
|
-
return "" if gems_with_envs.none?
|
63
|
-
|
64
|
-
gems_with_envs
|
65
|
-
.group_by { |gem| gem[:envs] }
|
66
|
-
.sort
|
67
|
-
.map { |envs, gems|
|
68
|
-
content = EMPTY_LINE.dup
|
69
|
-
|
70
|
-
content << GROUP << SPACE << envs.map { |env| ":#{env}" }.join(COMMA_WITH_SPACE) << SPACE << BLOCK_DO << ENTER
|
71
|
-
|
72
|
-
content << gems.map { |gem| "#{TAB}#{gem[:line]}#{ENTER}" }.join
|
73
|
-
|
74
|
-
content << BLOCK_END << ENTER
|
75
|
-
}
|
76
|
-
.join(ENTER)
|
77
|
-
end
|
78
|
-
|
79
|
-
def gems_with_envs
|
80
|
-
@gems_with_envs ||= parsed_content[:gems].to_a.select { |gem| gem[:envs].any? }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|