servactory 2.9.0.rc1 → 2.9.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- 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 +10 -2
- data/lib/servactory/exceptions/internal.rb +10 -2
- data/lib/servactory/exceptions/output.rb +10 -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: db731a222e915d37026b04c38cf65d916f3e2c9d7f16b39e7802b63e4a2e62a1
|
4
|
+
data.tar.gz: 533e74fc14b689fedf92f8d0cbdca8d910bb2e80525b1bb4888b0c09f67f398f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dcc8e601a71bc9e2b2664c4be96762bf36f39cdf385ee40c79a968d67b5a0c03483ae7d048e17613abb08598acbf73e64b1caaf5f854929f9c98a3a3c5dad2b
|
7
|
+
data.tar.gz: 15f59437a0fdb279e24f0d09a7f279d3849379cc7547a8338e826fe158804e1ff6edb1662b2c126cc4c4a3c31f04d174c075f06de4938256e50c4bacc1bb9977
|
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,17 +3,25 @@
|
|
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
|
+
@context = context
|
13
|
+
@service = context.send(:servactory_service_info)
|
11
14
|
@message = message
|
12
15
|
@input_name = input_name&.to_sym
|
13
16
|
@meta = meta
|
14
17
|
|
15
18
|
super(message)
|
16
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# API: Datory
|
24
|
+
attr_reader :context
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -3,17 +3,25 @@
|
|
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
|
+
@context = context
|
13
|
+
@service = context.send(:servactory_service_info)
|
11
14
|
@message = message
|
12
15
|
@internal_name = internal_name&.to_sym
|
13
16
|
@meta = meta
|
14
17
|
|
15
18
|
super(message)
|
16
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# API: Datory
|
24
|
+
attr_reader :context
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -3,17 +3,25 @@
|
|
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
|
+
@context = context
|
13
|
+
@service = context.send(:servactory_service_info)
|
11
14
|
@message = message
|
12
15
|
@output_name = output_name&.to_sym
|
13
16
|
@meta = meta
|
14
17
|
|
15
18
|
super(message)
|
16
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# API: Datory
|
24
|
+
attr_reader :context
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -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.rc3
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|