convenient_service 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) 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/CHANGELOG.md +18 -0
  7. data/README.md +12 -3
  8. data/ROADMAP.md +19 -8
  9. data/Taskfile.yml +2 -10
  10. data/lib/convenient_service/common/plugins/caches_return_value/middleware.rb +17 -2
  11. data/lib/convenient_service/common/plugins/caches_return_value.rb +0 -1
  12. data/lib/convenient_service/common/plugins/has_constructor/concern.rb +13 -0
  13. data/lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb +27 -0
  14. data/lib/convenient_service/common/plugins/has_constructor_without_initialize.rb +3 -0
  15. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/concern.rb +8 -4
  16. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache.rb +0 -1
  17. data/lib/convenient_service/common/plugins.rb +1 -0
  18. data/lib/convenient_service/configs/standard.rb +16 -0
  19. data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/commands/cast_container.rb +0 -2
  20. data/lib/convenient_service/dependencies.rb +1 -0
  21. data/lib/convenient_service/examples/dry/gemfile.rb +5 -4
  22. data/lib/convenient_service/examples/rails/gemfile.rb +5 -4
  23. data/lib/convenient_service/examples/standard/cowsay/services/build_cloud.rb +42 -0
  24. data/lib/convenient_service/examples/standard/cowsay/services/build_cow.rb +38 -0
  25. data/lib/convenient_service/examples/standard/cowsay/services/print.rb +32 -0
  26. data/lib/convenient_service/examples/standard/cowsay/services.rb +5 -0
  27. data/lib/convenient_service/examples/standard/cowsay.rb +24 -0
  28. data/lib/convenient_service/examples/standard/gemfile/services/format.rb +2 -0
  29. data/lib/convenient_service/examples/standard/gemfile.rb +5 -4
  30. data/lib/convenient_service/rspec/helpers/custom/stub_service/entities/result_spec.rb +96 -7
  31. data/lib/convenient_service/rspec/helpers/custom/wrap_method/entities/wrapped_method.rb +44 -8
  32. data/lib/convenient_service/rspec/helpers/custom/wrap_method/errors.rb +11 -9
  33. data/lib/convenient_service/rspec/matchers/custom/call_chain_next.rb +2 -0
  34. data/lib/convenient_service/rspec/matchers/custom/results/be_success.rb +6 -0
  35. data/lib/convenient_service/service/plugins/aliases.rb +1 -0
  36. data/lib/convenient_service/service/plugins/has_inspect/concern.rb +23 -0
  37. data/lib/convenient_service/service/plugins/has_inspect.rb +3 -0
  38. data/lib/convenient_service/service/plugins/has_result/commands/create_result_class.rb +10 -0
  39. data/lib/convenient_service/service/plugins/has_result/concern/class_methods.rb +23 -14
  40. data/lib/convenient_service/service/plugins/has_result/concern/instance_methods.rb +17 -1
  41. data/lib/convenient_service/service/plugins/has_result/entities/result/concern.rb +4 -3
  42. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_inspect/concern.rb +31 -0
  43. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_inspect.rb +3 -0
  44. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands/cast_jsend_attributes.rb +37 -0
  45. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands.rb +3 -0
  46. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/concern/instance_methods.rb +115 -0
  47. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/concern.rb +27 -0
  48. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/code/class_methods.rb +34 -0
  49. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/code.rb +49 -0
  50. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data/class_methods.rb +32 -0
  51. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data.rb +49 -0
  52. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message/class_methods.rb +34 -0
  53. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message.rb +45 -0
  54. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status/class_methods.rb +34 -0
  55. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb +73 -0
  56. data/lib/convenient_service/service/plugins/has_result/entities/result/{entities.rb → plugins/has_jsend_status_and_attributes/entities.rb} +0 -0
  57. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/errors.rb +29 -0
  58. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/middleware.rb +31 -0
  59. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs/jsend_attributes.rb +21 -0
  60. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs.rb +3 -0
  61. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes.rb +8 -0
  62. data/lib/convenient_service/service/plugins/has_result/entities/result/plugins.rb +2 -0
  63. data/lib/convenient_service/service/plugins/has_result/entities/result.rb +0 -4
  64. data/lib/convenient_service/service/plugins/has_result_method_steps/middleware.rb +1 -1
  65. data/lib/convenient_service/service/plugins/has_result_method_steps/services/method_step_config.rb +30 -4
  66. data/lib/convenient_service/service/plugins/has_result_status_check_short_syntax/concern.rb +63 -0
  67. data/lib/convenient_service/service/plugins/has_result_status_check_short_syntax.rb +3 -0
  68. data/lib/convenient_service/service/plugins/has_result_steps/concern.rb +2 -1
  69. data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/has_inspect/concern.rb +31 -0
  70. data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/has_inspect.rb +3 -0
  71. data/lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins.rb +3 -0
  72. data/lib/convenient_service/service/plugins/has_result_steps/entities/step.rb +1 -0
  73. data/lib/convenient_service/service/plugins.rb +2 -0
  74. data/lib/convenient_service/support/cache/key.rb +100 -0
  75. data/lib/convenient_service/support/cache.rb +131 -0
  76. data/lib/convenient_service/support/copyable.rb +3 -2
  77. data/lib/convenient_service/support/delegate.rb +3 -2
  78. data/lib/convenient_service/support.rb +1 -0
  79. data/lib/convenient_service/version.rb +1 -1
  80. data/logo.png +0 -0
  81. metadata +40 -21
  82. data/lib/convenient_service/common/plugins/caches_return_value/entities/key.rb +0 -79
  83. data/lib/convenient_service/common/plugins/caches_return_value/entities.rb +0 -3
  84. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/entities/cache.rb +0 -81
  85. data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/entities.rb +0 -3
  86. data/lib/convenient_service/service/plugins/has_result/entities/result/commands/cast_result_params.rb +0 -33
  87. data/lib/convenient_service/service/plugins/has_result/entities/result/commands.rb +0 -3
  88. data/lib/convenient_service/service/plugins/has_result/entities/result/concern/instance_methods.rb +0 -64
  89. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/code/class_methods.rb +0 -30
  90. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/code.rb +0 -45
  91. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/data/class_methods.rb +0 -28
  92. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/data.rb +0 -45
  93. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/message/class_methods.rb +0 -30
  94. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/message.rb +0 -41
  95. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/status/class_methods.rb +0 -30
  96. data/lib/convenient_service/service/plugins/has_result/entities/result/entities/status.rb +0 -69
  97. data/lib/convenient_service/service/plugins/has_result/entities/result/errors.rb +0 -25
  98. data/lib/convenient_service/service/plugins/has_result/entities/result/structs/result_params.rb +0 -17
  99. data/lib/convenient_service/service/plugins/has_result/entities/result/structs.rb +0 -3
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ConvenientService
4
+ module Service
5
+ module Plugins
6
+ module HasResultStatusCheckShortSyntax
7
+ module Concern
8
+ include Support::Concern
9
+
10
+ class_methods do
11
+ ##
12
+ # @return [Boolean]
13
+ # @since 0.2.0
14
+ #
15
+ def success?(...)
16
+ result(...).success?
17
+ end
18
+
19
+ ##
20
+ # @return [Boolean]
21
+ # @since 0.2.0
22
+ #
23
+ def error?(...)
24
+ result(...).error?
25
+ end
26
+
27
+ ##
28
+ # @return [Boolean]
29
+ # @since 0.2.0
30
+ #
31
+ def failure?(...)
32
+ result(...).failure?
33
+ end
34
+
35
+ ##
36
+ # @return [Boolean]
37
+ # @since 0.2.0
38
+ #
39
+ def not_success?(...)
40
+ result(...).not_success?
41
+ end
42
+
43
+ ##
44
+ # @return [Boolean]
45
+ # @since 0.2.0
46
+ #
47
+ def not_error?(...)
48
+ result(...).not_error?
49
+ end
50
+
51
+ ##
52
+ # @return [Boolean]
53
+ # @since 0.2.0
54
+ #
55
+ def not_failure?(...)
56
+ result(...).not_failure?
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "has_result_status_check_short_syntax/concern"
@@ -9,11 +9,12 @@ module ConvenientService
9
9
 
10
10
  instance_methods do
11
11
  def steps
12
- @steps ||=
12
+ internals.cache.fetch(:steps) do
13
13
  self.class
14
14
  .steps
15
15
  .tap(&:commit!)
16
16
  .map { |step| step.copy(overrides: {kwargs: {organizer: self}}) }
17
+ end
17
18
  end
18
19
 
19
20
  ##
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ConvenientService
4
+ module Service
5
+ module Plugins
6
+ module HasResultSteps
7
+ module Entities
8
+ class Step
9
+ module Plugins
10
+ module HasInspect
11
+ module Concern
12
+ include Support::Concern
13
+
14
+ instance_methods do
15
+ ##
16
+ # @return [String]
17
+ # @since 0.2.0
18
+ #
19
+ def inspect
20
+ "<#{container.klass.name}::Step service: #{service.klass.name}>"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "has_inspect/concern"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "plugins/has_inspect"
@@ -3,6 +3,7 @@
3
3
  require_relative "step/commands"
4
4
  require_relative "step/concern"
5
5
  require_relative "step/errors"
6
+ require_relative "step/plugins"
6
7
  require_relative "step/structs"
7
8
 
8
9
  module ConvenientService
@@ -4,11 +4,13 @@
4
4
  # NOTE: Order matters.
5
5
  #
6
6
  require_relative "plugins/can_recalculate_result"
7
+ require_relative "plugins/has_inspect"
7
8
  require_relative "plugins/has_result"
8
9
  require_relative "plugins/has_result_method_steps"
9
10
  require_relative "plugins/has_result_short_syntax"
10
11
  require_relative "plugins/has_result_steps"
11
12
  require_relative "plugins/raises_on_double_result"
12
13
  require_relative "plugins/wraps_result_in_db_transaction"
14
+ require_relative "plugins/has_result_status_check_short_syntax"
13
15
 
14
16
  require_relative "plugins/aliases"
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ConvenientService
4
+ module Support
5
+ class Cache
6
+ class Key
7
+ ##
8
+ # @param args [Array]
9
+ # @param kwargs [Hash]
10
+ # @param block [Proc]
11
+ # @return [void]
12
+ #
13
+ def initialize(*args, **kwargs, &block)
14
+ @args = args
15
+ @kwargs = kwargs
16
+ @block = block
17
+ end
18
+
19
+ ##
20
+ # @param other [Object] Can be any type.
21
+ # @return [Boolean]
22
+ #
23
+ def ==(other)
24
+ return unless other.instance_of?(self.class)
25
+
26
+ return false if args != other.args
27
+ return false if kwargs != other.kwargs
28
+ return false if block&.source_location != other.block&.source_location
29
+
30
+ true
31
+ end
32
+
33
+ ##
34
+ # @param other [Object] Can be any type.
35
+ # @return [Boolean]
36
+ #
37
+ # @internal
38
+ # IMPORTANT: `Key` instances are used as Ruby hash keys.
39
+ #
40
+ # This method is overridden in order to avoid the following case:
41
+ #
42
+ # hash = {}
43
+ #
44
+ # ##
45
+ # # Two equal keys in terms of `==`.
46
+ # #
47
+ # first_key = ConvenientService::Common::Plugins::CachesReturnValue::Entities::Key.new(method: :result, args: [], kwargs: {}, block: nil)
48
+ # second_key = ConvenientService::Common::Plugins::CachesReturnValue::Entities::Key.new(method: :result, args: [], kwargs: {}, block: nil)
49
+ #
50
+ # first_key == second_key
51
+ # # => true
52
+ #
53
+ # hash[first_key] = "value"
54
+ #
55
+ # hash[second_key]
56
+ # # => nil # This happens since keys are not equal in terms of `eql?`.
57
+ #
58
+ # NOTE: Ruby hash and Object#hash are not the same things.
59
+ # - https://ruby-doc.org/core-3.1.2/Object.html#method-i-hash
60
+ # - https://belighted.com/blog/overriding-equals-equals/
61
+ #
62
+ def eql?(other)
63
+ return unless other.instance_of?(self.class)
64
+
65
+ hash == other.hash
66
+ end
67
+
68
+ ##
69
+ # @internal
70
+ # NOTE: hash is overridden to treat blocks that were defined at the same location as equal.
71
+ # - https://ruby-doc.org/core-3.1.2/Proc.html#method-i-source_location
72
+ # - https://ruby-doc.org/core-3.1.2/Object.html#method-i-hash
73
+ #
74
+ def hash
75
+ [args, kwargs, block&.source_location].hash
76
+ end
77
+
78
+ protected
79
+
80
+ ##
81
+ # @!attribute [r] args
82
+ # @return [Array]
83
+ #
84
+ attr_reader :args
85
+
86
+ ##
87
+ # @!attribute [r] kwargs
88
+ # @return [Hash]
89
+ #
90
+ attr_reader :kwargs
91
+
92
+ ##
93
+ # @!attribute [r] block
94
+ # @return [Proc]
95
+ #
96
+ attr_reader :block
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,131 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "cache/key"
4
+
5
+ module ConvenientService
6
+ module Support
7
+ class Cache
8
+ ##
9
+ # @return [void]
10
+ #
11
+ def initialize(hash = {})
12
+ @hash = hash
13
+ end
14
+
15
+ class << self
16
+ ##
17
+ # @return [ConvenientService::Support::Cache::Key]
18
+ #
19
+ def keygen(...)
20
+ Cache::Key.new(...)
21
+ end
22
+ end
23
+
24
+ ##
25
+ # @return [Boolean]
26
+ #
27
+ # @internal
28
+ # https://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html#method-i-exist-3F
29
+ #
30
+ def exist?(key)
31
+ hash.has_key?(key)
32
+ end
33
+
34
+ ##
35
+ # @return [Object] Can be any type.
36
+ #
37
+ # @internal
38
+ # https://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html#method-i-read
39
+ #
40
+ def read(key)
41
+ hash[key]
42
+ end
43
+
44
+ ##
45
+ # @return [Object] Can be any type.
46
+ #
47
+ # @internal
48
+ # NOTE: `alias_method` is NOT used in order to have an ability to use `allow(cache).to receive(:read).with(key).and_call_original` for both `cache[key]` and `cache.read(key)` in RSpec.
49
+ #
50
+ def [](key)
51
+ read(key)
52
+ end
53
+
54
+ ##
55
+ # @param key [Object] Can be any type.
56
+ # @param value [Object] Can be any type.
57
+ # @return [Object] Can be any type.
58
+ #
59
+ # @internal
60
+ # https://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html#method-i-write
61
+ #
62
+ def write(key, value)
63
+ hash[key] = value
64
+ end
65
+
66
+ ##
67
+ # @param key [Object] Can be any type.
68
+ # @param value [Object] Can be any type.
69
+ # @return [Object] Can be any type.
70
+ #
71
+ # @internal
72
+ # NOTE: `alias_method` is NOT used in order to have an ability to use `allow(cache).to receive(:write).with(key, value).and_call_original` for both `cache[key] = value` and `cache.write(key, value)` in RSpec.
73
+ #
74
+ def []=(key, value)
75
+ write(key, value)
76
+ end
77
+
78
+ ##
79
+ # @param key [Object] Can be any type.
80
+ # @return [Object] Can be any type.
81
+ #
82
+ # @internal
83
+ # https://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html#method-i-delete
84
+ #
85
+ def delete(key)
86
+ hash.delete(key)
87
+ end
88
+
89
+ ##
90
+ # @param key [Object] Can be any type.
91
+ # @param block [Proc]
92
+ # @return [Object] Can be any type.
93
+ #
94
+ # @internal
95
+ # https://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html#method-i-fetch
96
+ #
97
+ def fetch(key, &block)
98
+ return read(key) unless block
99
+
100
+ exist?(key) ? read(key) : write(key, block.call)
101
+ end
102
+
103
+ ##
104
+ # @return [ConvenientService::Support::Cache::Key]
105
+ #
106
+ def keygen(...)
107
+ Cache.keygen(...)
108
+ end
109
+
110
+ ##
111
+ # @param other [Object] Can be any type.
112
+ # @return [Boolean]
113
+ #
114
+ def ==(other)
115
+ return unless other.instance_of?(self.class)
116
+
117
+ return false if hash != other.hash
118
+
119
+ true
120
+ end
121
+
122
+ protected
123
+
124
+ ##
125
+ # @!attribute [r] hash
126
+ # @return [Hash]
127
+ #
128
+ attr_reader :hash
129
+ end
130
+ end
131
+ end
@@ -15,8 +15,9 @@ module ConvenientService
15
15
  # copy = person.copy(overrides: {kwargs: {age: 18}})
16
16
  # copy = person.copy(overrides: {block: proc { |p| print p }})
17
17
  #
18
- # NOTE: Inline logic instead of private methods is used intentionally in order to NOT pollute the public interface.
19
- # NOTE: This method is NOT likely to be ever changed, that is why inline logic is preferred over command classes in this particular case.
18
+ # @internal
19
+ # NOTE: Inline logic instead of private methods is used intentionally in order to NOT pollute the public interface.
20
+ # NOTE: This method is NOT likely to be ever changed, that is why inline logic is preferred over command classes in this particular case.
20
21
  #
21
22
  def copy(overrides: {})
22
23
  overrides[:args] ||= {}
@@ -19,8 +19,9 @@ module ConvenientService
19
19
  end
20
20
 
21
21
  ##
22
- # `ClassMethods` is loaded faster than `included` by `Concern`.
23
- # Since `Forwardable` has it own `delegate` - a different name is used.
22
+ # @internal
23
+ # `ClassMethods` is loaded faster than `included` by `Concern`.
24
+ # Since `Forwardable` has it own `delegate` - a different name is used.
24
25
  #
25
26
  module ClassMethodsForForwardable
26
27
  def delegate(*methods, to:)
@@ -3,6 +3,7 @@
3
3
  require_relative "support/concern"
4
4
 
5
5
  require_relative "support/abstract_method"
6
+ require_relative "support/cache"
6
7
  require_relative "support/castable"
7
8
  require_relative "support/command"
8
9
  require_relative "support/copyable"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ConvenientService
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/logo.png CHANGED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convenient_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marian Kostyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-04 00:00:00.000000000 Z
11
+ date: 2022-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -303,6 +303,8 @@ extra_rdoc_files: []
303
303
  files:
304
304
  - ".dockerignore"
305
305
  - ".gem_release.yml"
306
+ - ".github/issue_template.md"
307
+ - ".github/pull_request_template.md"
306
308
  - ".github/workflows/cd.yml"
307
309
  - ".github/workflows/ci.yml"
308
310
  - ".gitignore"
@@ -342,8 +344,6 @@ files:
342
344
  - lib/convenient_service/common/plugins/caches_constructor_params/entities/constructor_params.rb
343
345
  - lib/convenient_service/common/plugins/caches_constructor_params/middleware.rb
344
346
  - lib/convenient_service/common/plugins/caches_return_value.rb
345
- - lib/convenient_service/common/plugins/caches_return_value/entities.rb
346
- - lib/convenient_service/common/plugins/caches_return_value/entities/key.rb
347
347
  - lib/convenient_service/common/plugins/caches_return_value/middleware.rb
348
348
  - lib/convenient_service/common/plugins/can_be_copied.rb
349
349
  - lib/convenient_service/common/plugins/can_be_copied/concern.rb
@@ -366,6 +366,8 @@ files:
366
366
  - lib/convenient_service/common/plugins/has_callbacks/middleware.rb
367
367
  - lib/convenient_service/common/plugins/has_constructor.rb
368
368
  - lib/convenient_service/common/plugins/has_constructor/concern.rb
369
+ - lib/convenient_service/common/plugins/has_constructor_without_initialize.rb
370
+ - lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb
369
371
  - lib/convenient_service/common/plugins/has_internals.rb
370
372
  - lib/convenient_service/common/plugins/has_internals/commands.rb
371
373
  - lib/convenient_service/common/plugins/has_internals/commands/create_internals_class.rb
@@ -376,8 +378,6 @@ files:
376
378
  - lib/convenient_service/common/plugins/has_internals/entities/internals/plugins.rb
377
379
  - lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache.rb
378
380
  - lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/concern.rb
379
- - lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/entities.rb
380
- - lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/entities/cache.rb
381
381
  - lib/convenient_service/common/plugins/normalizes_env.rb
382
382
  - lib/convenient_service/common/plugins/normalizes_env/middleware.rb
383
383
  - lib/convenient_service/configs.rb
@@ -471,6 +471,11 @@ files:
471
471
  - lib/convenient_service/examples/rails/gemfile/services/read_file_content.rb
472
472
  - lib/convenient_service/examples/rails/gemfile/services/run_shell.rb
473
473
  - lib/convenient_service/examples/rails/gemfile/services/strip_comments.rb
474
+ - lib/convenient_service/examples/standard/cowsay.rb
475
+ - lib/convenient_service/examples/standard/cowsay/services.rb
476
+ - lib/convenient_service/examples/standard/cowsay/services/build_cloud.rb
477
+ - lib/convenient_service/examples/standard/cowsay/services/build_cow.rb
478
+ - lib/convenient_service/examples/standard/cowsay/services/print.rb
474
479
  - lib/convenient_service/examples/standard/gemfile.rb
475
480
  - lib/convenient_service/examples/standard/gemfile/services.rb
476
481
  - lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb
@@ -545,6 +550,8 @@ files:
545
550
  - lib/convenient_service/service/plugins/aliases.rb
546
551
  - lib/convenient_service/service/plugins/can_recalculate_result.rb
547
552
  - lib/convenient_service/service/plugins/can_recalculate_result/concern.rb
553
+ - lib/convenient_service/service/plugins/has_inspect.rb
554
+ - lib/convenient_service/service/plugins/has_inspect/concern.rb
548
555
  - lib/convenient_service/service/plugins/has_result.rb
549
556
  - lib/convenient_service/service/plugins/has_result/commands.rb
550
557
  - lib/convenient_service/service/plugins/has_result/commands/create_result_class.rb
@@ -554,23 +561,30 @@ files:
554
561
  - lib/convenient_service/service/plugins/has_result/constants.rb
555
562
  - lib/convenient_service/service/plugins/has_result/entities.rb
556
563
  - lib/convenient_service/service/plugins/has_result/entities/result.rb
557
- - lib/convenient_service/service/plugins/has_result/entities/result/commands.rb
558
- - lib/convenient_service/service/plugins/has_result/entities/result/commands/cast_result_params.rb
559
564
  - lib/convenient_service/service/plugins/has_result/entities/result/concern.rb
560
- - lib/convenient_service/service/plugins/has_result/entities/result/concern/instance_methods.rb
561
- - lib/convenient_service/service/plugins/has_result/entities/result/entities.rb
562
- - lib/convenient_service/service/plugins/has_result/entities/result/entities/code.rb
563
- - lib/convenient_service/service/plugins/has_result/entities/result/entities/code/class_methods.rb
564
- - lib/convenient_service/service/plugins/has_result/entities/result/entities/data.rb
565
- - lib/convenient_service/service/plugins/has_result/entities/result/entities/data/class_methods.rb
566
- - lib/convenient_service/service/plugins/has_result/entities/result/entities/message.rb
567
- - lib/convenient_service/service/plugins/has_result/entities/result/entities/message/class_methods.rb
568
- - lib/convenient_service/service/plugins/has_result/entities/result/entities/status.rb
569
- - lib/convenient_service/service/plugins/has_result/entities/result/entities/status/class_methods.rb
570
- - lib/convenient_service/service/plugins/has_result/entities/result/errors.rb
571
565
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins.rb
572
566
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_recalculate_result.rb
573
567
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/can_recalculate_result/concern.rb
568
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_inspect.rb
569
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_inspect/concern.rb
570
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes.rb
571
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands.rb
572
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/commands/cast_jsend_attributes.rb
573
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/concern.rb
574
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/concern/instance_methods.rb
575
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities.rb
576
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/code.rb
577
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/code/class_methods.rb
578
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data.rb
579
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data/class_methods.rb
580
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message.rb
581
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/message/class_methods.rb
582
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb
583
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status/class_methods.rb
584
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/errors.rb
585
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/middleware.rb
586
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs.rb
587
+ - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/structs/jsend_attributes.rb
574
588
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax.rb
575
589
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax/concern.rb
576
590
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_result_short_syntax/concern/instance_methods.rb
@@ -579,8 +593,6 @@ files:
579
593
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/raises_on_not_checked_result_status.rb
580
594
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/raises_on_not_checked_result_status/errors.rb
581
595
  - lib/convenient_service/service/plugins/has_result/entities/result/plugins/raises_on_not_checked_result_status/middleware.rb
582
- - lib/convenient_service/service/plugins/has_result/entities/result/structs.rb
583
- - lib/convenient_service/service/plugins/has_result/entities/result/structs/result_params.rb
584
596
  - lib/convenient_service/service/plugins/has_result/errors.rb
585
597
  - lib/convenient_service/service/plugins/has_result/middleware.rb
586
598
  - lib/convenient_service/service/plugins/has_result_method_steps.rb
@@ -614,6 +626,8 @@ files:
614
626
  - lib/convenient_service/service/plugins/has_result_short_syntax/success/commands/refute_kwargs_contain_data_and_extra_keys.rb
615
627
  - lib/convenient_service/service/plugins/has_result_short_syntax/success/errors.rb
616
628
  - lib/convenient_service/service/plugins/has_result_short_syntax/success/middleware.rb
629
+ - lib/convenient_service/service/plugins/has_result_status_check_short_syntax.rb
630
+ - lib/convenient_service/service/plugins/has_result_status_check_short_syntax/concern.rb
617
631
  - lib/convenient_service/service/plugins/has_result_steps.rb
618
632
  - lib/convenient_service/service/plugins/has_result_steps/commands.rb
619
633
  - lib/convenient_service/service/plugins/has_result_steps/commands/create_step_class.rb
@@ -655,6 +669,9 @@ files:
655
669
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/concern.rb
656
670
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/concern/instance_methods.rb
657
671
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/errors.rb
672
+ - lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins.rb
673
+ - lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/has_inspect.rb
674
+ - lib/convenient_service/service/plugins/has_result_steps/entities/step/plugins/has_inspect/concern.rb
658
675
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/structs.rb
659
676
  - lib/convenient_service/service/plugins/has_result_steps/entities/step/structs/params.rb
660
677
  - lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb
@@ -668,6 +685,8 @@ files:
668
685
  - lib/convenient_service/support.rb
669
686
  - lib/convenient_service/support/abstract_method.rb
670
687
  - lib/convenient_service/support/abstract_method/errors.rb
688
+ - lib/convenient_service/support/cache.rb
689
+ - lib/convenient_service/support/cache/key.rb
671
690
  - lib/convenient_service/support/castable.rb
672
691
  - lib/convenient_service/support/castable/errors.rb
673
692
  - lib/convenient_service/support/command.rb
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConvenientService
4
- module Common
5
- module Plugins
6
- module CachesReturnValue
7
- module Entities
8
- class Key
9
- attr_reader :method, :args, :kwargs, :block
10
-
11
- ##
12
- #
13
- #
14
- def initialize(method:, args:, kwargs:, block:)
15
- @method = method
16
- @args = args
17
- @kwargs = kwargs
18
- @block = block
19
- end
20
-
21
- ##
22
- #
23
- #
24
- def ==(other)
25
- return unless other.instance_of?(self.class)
26
-
27
- return false if method != other.method
28
- return false if args != other.args
29
- return false if kwargs != other.kwargs
30
- return false if block&.source_location != other.block&.source_location
31
-
32
- true
33
- end
34
-
35
- ##
36
- # IMPORTANT: `Key` instances are used as Ruby hash keys.
37
- #
38
- # This method is overridden in order to avoid the following case:
39
- #
40
- # hash = {}
41
- #
42
- # ##
43
- # # Two equal keys in terms of `==`.
44
- # #
45
- # first_key = ConvenientService::Common::Plugins::CachesReturnValue::Entities::Key.new(method: :result, args: [], kwargs: {}, block: nil)
46
- # second_key = ConvenientService::Common::Plugins::CachesReturnValue::Entities::Key.new(method: :result, args: [], kwargs: {}, block: nil)
47
- #
48
- # first_key == second_key
49
- # # => true
50
- #
51
- # hash[first_key] = "value"
52
- #
53
- # hash[second_key]
54
- # # => nil # This happens since keys are not equal in terms of `eql?`.
55
- #
56
- # NOTE: Ruby hash and Object#hash are not the same things.
57
- # https://ruby-doc.org/core-3.1.2/Object.html#method-i-hash
58
- # https://belighted.com/blog/overriding-equals-equals/
59
- #
60
- def eql?(other)
61
- return unless other.instance_of?(self.class)
62
-
63
- hash == other.hash
64
- end
65
-
66
- ##
67
- # NOTE: hash is overridden to treat blocks that were defined at the same location as equal.
68
- # https://ruby-doc.org/core-3.1.2/Proc.html#method-i-source_location
69
- # https://ruby-doc.org/core-3.1.2/Object.html#method-i-hash
70
- #
71
- def hash
72
- [method, args, kwargs, block&.source_location].hash
73
- end
74
- end
75
- end
76
- end
77
- end
78
- end
79
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "entities/key"