servactory 2.9.0.rc1 → 2.9.0.rc2
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.
- checksums.yaml +4 -4
- data/config/locales/en.yml +6 -6
- data/config/locales/ru.yml +6 -6
- data/lib/servactory/context/workspace/inputs.rb +9 -5
- data/lib/servactory/context/workspace/internals.rb +9 -6
- data/lib/servactory/context/workspace/outputs.rb +9 -6
- data/lib/servactory/context/workspace.rb +3 -0
- data/lib/servactory/exceptions/input.rb +4 -2
- data/lib/servactory/exceptions/internal.rb +4 -2
- data/lib/servactory/exceptions/output.rb +4 -2
- data/lib/servactory/inputs/tools/rules.rb +1 -0
- data/lib/servactory/inputs/tools/unnecessary.rb +4 -1
- data/lib/servactory/inputs/tools/validation.rb +4 -1
- data/lib/servactory/maintenance/attributes/options/registrar.rb +1 -1
- data/lib/servactory/maintenance/attributes/tools/validation.rb +1 -1
- data/lib/servactory/maintenance/validations/object_schema.rb +1 -1
- data/lib/servactory/tool_kit/dynamic_options/consists_of.rb +2 -2
- data/lib/servactory/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a295d5b65040b9767438b436911e505ba6fa55adc08eff17b4519ca590821fb
|
|
4
|
+
data.tar.gz: b822546868d45ea6d96af38844992346d291328f7fc45479d07885b96cbe2bde
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b13d1f7b5e0ffc8d315a4b4c4749ac71f06d75a271d40158945d227f0dd5b9258bd28afbb7cf020a4432cf1976a8253f9a0983593a6358600a280064fc4a725c
|
|
7
|
+
data.tar.gz: f82304135dff9cc2030b6946f0b7b30b10fb919f24170215f76488eb534920cd818716b15464b180ec8e3a67f9dc8934056c6e3b18f94f92af646935a3f8265d
|
data/config/locales/en.yml
CHANGED
|
@@ -9,8 +9,8 @@ en:
|
|
|
9
9
|
cannot_be_overwritten: "[%{service_class_name}] The following methods cannot be overwritten: %{list_of_methods}"
|
|
10
10
|
inputs:
|
|
11
11
|
undefined:
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
for_fetch: "[%{service_class_name}] Undefined input attribute `%{input_name}`"
|
|
13
|
+
for_assign: "[%{service_class_name}] Undefined input attribute `%{input_name}`"
|
|
14
14
|
validations:
|
|
15
15
|
inclusion:
|
|
16
16
|
default_error: "[%{service_class_name}] Wrong value in `%{input_name}`, must be one of `%{input_inclusion}`"
|
|
@@ -49,8 +49,8 @@ en:
|
|
|
49
49
|
error: "[%{service_class_name}] Conflict in `%{input_name}` input options: `%{conflict_code}`"
|
|
50
50
|
internals:
|
|
51
51
|
undefined:
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
for_fetch: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
|
|
53
|
+
for_assign: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
|
|
54
54
|
validations:
|
|
55
55
|
inclusion:
|
|
56
56
|
default_error: "[%{service_class_name}] Wrong value in `%{internal_name}`, must be one of `%{internal_inclusion}`"
|
|
@@ -81,8 +81,8 @@ en:
|
|
|
81
81
|
wrong_element_type: "[%{service_class_name}] Wrong type in internal attribute hash `%{internal_name}`, expected `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
|
82
82
|
outputs:
|
|
83
83
|
undefined:
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
for_fetch: "[%{service_class_name}] Undefined output attribute `%{output_name}`"
|
|
85
|
+
for_assign: "[%{service_class_name}] Undefined output attribute `%{output_name}`"
|
|
86
86
|
validations:
|
|
87
87
|
inclusion:
|
|
88
88
|
default_error: "[%{service_class_name}] Wrong value in `%{output_name}`, must be one of `%{output_inclusion}`"
|
data/config/locales/ru.yml
CHANGED
|
@@ -9,8 +9,8 @@ ru:
|
|
|
9
9
|
cannot_be_overwritten: "[%{service_class_name}] Нельзя перезаписать следующие методы: %{list_of_methods}"
|
|
10
10
|
inputs:
|
|
11
11
|
undefined:
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
for_fetch: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
|
|
13
|
+
for_assign: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
|
|
14
14
|
validations:
|
|
15
15
|
inclusion:
|
|
16
16
|
default_error: "[%{service_class_name}] Неправильное значение в `%{input_name}`, должно быть одним из `%{input_inclusion}`"
|
|
@@ -49,8 +49,8 @@ ru:
|
|
|
49
49
|
error: "[%{service_class_name}] Конфликт в опциях инпута `%{input_name}`: `%{conflict_code}`"
|
|
50
50
|
internals:
|
|
51
51
|
undefined:
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
for_fetch: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
|
|
53
|
+
for_assign: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
|
|
54
54
|
validations:
|
|
55
55
|
inclusion:
|
|
56
56
|
default_error: "[%{service_class_name}] Неправильное значение в `%{internal_name}`, должно быть одним из `%{internal_inclusion}`"
|
|
@@ -81,8 +81,8 @@ ru:
|
|
|
81
81
|
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше внутреннего атрибута `%{internal_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
82
82
|
outputs:
|
|
83
83
|
undefined:
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
for_fetch: "[%{service_class_name}] Неизвестный выходящий атрибут `%{output_name}`"
|
|
85
|
+
for_assign: "[%{service_class_name}] Неизвестный выходящий атрибут `%{output_name}`"
|
|
86
86
|
validations:
|
|
87
87
|
inclusion:
|
|
88
88
|
default_error: "[%{service_class_name}] Неправильное значение в `%{output_name}`, должно быть одним из `%{output_inclusion}`"
|
|
@@ -29,9 +29,9 @@ module Servactory
|
|
|
29
29
|
if name.to_s.end_with?("=")
|
|
30
30
|
prepared_name = name.to_s.delete("=").to_sym
|
|
31
31
|
|
|
32
|
-
raise_error_for(:
|
|
32
|
+
raise_error_for(:assign, prepared_name)
|
|
33
33
|
else
|
|
34
|
-
|
|
34
|
+
fetch_with(name:) { raise_error_for(:fetch, name) }
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -42,7 +42,7 @@ module Servactory
|
|
|
42
42
|
private
|
|
43
43
|
|
|
44
44
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
|
|
45
|
-
def
|
|
45
|
+
def fetch_with(name:, &block)
|
|
46
46
|
input_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
|
|
47
47
|
|
|
48
48
|
input = @collection_of_inputs.find_by(name: input_name)
|
|
@@ -100,11 +100,15 @@ module Servactory
|
|
|
100
100
|
|
|
101
101
|
def raise_error_for(type, name)
|
|
102
102
|
message_text = @context.send(:servactory_service_info).translate(
|
|
103
|
-
"inputs.undefined
|
|
103
|
+
"inputs.undefined.for_#{type}",
|
|
104
104
|
input_name: name
|
|
105
105
|
)
|
|
106
106
|
|
|
107
|
-
raise @context.class.config.input_exception_class.new(
|
|
107
|
+
raise @context.class.config.input_exception_class.new(
|
|
108
|
+
context: @context,
|
|
109
|
+
message: message_text,
|
|
110
|
+
input_name: name
|
|
111
|
+
)
|
|
108
112
|
end
|
|
109
113
|
end
|
|
110
114
|
end
|
|
@@ -25,9 +25,9 @@ module Servactory
|
|
|
25
25
|
if name.to_s.end_with?("=")
|
|
26
26
|
prepared_name = name.to_s.delete("=").to_sym
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
assign_with(prepared_name:, value: args.pop) { raise_error_for(:assign, prepared_name) }
|
|
29
29
|
else
|
|
30
|
-
|
|
30
|
+
fetch_with(name:) { raise_error_for(:fetch, name) }
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ module Servactory
|
|
|
37
37
|
|
|
38
38
|
private
|
|
39
39
|
|
|
40
|
-
def
|
|
40
|
+
def assign_with(prepared_name:, value:, &block) # rubocop:disable Lint/UnusedMethodArgument
|
|
41
41
|
return yield unless @collection_of_internals.names.include?(prepared_name)
|
|
42
42
|
|
|
43
43
|
internal = @collection_of_internals.find_by(name: prepared_name) # ::Servactory::Internals::Internal
|
|
@@ -53,7 +53,7 @@ module Servactory
|
|
|
53
53
|
@context.send(:servactory_service_store).assign_internal(internal.name, value)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
def
|
|
56
|
+
def fetch_with(name:, &block) # rubocop:disable Metrics/AbcSize, Lint/UnusedMethodArgument
|
|
57
57
|
internal_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
|
|
58
58
|
internal = @collection_of_internals.find_by(name: internal_name)
|
|
59
59
|
|
|
@@ -70,11 +70,14 @@ module Servactory
|
|
|
70
70
|
|
|
71
71
|
def raise_error_for(type, name)
|
|
72
72
|
message_text = @context.send(:servactory_service_info).translate(
|
|
73
|
-
"internals.undefined
|
|
73
|
+
"internals.undefined.for_#{type}",
|
|
74
74
|
internal_name: name
|
|
75
75
|
)
|
|
76
76
|
|
|
77
|
-
raise @context.class.config.internal_exception_class.new(
|
|
77
|
+
raise @context.class.config.internal_exception_class.new(
|
|
78
|
+
context: @context,
|
|
79
|
+
message: message_text
|
|
80
|
+
)
|
|
78
81
|
end
|
|
79
82
|
end
|
|
80
83
|
end
|
|
@@ -25,9 +25,9 @@ module Servactory
|
|
|
25
25
|
if name.to_s.end_with?("=")
|
|
26
26
|
prepared_name = name.to_s.delete("=").to_sym
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
assign_with(prepared_name:, value: args.pop) { raise_error_for(:assign, prepared_name) }
|
|
29
29
|
else
|
|
30
|
-
|
|
30
|
+
fetch_with(name:) { raise_error_for(:fetch, name) }
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ module Servactory
|
|
|
37
37
|
|
|
38
38
|
private
|
|
39
39
|
|
|
40
|
-
def
|
|
40
|
+
def assign_with(prepared_name:, value:, &block) # rubocop:disable Lint/UnusedMethodArgument
|
|
41
41
|
return yield unless @collection_of_outputs.names.include?(prepared_name)
|
|
42
42
|
|
|
43
43
|
output = @collection_of_outputs.find_by(name: prepared_name)
|
|
@@ -53,7 +53,7 @@ module Servactory
|
|
|
53
53
|
@context.send(:servactory_service_store).assign_output(output.name, value)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
def
|
|
56
|
+
def fetch_with(name:, &block) # rubocop:disable Metrics/AbcSize, Lint/UnusedMethodArgument
|
|
57
57
|
output_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
|
|
58
58
|
output = @collection_of_outputs.find_by(name: output_name)
|
|
59
59
|
|
|
@@ -70,11 +70,14 @@ module Servactory
|
|
|
70
70
|
|
|
71
71
|
def raise_error_for(type, name)
|
|
72
72
|
message_text = @context.send(:servactory_service_info).translate(
|
|
73
|
-
"outputs.undefined
|
|
73
|
+
"outputs.undefined.for_#{type}",
|
|
74
74
|
output_name: name
|
|
75
75
|
)
|
|
76
76
|
|
|
77
|
-
raise @context.class.config.output_exception_class.new(
|
|
77
|
+
raise @context.class.config.output_exception_class.new(
|
|
78
|
+
context: @context,
|
|
79
|
+
message: message_text
|
|
80
|
+
)
|
|
78
81
|
end
|
|
79
82
|
end
|
|
80
83
|
end
|
|
@@ -48,6 +48,7 @@ module Servactory
|
|
|
48
48
|
|
|
49
49
|
def fail_input!(input_name, message:, meta: nil)
|
|
50
50
|
raise self.class.config.input_exception_class.new(
|
|
51
|
+
context: self,
|
|
51
52
|
input_name:,
|
|
52
53
|
message:,
|
|
53
54
|
meta:
|
|
@@ -56,6 +57,7 @@ module Servactory
|
|
|
56
57
|
|
|
57
58
|
def fail_internal!(internal_name, message:, meta: nil)
|
|
58
59
|
raise self.class.config.internal_exception_class.new(
|
|
60
|
+
context: self,
|
|
59
61
|
internal_name:,
|
|
60
62
|
message:,
|
|
61
63
|
meta:
|
|
@@ -64,6 +66,7 @@ module Servactory
|
|
|
64
66
|
|
|
65
67
|
def fail_output!(output_name, message:, meta: nil)
|
|
66
68
|
raise self.class.config.output_exception_class.new(
|
|
69
|
+
context: self,
|
|
67
70
|
output_name:,
|
|
68
71
|
message:,
|
|
69
72
|
meta:
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
module Servactory
|
|
4
4
|
module Exceptions
|
|
5
5
|
class Input < Base
|
|
6
|
-
attr_reader :
|
|
6
|
+
attr_reader :service,
|
|
7
|
+
:message,
|
|
7
8
|
:input_name,
|
|
8
9
|
:meta
|
|
9
10
|
|
|
10
|
-
def initialize(message:, input_name: nil, meta: nil)
|
|
11
|
+
def initialize(context:, message:, input_name: nil, meta: nil)
|
|
12
|
+
@service = context.send(:servactory_service_info)
|
|
11
13
|
@message = message
|
|
12
14
|
@input_name = input_name&.to_sym
|
|
13
15
|
@meta = meta
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
module Servactory
|
|
4
4
|
module Exceptions
|
|
5
5
|
class Internal < Base
|
|
6
|
-
attr_reader :
|
|
6
|
+
attr_reader :service,
|
|
7
|
+
:message,
|
|
7
8
|
:internal_name,
|
|
8
9
|
:meta
|
|
9
10
|
|
|
10
|
-
def initialize(message:, internal_name: nil, meta: nil)
|
|
11
|
+
def initialize(context:, message:, internal_name: nil, meta: nil)
|
|
12
|
+
@service = context.send(:servactory_service_info)
|
|
11
13
|
@message = message
|
|
12
14
|
@internal_name = internal_name&.to_sym
|
|
13
15
|
@meta = meta
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
module Servactory
|
|
4
4
|
module Exceptions
|
|
5
5
|
class Output < Base
|
|
6
|
-
attr_reader :
|
|
6
|
+
attr_reader :service,
|
|
7
|
+
:message,
|
|
7
8
|
:output_name,
|
|
8
9
|
:meta
|
|
9
10
|
|
|
10
|
-
def initialize(message:, output_name: nil, meta: nil)
|
|
11
|
+
def initialize(context:, message:, output_name: nil, meta: nil)
|
|
12
|
+
@service = context.send(:servactory_service_info)
|
|
11
13
|
@message = message
|
|
12
14
|
@output_name = output_name&.to_sym
|
|
13
15
|
@meta = meta
|
|
@@ -22,7 +22,10 @@ module Servactory
|
|
|
22
22
|
unnecessary_attributes: unnecessary_attributes.join(", ")
|
|
23
23
|
)
|
|
24
24
|
|
|
25
|
-
raise @context.class.config.input_exception_class.new(
|
|
25
|
+
raise @context.class.config.input_exception_class.new(
|
|
26
|
+
context: @context,
|
|
27
|
+
message: message_text
|
|
28
|
+
)
|
|
26
29
|
end
|
|
27
30
|
|
|
28
31
|
private
|
|
@@ -73,7 +73,10 @@ module Servactory
|
|
|
73
73
|
def raise_errors
|
|
74
74
|
return if (tmp_errors = errors.not_blank).empty?
|
|
75
75
|
|
|
76
|
-
raise @context.class.config.input_exception_class.new(
|
|
76
|
+
raise @context.class.config.input_exception_class.new(
|
|
77
|
+
context: @context,
|
|
78
|
+
message: tmp_errors.first
|
|
79
|
+
)
|
|
77
80
|
end
|
|
78
81
|
end
|
|
79
82
|
end
|
|
@@ -96,7 +96,7 @@ module Servactory
|
|
|
96
96
|
name: :types,
|
|
97
97
|
attribute: @attribute,
|
|
98
98
|
validation_class: Servactory::Maintenance::Attributes::Validations::Type,
|
|
99
|
-
original_value: Array(@options.fetch(:type)),
|
|
99
|
+
original_value: Array(@options.fetch(:type)).uniq,
|
|
100
100
|
need_for_checks: true,
|
|
101
101
|
body_fallback: nil,
|
|
102
102
|
with_advanced_mode: false
|
|
@@ -80,7 +80,7 @@ module Servactory
|
|
|
80
80
|
value = object.fetch(schema_key, nil)
|
|
81
81
|
prepared_value = prepare_value_from(schema_value:, value:, required: attribute_required)
|
|
82
82
|
|
|
83
|
-
Array(attribute_type).any? { |type| prepared_value.is_a?(type) }
|
|
83
|
+
Array(attribute_type).uniq.any? { |type| prepared_value.is_a?(type) }
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def should_be_checked_for?(object:, schema_key:, schema_value:, required:)
|
|
@@ -36,7 +36,7 @@ module Servactory
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def validate_for!(attribute:, values:, option:)
|
|
39
|
-
consists_of_types = Array(option.value)
|
|
39
|
+
consists_of_types = Array(option.value).uniq
|
|
40
40
|
|
|
41
41
|
return [false, :required] if fails_presence_validation?(attribute:, values:, consists_of_types:)
|
|
42
42
|
|
|
@@ -110,7 +110,7 @@ module Servactory
|
|
|
110
110
|
|
|
111
111
|
values = values&.flatten if values.respond_to?(:flatten)
|
|
112
112
|
|
|
113
|
-
values.filter { |value| Array(option_value).exclude?(value.class) }.map(&:class).uniq.join(", ")
|
|
113
|
+
values.filter { |value| Array(option_value).uniq.exclude?(value.class) }.map(&:class).uniq.join(", ")
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
end
|
data/lib/servactory/version.rb
CHANGED
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.9.0.
|
|
4
|
+
version: 2.9.0.rc2
|
|
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-09-
|
|
11
|
+
date: 2024-09-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|