convenient_service 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gem_release.yml +0 -12
  3. data/.github/issue_template.md +35 -0
  4. data/.github/pull_request_template.md +31 -0
  5. data/.github/workflows/cd.yml +15 -2
  6. data/.github/workflows/ci.yml +6 -6
  7. data/CHANGELOG.md +27 -0
  8. data/README.md +12 -3
  9. data/ROADMAP.md +22 -8
  10. data/Taskfile.yml +5 -13
  11. data/env.rb +4 -0
  12. data/lib/convenient_service/common/plugins/caches_return_value/middleware.rb +17 -2
  13. data/lib/convenient_service/common/plugins/caches_return_value.rb +0 -1
  14. data/lib/convenient_service/common/plugins/has_constructor/concern.rb +13 -0
  15. data/lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb +27 -0
  16. data/lib/convenient_service/common/plugins/has_constructor_without_initialize.rb +3 -0
  17. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/concern.rb +8 -4
  18. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache.rb +0 -1
  19. data/lib/convenient_service/common/plugins.rb +1 -0
  20. data/lib/convenient_service/configs/standard.rb +16 -0
  21. data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/commands/cast_container.rb +0 -2
  22. data/lib/convenient_service/dependencies.rb +1 -0
  23. data/lib/convenient_service/examples/dry/gemfile/dry_service/config.rb +3 -1
  24. data/lib/convenient_service/examples/dry/gemfile/services/assert_file_exists.rb +1 -1
  25. data/lib/convenient_service/examples/dry/gemfile/services/assert_file_not_empty.rb +1 -1
  26. data/lib/convenient_service/examples/dry/gemfile/services/assert_npm_package_available.rb +1 -1
  27. data/lib/convenient_service/examples/dry/gemfile/services/parse_content.rb +1 -1
  28. data/lib/convenient_service/examples/dry/gemfile/services/print_shell_command.rb +1 -1
  29. data/lib/convenient_service/examples/dry/gemfile/services/read_file_content.rb +1 -1
  30. data/lib/convenient_service/examples/dry/gemfile/services/run_shell.rb +1 -1
  31. data/lib/convenient_service/examples/dry/gemfile/services/strip_comments.rb +1 -1
  32. data/lib/convenient_service/examples/dry/gemfile.rb +5 -4
  33. data/lib/convenient_service/examples/rails/gemfile/rails_service/config.rb +3 -1
  34. data/lib/convenient_service/examples/rails/gemfile.rb +5 -4
  35. data/lib/convenient_service/examples/standard/cowsay/services/build_cloud.rb +42 -0
  36. data/lib/convenient_service/examples/standard/cowsay/services/build_cow.rb +38 -0
  37. data/lib/convenient_service/examples/standard/cowsay/services/print.rb +32 -0
  38. data/lib/convenient_service/examples/standard/cowsay/services.rb +5 -0
  39. data/lib/convenient_service/examples/standard/cowsay.rb +24 -0
  40. data/lib/convenient_service/examples/standard/gemfile/services/format.rb +2 -0
  41. data/lib/convenient_service/examples/standard/gemfile.rb +5 -4
  42. data/lib/convenient_service/rspec/helpers/custom/stub_service/entities/result_spec.rb +96 -7
  43. data/lib/convenient_service/rspec/helpers/custom/wrap_method/entities/wrapped_method.rb +44 -8
  44. data/lib/convenient_service/rspec/helpers/custom/wrap_method/errors.rb +11 -9
  45. data/lib/convenient_service/rspec/matchers/custom/cache_its_value.rb +7 -7
  46. data/lib/convenient_service/rspec/matchers/custom/call_chain_next.rb +2 -0
  47. data/lib/convenient_service/rspec/matchers/custom/delegate_to.rb +50 -12
  48. data/lib/convenient_service/rspec/matchers/custom/results/be_success.rb +6 -0
  49. data/lib/convenient_service/service/plugins/aliases.rb +1 -0
  50. data/lib/convenient_service/service/plugins/has_inspect/concern.rb +23 -0
  51. data/lib/convenient_service/service/plugins/has_inspect.rb +3 -0
  52. data/lib/convenient_service/service/plugins/has_result/commands/create_result_class.rb +10 -0
  53. data/lib/convenient_service/service/plugins/has_result/concern/class_methods.rb +23 -14
  54. data/lib/convenient_service/service/plugins/has_result/concern/instance_methods.rb +17 -1
  55. data/lib/convenient_service/service/plugins/has_result/entities/result/concern.rb +4 -3
  56. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_inspect/concern.rb +31 -0
  57. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_inspect.rb +3 -0
  58. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands/cast_jsend_attributes.rb +37 -0
  59. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands.rb +3 -0
  60. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/concern/instance_methods.rb +127 -0
  61. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/concern.rb +27 -0
  62. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/code/class_methods.rb +34 -0
  63. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/code.rb +49 -0
  64. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data/class_methods.rb +32 -0
  65. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data.rb +49 -0
  66. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message/class_methods.rb +34 -0
  67. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message.rb +45 -0
  68. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status/class_methods.rb +34 -0
  69. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb +73 -0
  70. data/lib/convenient_service/service/plugins/has_result/entities/result/{entities.rb → plugins/has_jsend_status_and_attributes/entities.rb} +0 -0
  71. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/errors.rb +29 -0
  72. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/middleware.rb +31 -0
  73. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs/jsend_attributes.rb +21 -0
  74. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs.rb +3 -0
  75. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes.rb +8 -0
  76. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins.rb +2 -0
  77. data/lib/convenient_service/service/plugins/has_result/entities/result.rb +0 -4
  78. data/lib/convenient_service/service/plugins/has_result_method_steps/middleware.rb +1 -1
  79. data/lib/convenient_service/service/plugins/has_result_method_steps/services/method_step_config.rb +30 -4
  80. data/lib/convenient_service/service/plugins/has_result_params_validations/using_dry_validation/middleware.rb +19 -9
  81. data/lib/convenient_service/service/plugins/has_result_status_check_short_syntax/concern.rb +63 -0
  82. data/lib/convenient_service/service/plugins/has_result_status_check_short_syntax.rb +3 -0
  83. data/lib/convenient_service/service/plugins/has_result_steps/concern.rb +2 -1
  84. data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/has_inspect/concern.rb +31 -0
  85. data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/has_inspect.rb +3 -0
  86. data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins.rb +3 -0
  87. data/lib/convenient_service/service/plugins/has_result_steps/entities/step.rb +1 -0
  88. data/lib/convenient_service/service/plugins/has_result_steps/middleware.rb +1 -1
  89. data/lib/convenient_service/service/plugins.rb +2 -0
  90. data/lib/convenient_service/support/cache/key.rb +100 -0
  91. data/lib/convenient_service/support/cache.rb +131 -0
  92. data/lib/convenient_service/support/copyable.rb +3 -2
  93. data/lib/convenient_service/support/delegate.rb +3 -2
  94. data/lib/convenient_service/support.rb +1 -0
  95. data/lib/convenient_service/version.rb +1 -1
  96. data/logo.png +0 -0
  97. metadata +40 -21
  98. data/lib/convenient_service/common/plugins/caches_return_value/entities/key.rb +0 -79
  99. data/lib/convenient_service/common/plugins/caches_return_value/entities.rb +0 -3
  100. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/entities/cache.rb +0 -81
  101. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/entities.rb +0 -3
  102. data/lib/convenient_service/service/plugins/has_result/entities/result/commands/cast_result_params.rb +0 -33
  103. data/lib/convenient_service/service/plugins/has_result/entities/result/commands.rb +0 -3
  104. data/lib/convenient_service/service/plugins/has_result/entities/result/concern/instance_methods.rb +0 -64
  105. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/code/class_methods.rb +0 -30
  106. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/code.rb +0 -45
  107. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/data/class_methods.rb +0 -28
  108. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/data.rb +0 -45
  109. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/message/class_methods.rb +0 -30
  110. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/message.rb +0 -41
  111. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/status/class_methods.rb +0 -30
  112. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/status.rb +0 -69
  113. data/lib/convenient_service/service/plugins/has_result/entities/result/errors.rb +0 -25
  114. data/lib/convenient_service/service/plugins/has_result/entities/result/structs/result_params.rb +0 -17
  115. data/lib/convenient_service/service/plugins/has_result/entities/result/structs.rb +0 -3
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "code/class_methods"
4
-
5
- module ConvenientService
6
- module Service
7
- module Plugins
8
- module HasResult
9
- module Entities
10
- class Result
11
- module Entities
12
- class Code
13
- include Support::Castable
14
-
15
- extend ClassMethods
16
-
17
- attr_reader :value
18
-
19
- def initialize(value:)
20
- @value = value
21
- end
22
-
23
- def ==(other)
24
- casted = cast(other)
25
-
26
- return unless casted
27
-
28
- value == casted.value
29
- end
30
-
31
- def to_s
32
- @to_s ||= value.to_s
33
- end
34
-
35
- def to_sym
36
- @to_sym ||= value.to_sym
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Service
5
- module Plugins
6
- module HasResult
7
- module Entities
8
- class Result
9
- module Entities
10
- class Data
11
- module ClassMethods
12
- def cast(other)
13
- case other
14
- when ::Hash
15
- new(value: other.transform_keys(&:to_sym))
16
- when Data
17
- new(value: other.value)
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "data/class_methods"
4
-
5
- module ConvenientService
6
- module Service
7
- module Plugins
8
- module HasResult
9
- module Entities
10
- class Result
11
- module Entities
12
- class Data
13
- include Support::Castable
14
-
15
- extend ClassMethods
16
-
17
- attr_reader :value
18
-
19
- def initialize(value:)
20
- @value = value
21
- end
22
-
23
- def ==(other)
24
- casted = cast(other)
25
-
26
- return unless casted
27
-
28
- value == casted.value
29
- end
30
-
31
- def [](key)
32
- value.fetch(key.to_sym) { raise Errors::NotExistingAttribute.new(attribute: key) }
33
- end
34
-
35
- def to_h
36
- @to_h ||= value.to_h
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Service
5
- module Plugins
6
- module HasResult
7
- module Entities
8
- class Result
9
- module Entities
10
- class Message
11
- module ClassMethods
12
- def cast(other)
13
- case other
14
- when ::String
15
- new(value: other)
16
- when ::Symbol
17
- new(value: other.to_s)
18
- when Message
19
- new(value: other.value)
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "message/class_methods"
4
-
5
- module ConvenientService
6
- module Service
7
- module Plugins
8
- module HasResult
9
- module Entities
10
- class Result
11
- module Entities
12
- class Message
13
- include Support::Castable
14
-
15
- extend ClassMethods
16
-
17
- attr_reader :value
18
-
19
- def initialize(value:)
20
- @value = value
21
- end
22
-
23
- def ==(other)
24
- casted = cast(other)
25
-
26
- return unless casted
27
-
28
- value == casted.value
29
- end
30
-
31
- def to_s
32
- @to_s ||= value.to_s
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Service
5
- module Plugins
6
- module HasResult
7
- module Entities
8
- class Result
9
- module Entities
10
- class Status
11
- module ClassMethods
12
- def cast(other)
13
- case other
14
- when ::String
15
- new(value: other.to_sym)
16
- when ::Symbol
17
- new(value: other)
18
- when Status
19
- new(value: other.value)
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,69 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "status/class_methods"
4
-
5
- module ConvenientService
6
- module Service
7
- module Plugins
8
- module HasResult
9
- module Entities
10
- class Result
11
- module Entities
12
- class Status
13
- include Support::Castable
14
-
15
- extend ClassMethods
16
-
17
- attr_reader :value
18
-
19
- def initialize(value:)
20
- @value = value
21
- end
22
-
23
- def ==(other)
24
- casted = cast(other)
25
-
26
- return unless casted
27
-
28
- value == casted.value
29
- end
30
-
31
- def success?
32
- value == :success
33
- end
34
-
35
- def failure?
36
- value == :failure
37
- end
38
-
39
- def error?
40
- value == :error
41
- end
42
-
43
- def not_success?
44
- !success?
45
- end
46
-
47
- def not_failure?
48
- !failure?
49
- end
50
-
51
- def not_error?
52
- !error?
53
- end
54
-
55
- def to_s
56
- @to_s ||= value.to_s
57
- end
58
-
59
- def to_sym
60
- @to_sym ||= value.to_sym
61
- end
62
- end
63
- end
64
- end
65
- end
66
- end
67
- end
68
- end
69
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Service
5
- module Plugins
6
- module HasResult
7
- module Entities
8
- class Result
9
- module Errors
10
- class NotExistingAttribute < ConvenientService::Error
11
- def initialize(attribute:)
12
- message = <<~TEXT
13
- Data attribute `#{attribute}` does NOT exist. Make sure the corresponding result returns it.
14
- TEXT
15
-
16
- super(message)
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Service
5
- module Plugins
6
- module HasResult
7
- module Entities
8
- class Result
9
- module Structs
10
- ResultParams = ::Struct.new(:service, :status, :data, :message, :code, keyword_init: true)
11
- end
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "structs/result_params"