convenient_service 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/convenient_service/dependencies/queries/version.rb +18 -0
  3. data/lib/convenient_service/dependencies/queries.rb +4 -2
  4. data/lib/convenient_service/extras/rspec.rb +1 -1
  5. data/lib/convenient_service/logger.rb +6 -3
  6. data/lib/convenient_service/rspec/matchers/classes/results/base/entities/printers/error/commands/generate_got_jsend_attributes_part.rb +1 -1
  7. data/lib/convenient_service/rspec/matchers/classes/results/base/entities/printers/failure/commands/generate_got_jsend_attributes_part.rb +1 -1
  8. data/lib/convenient_service/rspec/matchers/classes/results/base/entities/printers/success/commands/generate_got_jsend_attributes_part.rb +1 -1
  9. data/lib/convenient_service/rspec/matchers/classes/results/be_error.rb +1 -1
  10. data/lib/convenient_service/rspec/matchers/classes/results/be_failure.rb +1 -1
  11. data/lib/convenient_service/rspec/matchers/classes/results/be_not_error.rb +2 -2
  12. data/lib/convenient_service/rspec/matchers/classes/results/be_not_failure.rb +2 -2
  13. data/lib/convenient_service/rspec/matchers/classes/results/be_not_success.rb +2 -2
  14. data/lib/convenient_service/rspec/matchers/classes/results/be_success.rb +1 -1
  15. data/lib/convenient_service/service/configs/standard.rb +11 -3
  16. data/lib/convenient_service/service/plugins/can_have_after_step_callbacks/middleware.rb +5 -1
  17. data/lib/convenient_service/service/plugins/can_have_around_step_callbacks/middleware.rb +1 -1
  18. data/lib/convenient_service/service/plugins/can_have_before_step_callbacks/middleware.rb +1 -1
  19. data/lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb +1 -6
  20. data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/scalar.rb +1 -1
  21. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_backtrace.rb +1 -1
  22. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_cause.rb +1 -1
  23. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_class.rb +1 -1
  24. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_exception.rb +2 -2
  25. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_line.rb +1 -1
  26. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_message.rb +1 -1
  27. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/constants.rb +1 -1
  28. data/lib/convenient_service/service/plugins/can_have_formatted_exceptions.rb +35 -0
  29. data/lib/convenient_service/service/plugins/can_have_handled_exceptions/concern.rb +34 -0
  30. data/lib/convenient_service/service/plugins/can_have_handled_exceptions.rb +8 -0
  31. data/lib/convenient_service/service/plugins/can_have_inline_services/concern.rb +29 -0
  32. data/lib/convenient_service/service/plugins/can_have_inline_services/entities/proxy.rb +205 -0
  33. data/lib/convenient_service/service/plugins/{can_have_steps/entities/step/plugins/can_be_completed.rb → can_have_inline_services/entities.rb} +1 -1
  34. data/lib/convenient_service/service/plugins/can_have_inline_services/exceptions.rb +30 -0
  35. data/lib/convenient_service/service/plugins/can_have_inline_services.rb +36 -0
  36. data/lib/convenient_service/service/plugins/can_have_sequential_steps/concern.rb +2 -0
  37. data/lib/convenient_service/service/plugins/can_have_sequential_steps/middleware.rb +1 -5
  38. data/lib/convenient_service/service/plugins/can_have_steps/concern.rb +1 -6
  39. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_factory.rb +5 -8
  40. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/proc.rb +1 -1
  41. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/raw.rb +1 -1
  42. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/factories/string.rb +1 -1
  43. data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/key.rb +1 -1
  44. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/concern/instance_methods.rb +13 -0
  45. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/{can_be_completed → can_be_evaluated}/concern.rb +1 -1
  46. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_evaluated.rb +8 -0
  47. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +1 -1
  48. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_exception/concern.rb +4 -4
  49. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception/concern.rb +81 -0
  50. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception/exceptions.rb +38 -0
  51. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception.rb +9 -0
  52. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception/concern.rb +46 -0
  53. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception.rb +8 -0
  54. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins.rb +2 -0
  55. data/lib/convenient_service/service/plugins/has_j_send_result.rb +84 -0
  56. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb +3 -3
  57. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions.rb +0 -2
  58. data/lib/convenient_service/service/plugins.rb +3 -0
  59. data/lib/convenient_service/version.rb +1 -1
  60. data/lib/convenient_service.rb +23 -1
  61. metadata +24 -11
  62. /data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands.rb +0 -0
@@ -14,6 +14,90 @@ module ConvenientService
14
14
  module Plugins
15
15
  module HasJSendResult
16
16
  class << self
17
+ ##
18
+ # @return [Symbol]
19
+ #
20
+ def success_status
21
+ Constants::SUCCESS_STATUS
22
+ end
23
+
24
+ ##
25
+ # @return [Symbol]
26
+ #
27
+ def failure_status
28
+ Constants::FAILURE_STATUS
29
+ end
30
+
31
+ ##
32
+ # @return [Symbol]
33
+ #
34
+ def error_status
35
+ Constants::ERROR_STATUS
36
+ end
37
+
38
+ ##
39
+ # @return [Hash{Symbol => Object}]
40
+ #
41
+ def default_success_data
42
+ Constants::DEFAULT_SUCCESS_DATA
43
+ end
44
+
45
+ ##
46
+ # @return [Hash{Symbol => Object}]
47
+ #
48
+ def default_failure_data
49
+ Constants::DEFAULT_FAILURE_DATA
50
+ end
51
+
52
+ ##
53
+ # @return [Hash{Symbol => Object}]
54
+ #
55
+ def default_error_data
56
+ Constants::DEFAULT_ERROR_DATA
57
+ end
58
+
59
+ ##
60
+ # @return [String]
61
+ #
62
+ def default_success_message
63
+ Constants::DEFAULT_SUCCESS_MESSAGE
64
+ end
65
+
66
+ ##
67
+ # @return [String]
68
+ #
69
+ def default_failure_message
70
+ Constants::DEFAULT_FAILURE_MESSAGE
71
+ end
72
+
73
+ ##
74
+ # @return [String]
75
+ #
76
+ def default_error_message
77
+ Constants::DEFAULT_ERROR_MESSAGE
78
+ end
79
+
80
+ ##
81
+ # @return [Symbol]
82
+ #
83
+ def default_success_code
84
+ Constants::DEFAULT_SUCCESS_CODE
85
+ end
86
+
87
+ ##
88
+ # @return [Symbol]
89
+ #
90
+ def default_failure_code
91
+ Constants::DEFAULT_FAILURE_CODE
92
+ end
93
+
94
+ ##
95
+ # @return [Symbol]
96
+ #
97
+ def default_error_code
98
+ Constants::DEFAULT_ERROR_CODE
99
+ end
100
+
17
101
  ##
18
102
  # Checks whether an object is a result class.
19
103
  #
@@ -81,7 +81,7 @@ module ConvenientService
81
81
  message: format_exception(exception, *args, **kwargs, &block),
82
82
  code: :unhandled_exception
83
83
  )
84
- .copy(overrides: {kwargs: {unhandled_exception: exception}})
84
+ .copy(overrides: {kwargs: {exceptions: {unhandled: exception}}})
85
85
  end
86
86
 
87
87
  ##
@@ -92,14 +92,14 @@ module ConvenientService
92
92
  # @return [String]
93
93
  #
94
94
  def format_exception(exception, *args, **kwargs, &block)
95
- Commands::FormatException.call(exception: exception, args: args, kwargs: kwargs, block: block, max_backtrace_size: max_backtrace_size)
95
+ Plugins::CanHaveFormattedExceptions.format_exception(exception, args: args, kwargs: kwargs, block: block, max_backtrace_size: max_backtrace_size)
96
96
  end
97
97
 
98
98
  ##
99
99
  # @return [Integer]
100
100
  #
101
101
  def max_backtrace_size
102
- middleware_arguments.kwargs.fetch(:max_backtrace_size) { Constants::DEFAULT_MAX_BACKTRACE_SIZE }
102
+ middleware_arguments.kwargs.fetch(:max_backtrace_size) { Plugins::CanHaveFormattedExceptions.default_max_backtrace_size }
103
103
  end
104
104
 
105
105
  ##
@@ -5,6 +5,4 @@
5
5
  # @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
6
6
  ##
7
7
 
8
- require_relative "rescues_result_unhandled_exceptions/commands"
9
- require_relative "rescues_result_unhandled_exceptions/constants"
10
8
  require_relative "rescues_result_unhandled_exceptions/middleware"
@@ -27,9 +27,12 @@ require_relative "plugins/can_have_around_step_callbacks"
27
27
  require_relative "plugins/can_have_before_step_callbacks"
28
28
  require_relative "plugins/can_have_fallbacks"
29
29
  require_relative "plugins/can_have_rollbacks"
30
+ require_relative "plugins/can_have_inline_services"
30
31
  require_relative "plugins/can_have_stubbed_results"
31
32
  require_relative "plugins/can_not_be_inherited"
32
33
  require_relative "plugins/can_have_recalculations"
34
+ require_relative "plugins/can_have_handled_exceptions"
35
+ require_relative "plugins/can_have_formatted_exceptions"
33
36
  require_relative "plugins/collects_services_in_exception"
34
37
  require_relative "plugins/forbids_convenient_service_entities_as_constructor_arguments"
35
38
  require_relative "plugins/has_inspect"
@@ -13,5 +13,5 @@ module ConvenientService
13
13
  # @since 1.0.0
14
14
  # @return [String]
15
15
  #
16
- VERSION = "0.23.0"
16
+ VERSION = "0.25.0"
17
17
  end
@@ -209,10 +209,12 @@ module ConvenientService
209
209
  ##
210
210
  # Returns `true` when Convenient Service is in debug mode. In other words `$CONVENIENT_SERVICE_DEBUG` env variable is set to `true`.
211
211
  #
212
- # @api private
212
+ # @api public
213
213
  # @since 1.0.0
214
214
  # @return [Boolean]
215
215
  #
216
+ # @see https://userdocs.convenientservice.org/comprehensive_docs/docs/the_how/how_to_debug_the_convenient_service_lib_itself.html
217
+ #
216
218
  def debug?
217
219
  Dependencies.debug?
218
220
  end
@@ -249,6 +251,9 @@ module ConvenientService
249
251
  #
250
252
  # @see https://github.com/ruby/logger
251
253
  # @see https://ruby-doc.org/stdlib-2.7.0/libdoc/logger/rdoc/Logger.html
254
+ # @see https://userdocs.convenientservice.org/comprehensive_docs/docs/the_how/how_to_debug_the_convenient_service_lib_itself.html
255
+ # @see https://userdocs.convenientservice.org/comprehensive_docs/docs/the_what/what_is_convenient_service_logger.html
256
+ # @see https://userdocs.convenientservice.org/comprehensive_docs/docs/the_how/how_to_configure_convenient_service_logger.html
252
257
  #
253
258
  # @example Set log level.
254
259
  # ConvenientService.logger.level = Logger::DEBUG
@@ -267,6 +272,7 @@ module ConvenientService
267
272
  #
268
273
  # @see https://ruby-doc.org/core-2.7.1/Kernel.html#method-i-__dir__
269
274
  # @see https://api.rubyonrails.org/classes/Rails.html#method-c-root
275
+ # @see https://userdocs.convenientservice.org/comprehensive_docs/docs/the_how/how_to_get_convenient_service_root_folder.html
270
276
  #
271
277
  def root
272
278
  @root ||= ::Pathname.new(::File.expand_path(::File.join(__dir__, "..")))
@@ -280,6 +286,9 @@ module ConvenientService
280
286
  # @since 1.0.0
281
287
  # @return [Pathname]
282
288
  #
289
+ # @internal
290
+ # TODO: Consider to make public for plugin devs.
291
+ #
283
292
  def lib_root
284
293
  @lib_root ||= ::Pathname.new(::File.join(root, "lib"))
285
294
  end
@@ -292,6 +301,9 @@ module ConvenientService
292
301
  # @since 1.0.0
293
302
  # @return [Pathname]
294
303
  #
304
+ # @internal
305
+ # TODO: Consider to make public for plugin devs.
306
+ #
295
307
  def examples_root
296
308
  @examples_root ||= ::Pathname.new(::File.join(root, "lib", "convenient_service", "examples"))
297
309
  end
@@ -343,6 +355,16 @@ module ConvenientService
343
355
  @backtrace_cleaner ||= Support::BacktraceCleaner.new
344
356
  end
345
357
 
358
+ ##
359
+ # @api public
360
+ # @since 1.0.0
361
+ # @param block [Proc, nil]
362
+ # @return [ConvenientService::Service::Plugins::CanHaveInlineServices::Entities::Proxy]
363
+ #
364
+ def inline(&block)
365
+ Service::Plugins::CanHaveInlineServices.proxy(&block)
366
+ end
367
+
346
368
  ##
347
369
  # Raises Convenient Service exceptions.
348
370
  # Cleans exception backtrace with `ConvenientService.backtrace_cleaner.clean` before delegating to `Kernel.raise`.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convenient_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marian Kostyk
@@ -425,6 +425,22 @@ files:
425
425
  - lib/convenient_service/service/plugins/can_have_fallbacks/concern.rb
426
426
  - lib/convenient_service/service/plugins/can_have_fallbacks/exceptions.rb
427
427
  - lib/convenient_service/service/plugins/can_have_fallbacks/middleware.rb
428
+ - lib/convenient_service/service/plugins/can_have_formatted_exceptions.rb
429
+ - lib/convenient_service/service/plugins/can_have_formatted_exceptions/commands.rb
430
+ - lib/convenient_service/service/plugins/can_have_formatted_exceptions/commands/format_backtrace.rb
431
+ - lib/convenient_service/service/plugins/can_have_formatted_exceptions/commands/format_cause.rb
432
+ - lib/convenient_service/service/plugins/can_have_formatted_exceptions/commands/format_class.rb
433
+ - lib/convenient_service/service/plugins/can_have_formatted_exceptions/commands/format_exception.rb
434
+ - lib/convenient_service/service/plugins/can_have_formatted_exceptions/commands/format_line.rb
435
+ - lib/convenient_service/service/plugins/can_have_formatted_exceptions/commands/format_message.rb
436
+ - lib/convenient_service/service/plugins/can_have_formatted_exceptions/constants.rb
437
+ - lib/convenient_service/service/plugins/can_have_handled_exceptions.rb
438
+ - lib/convenient_service/service/plugins/can_have_handled_exceptions/concern.rb
439
+ - lib/convenient_service/service/plugins/can_have_inline_services.rb
440
+ - lib/convenient_service/service/plugins/can_have_inline_services/concern.rb
441
+ - lib/convenient_service/service/plugins/can_have_inline_services/entities.rb
442
+ - lib/convenient_service/service/plugins/can_have_inline_services/entities/proxy.rb
443
+ - lib/convenient_service/service/plugins/can_have_inline_services/exceptions.rb
428
444
  - lib/convenient_service/service/plugins/can_have_recalculations.rb
429
445
  - lib/convenient_service/service/plugins/can_have_recalculations/concern.rb
430
446
  - lib/convenient_service/service/plugins/can_have_rollbacks.rb
@@ -507,8 +523,8 @@ files:
507
523
  - lib/convenient_service/service/plugins/can_have_steps/entities/step/exceptions.rb
508
524
  - lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb
509
525
  - lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/aliases.rb
510
- - lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_completed.rb
511
- - lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_completed/concern.rb
526
+ - lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_evaluated.rb
527
+ - lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_evaluated/concern.rb
512
528
  - lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step.rb
513
529
  - lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/commands.rb
514
530
  - lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/commands/calculate_method_result.rb
@@ -594,6 +610,11 @@ files:
594
610
  - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_exception/concern.rb
595
611
  - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_fallback.rb
596
612
  - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_fallback/concern.rb
613
+ - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception.rb
614
+ - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception/concern.rb
615
+ - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception/exceptions.rb
616
+ - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception.rb
617
+ - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception/concern.rb
597
618
  - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_own_result.rb
598
619
  - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_own_result/concern.rb
599
620
  - lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_strict.rb
@@ -731,14 +752,6 @@ files:
731
752
  - lib/convenient_service/service/plugins/raises_on_not_result_return_value/exceptions.rb
732
753
  - lib/convenient_service/service/plugins/raises_on_not_result_return_value/middleware.rb
733
754
  - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions.rb
734
- - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands.rb
735
- - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_backtrace.rb
736
- - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_cause.rb
737
- - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_class.rb
738
- - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_exception.rb
739
- - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_line.rb
740
- - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb
741
- - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/constants.rb
742
755
  - lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb
743
756
  - lib/convenient_service/service/plugins/sets_parent_to_foreign_result.rb
744
757
  - lib/convenient_service/service/plugins/sets_parent_to_foreign_result/middleware.rb