servactory 2.6.3 → 2.8.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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/config/locales/en.yml +12 -0
  3. data/config/locales/ru.yml +12 -0
  4. data/lib/servactory/actions/dsl.rb +2 -2
  5. data/lib/servactory/actions/tools/runner.rb +1 -1
  6. data/lib/servactory/configuration/factory.rb +1 -31
  7. data/lib/servactory/configuration/setup.rb +3 -3
  8. data/lib/servactory/context/callable.rb +7 -7
  9. data/lib/servactory/context/workspace/inputs.rb +2 -2
  10. data/lib/servactory/context/workspace/internals.rb +3 -3
  11. data/lib/servactory/context/workspace/outputs.rb +3 -3
  12. data/lib/servactory/context/workspace.rb +19 -19
  13. data/lib/servactory/info/dsl.rb +3 -3
  14. data/lib/servactory/inputs/input.rb +5 -5
  15. data/lib/servactory/inputs/tools/validation.rb +7 -7
  16. data/lib/servactory/inputs/validations/required.rb +1 -1
  17. data/lib/servactory/internals/internal.rb +5 -5
  18. data/lib/servactory/maintenance/attributes/option.rb +13 -13
  19. data/lib/servactory/maintenance/attributes/tools/validation.rb +5 -5
  20. data/lib/servactory/maintenance/attributes/translator/inclusion.rb +2 -2
  21. data/lib/servactory/maintenance/attributes/translator/must.rb +8 -8
  22. data/lib/servactory/maintenance/attributes/translator/type.rb +12 -12
  23. data/lib/servactory/maintenance/attributes/validations/inclusion.rb +1 -1
  24. data/lib/servactory/maintenance/attributes/validations/must.rb +7 -7
  25. data/lib/servactory/maintenance/attributes/validations/type.rb +1 -1
  26. data/lib/servactory/maintenance/validations/object_schema.rb +11 -11
  27. data/lib/servactory/outputs/output.rb +5 -5
  28. data/lib/servactory/result.rb +15 -4
  29. data/lib/servactory/test_kit/result.rb +2 -2
  30. data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb +1 -1
  31. data/lib/servactory/tool_kit/dynamic_options/consists_of.rb +14 -13
  32. data/lib/servactory/tool_kit/dynamic_options/format.rb +11 -8
  33. data/lib/servactory/tool_kit/dynamic_options/max.rb +12 -9
  34. data/lib/servactory/tool_kit/dynamic_options/min.rb +12 -9
  35. data/lib/servactory/tool_kit/dynamic_options/multiple_of.rb +103 -0
  36. data/lib/servactory/tool_kit/dynamic_options/must.rb +16 -13
  37. data/lib/servactory/version.rb +2 -2
  38. metadata +5 -8
  39. data/lib/servactory/errors/failure.rb +0 -20
  40. data/lib/servactory/errors/input_error.rb +0 -20
  41. data/lib/servactory/errors/internal_error.rb +0 -20
  42. data/lib/servactory/errors/output_error.rb +0 -20
@@ -5,11 +5,14 @@ module Servactory
5
5
  module DynamicOptions
6
6
  class Must
7
7
  class WorkOption
8
- attr_reader :value,
8
+ attr_reader :name,
9
+ :value,
9
10
  :message,
10
11
  :properties
11
12
 
12
- def initialize(data, body_key:, body_fallback:)
13
+ def initialize(name, data, body_key:, body_fallback:)
14
+ @name = name
15
+
13
16
  @value =
14
17
  if data.is_a?(Hash) && data.key?(body_key)
15
18
  data.delete(body_key)
@@ -37,7 +40,7 @@ module Servactory
37
40
 
38
41
  def equivalent_with(name)
39
42
  lambda do |data|
40
- option = WorkOption.new(data, body_key: @body_key, body_fallback: @body_fallback)
43
+ option = WorkOption.new(@option_name, data, body_key: @body_key, body_fallback: @body_fallback)
41
44
 
42
45
  {
43
46
  must: {
@@ -59,11 +62,11 @@ module Servactory
59
62
  def must_content_value_with(option)
60
63
  lambda do |value:, input: nil, internal: nil, output: nil|
61
64
  if input.present? && input.input?
62
- condition_for_input_with(input: input, value: value, option: option)
65
+ condition_for_input_with(input:, value:, option:)
63
66
  elsif internal.present? && internal.internal?
64
- condition_for_internal_with(internal: internal, value: value, option: option)
67
+ condition_for_internal_with(internal:, value:, option:)
65
68
  elsif output.present? && output.output?
66
- condition_for_output_with(output: output, value: value, option: option)
69
+ condition_for_output_with(output:, value:, option:)
67
70
  end
68
71
  end
69
72
  end
@@ -74,25 +77,25 @@ module Servactory
74
77
  is_option_message_proc = option.message.is_a?(Proc) if is_option_message_present
75
78
 
76
79
  lambda do |input: nil, internal: nil, output: nil, **attributes|
77
- default_attributes = { **attributes, option_value: option.value }
80
+ default_attributes = { **attributes, option_name: option.name, option_value: option.value }
78
81
 
79
82
  if Servactory::Utils.really_input?(input)
80
83
  if is_option_message_present
81
- is_option_message_proc ? option.message.call(**default_attributes.merge(input: input)) : option.message
84
+ is_option_message_proc ? option.message.call(**default_attributes.merge(input:)) : option.message
82
85
  else
83
- message_for_input_with(**default_attributes.merge(input: input))
86
+ message_for_input_with(**default_attributes.merge(input:))
84
87
  end
85
88
  elsif Servactory::Utils.really_internal?(internal)
86
89
  if is_option_message_present
87
- is_option_message_proc ? option.message.call(**default_attributes.merge(internal: internal)) : option.message # rubocop:disable Layout/LineLength
90
+ is_option_message_proc ? option.message.call(**default_attributes.merge(internal:)) : option.message
88
91
  else
89
- message_for_internal_with(**default_attributes.merge(internal: internal))
92
+ message_for_internal_with(**default_attributes.merge(internal:))
90
93
  end
91
94
  elsif Servactory::Utils.really_output?(output)
92
95
  if is_option_message_present
93
- is_option_message_proc ? option.message.call(**default_attributes.merge(output: output)) : option.message # rubocop:disable Layout/LineLength
96
+ is_option_message_proc ? option.message.call(**default_attributes.merge(output:)) : option.message
94
97
  else
95
- message_for_output_with(**default_attributes.merge(output: output))
98
+ message_for_output_with(**default_attributes.merge(output:))
96
99
  end
97
100
  end
98
101
  end
@@ -3,8 +3,8 @@
3
3
  module Servactory
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 6
7
- PATCH = 3
6
+ MINOR = 8
7
+ PATCH = 0
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.3
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-26 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5.1'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7.2'
22
+ version: '8.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '5.1'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7.2'
32
+ version: '8.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: i18n
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -271,10 +271,6 @@ files:
271
271
  - lib/servactory/context/workspace/outputs.rb
272
272
  - lib/servactory/dsl.rb
273
273
  - lib/servactory/engine.rb
274
- - lib/servactory/errors/failure.rb
275
- - lib/servactory/errors/input_error.rb
276
- - lib/servactory/errors/internal_error.rb
277
- - lib/servactory/errors/output_error.rb
278
274
  - lib/servactory/exceptions/base.rb
279
275
  - lib/servactory/exceptions/failure.rb
280
276
  - lib/servactory/exceptions/input.rb
@@ -338,6 +334,7 @@ files:
338
334
  - lib/servactory/tool_kit/dynamic_options/format.rb
339
335
  - lib/servactory/tool_kit/dynamic_options/max.rb
340
336
  - lib/servactory/tool_kit/dynamic_options/min.rb
337
+ - lib/servactory/tool_kit/dynamic_options/multiple_of.rb
341
338
  - lib/servactory/tool_kit/dynamic_options/must.rb
342
339
  - lib/servactory/utils.rb
343
340
  - lib/servactory/version.rb
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Errors
5
- # DEPRECATED: This class will be deleted after release 2.4.
6
- class Failure < Servactory::Exceptions::Base
7
- attr_reader :type,
8
- :message,
9
- :meta
10
-
11
- def initialize(type: :base, message:, meta: nil) # rubocop:disable Style/KeywordParametersOrder
12
- @type = type
13
- @message = message
14
- @meta = meta
15
-
16
- super(message)
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Errors
5
- # DEPRECATED: This class will be deleted after release 2.4.
6
- class InputError < Servactory::Exceptions::Base
7
- attr_reader :message,
8
- :input_name,
9
- :meta
10
-
11
- def initialize(message:, input_name: nil, meta: nil)
12
- @message = message
13
- @input_name = input_name&.to_sym
14
- @meta = meta
15
-
16
- super(message)
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Errors
5
- # DEPRECATED: This class will be deleted after release 2.4.
6
- class InternalError < Servactory::Exceptions::Base
7
- attr_reader :message,
8
- :internal_name,
9
- :meta
10
-
11
- def initialize(message:, internal_name: nil, meta: nil)
12
- @message = message
13
- @internal_name = internal_name&.to_sym
14
- @meta = meta
15
-
16
- super(message)
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Errors
5
- # DEPRECATED: This class will be deleted after release 2.4.
6
- class OutputError < Servactory::Exceptions::Base
7
- attr_reader :message,
8
- :output_name,
9
- :meta
10
-
11
- def initialize(message:, output_name: nil, meta: nil)
12
- @message = message
13
- @output_name = output_name&.to_sym
14
- @meta = meta
15
-
16
- super(message)
17
- end
18
- end
19
- end
20
- end