servactory 2.12.0.rc1 → 2.12.0.rc3
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 +18 -12
- data/config/locales/ru.yml +18 -12
- data/lib/servactory/configuration/option_helpers/option_helpers_collection.rb +5 -1
- data/lib/servactory/configuration/setup.rb +9 -3
- data/lib/servactory/context/workspace/inputs.rb +0 -35
- data/lib/servactory/info/builder.rb +103 -0
- data/lib/servactory/info/dsl.rb +8 -51
- data/lib/servactory/info/result.rb +4 -4
- data/lib/servactory/inputs/dsl.rb +0 -1
- data/lib/servactory/inputs/input.rb +8 -9
- data/lib/servactory/internals/dsl.rb +0 -1
- data/lib/servactory/internals/internal.rb +5 -8
- data/lib/servactory/maintenance/attributes/option.rb +7 -13
- data/lib/servactory/maintenance/attributes/option_helper.rb +8 -2
- data/lib/servactory/maintenance/attributes/options/registrar.rb +2 -57
- data/lib/servactory/maintenance/attributes/translator/must.rb +1 -1
- data/lib/servactory/maintenance/attributes/translator/type.rb +3 -38
- data/lib/servactory/maintenance/attributes/validations/must.rb +8 -6
- data/lib/servactory/maintenance/validations/types.rb +3 -26
- data/lib/servactory/outputs/dsl.rb +0 -1
- data/lib/servactory/outputs/output.rb +5 -8
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/consists_of_matcher.rb +8 -13
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/inclusion_matcher.rb +7 -4
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/message_matcher.rb +91 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/must_matcher.rb +6 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/schema_matcher.rb +83 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matcher.rb +29 -7
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb +12 -5
- data/lib/servactory/test_kit/rspec/matchers/have_service_internal_matcher.rb +31 -7
- data/lib/servactory/tool_kit/dynamic_options/inclusion.rb +63 -0
- data/lib/servactory/tool_kit/dynamic_options/must.rb +34 -6
- data/lib/servactory/tool_kit/dynamic_options/schema.rb +193 -0
- data/lib/servactory/version.rb +1 -1
- metadata +7 -5
- data/lib/servactory/maintenance/attributes/translator/inclusion.rb +0 -26
- data/lib/servactory/maintenance/attributes/validations/inclusion.rb +0 -63
- data/lib/servactory/maintenance/validations/object_schema.rb +0 -116
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db0f437672047c90c0b10f79f55c49670ec6c18ea977f3cf0ac2ab5e0b1b5cee
|
4
|
+
data.tar.gz: 5a51217c27c4d0d21d1d2d466450295dc4c6b8fcc7254bf7b82634ffa968b03d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62a421c1ee2f2135f5d14fdc11378e05f3dda3ddf5a613af2e0809c40defacad98c3ed7ad06d6cb1c91c1333890cb31687dd8423ac2e2c5658acfc53a62a2885
|
7
|
+
data.tar.gz: 900ab23ae47cd912238476d6945ecc31f9fc43e26378bde0ff3d4e0367c1e8f703006a2d44b5704335ee7b1549ecde596be732c5a12acbabbc94d1ca717dfea0
|
data/config/locales/en.yml
CHANGED
@@ -12,8 +12,6 @@ en:
|
|
12
12
|
for_fetch: "[%{service_class_name}] Undefined input attribute `%{input_name}`"
|
13
13
|
for_assign: "[%{service_class_name}] Undefined input attribute `%{input_name}`"
|
14
14
|
validations:
|
15
|
-
inclusion:
|
16
|
-
default_error: "[%{service_class_name}] Wrong value in `%{input_name}`, must be one of `%{input_inclusion}`"
|
17
15
|
must:
|
18
16
|
default_error: "[%{service_class_name}] Input `%{input_name}` must \"%{code}\""
|
19
17
|
syntax_error: "[%{service_class_name}] Syntax error inside `%{code}` of `%{input_name}` input: %{exception_message}"
|
@@ -26,6 +24,8 @@ en:
|
|
26
24
|
default: "[%{service_class_name}] Input `%{input_name}` does not match `%{format_name}` format"
|
27
25
|
wrong_pattern: "[%{service_class_name}] Input `%{input_name}` does not match `%{format_name}` format"
|
28
26
|
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for input `%{input_name}`"
|
27
|
+
inclusion:
|
28
|
+
default: "[%{service_class_name}] Wrong value in `%{input_name}`, must be one of `%{input_inclusion}`, got `%{value}`"
|
29
29
|
min:
|
30
30
|
default: "[%{service_class_name}] Input `%{input_name}` received value `%{value}`, which is less than `%{option_value}`"
|
31
31
|
max:
|
@@ -34,14 +34,16 @@ en:
|
|
34
34
|
default: "[%{service_class_name}] Input `%{input_name}` has the value `%{value}`, which is not a multiple of `%{option_value}`"
|
35
35
|
blank: "[%{service_class_name}] Input `%{input_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
36
36
|
divided_by_0: "[%{service_class_name}] Input `%{input_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
37
|
+
schema:
|
38
|
+
wrong_type: "[%{service_class_name}] Wrong type of input `%{input_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
39
|
+
wrong_element_type: "[%{service_class_name}] Wrong type in input hash `%{input_name}`, expected `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
40
|
+
wrong_element_value: "[%{service_class_name}] Wrong value in input hash `%{input_name}`, expected value of type `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
37
41
|
required:
|
38
42
|
default_error:
|
39
43
|
default: "[%{service_class_name}] Required input `%{input_name}` is missing"
|
40
44
|
type:
|
41
45
|
default_error:
|
42
46
|
default: "[%{service_class_name}] Wrong type of input `%{input_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
43
|
-
for_hash:
|
44
|
-
wrong_element_type: "[%{service_class_name}] Wrong type in input hash `%{input_name}`, expected `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
45
47
|
tools:
|
46
48
|
find_unnecessary:
|
47
49
|
error: "[%{service_class_name}] Unexpected attributes: `%{unnecessary_attributes}`"
|
@@ -52,8 +54,6 @@ en:
|
|
52
54
|
for_fetch: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
|
53
55
|
for_assign: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
|
54
56
|
validations:
|
55
|
-
inclusion:
|
56
|
-
default_error: "[%{service_class_name}] Wrong value in `%{internal_name}`, must be one of `%{internal_inclusion}`"
|
57
57
|
must:
|
58
58
|
default_error: "[%{service_class_name}] Internal attribute `%{internal_name}` must \"%{code}\""
|
59
59
|
syntax_error: "[%{service_class_name}] Syntax error inside `%{code}` of `%{internal_name}` internal attribute: %{exception_message}"
|
@@ -66,6 +66,8 @@ en:
|
|
66
66
|
default: "[%{service_class_name}] Internal attribute `%{internal_name}` does not match `%{format_name}` format"
|
67
67
|
wrong_pattern: "[%{service_class_name}] Internal attribute `%{internal_name}` does not match `%{format_name}` format"
|
68
68
|
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for internal attribute `%{internal_name}`"
|
69
|
+
inclusion:
|
70
|
+
default: "[%{service_class_name}] Wrong value in `%{internal_name}`, must be one of `%{internal_inclusion}`, got `%{value}`"
|
69
71
|
min:
|
70
72
|
default: "[%{service_class_name}] Internal attribute `%{internal_name}` received value `%{value}`, which is less than `%{option_value}`"
|
71
73
|
max:
|
@@ -74,18 +76,18 @@ en:
|
|
74
76
|
default: "[%{service_class_name}] Internal attribute `%{internal_name}` has the value `%{value}`, which is not a multiple of `%{option_value}`"
|
75
77
|
blank: "[%{service_class_name}] Internal attribute `%{internal_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
76
78
|
divided_by_0: "[%{service_class_name}] Internal attribute `%{internal_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
79
|
+
schema:
|
80
|
+
wrong_type: "[%{service_class_name}] Wrong type of internal attribute `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
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
|
+
wrong_element_value: "[%{service_class_name}] Wrong value in internal attribute hash `%{internal_name}`, expected value of type `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
77
83
|
type:
|
78
84
|
default_error:
|
79
85
|
default: "[%{service_class_name}] Wrong type of internal attribute `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
80
|
-
for_hash:
|
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
86
|
outputs:
|
83
87
|
undefined:
|
84
88
|
for_fetch: "[%{service_class_name}] Undefined output attribute `%{output_name}`"
|
85
89
|
for_assign: "[%{service_class_name}] Undefined output attribute `%{output_name}`"
|
86
90
|
validations:
|
87
|
-
inclusion:
|
88
|
-
default_error: "[%{service_class_name}] Wrong value in `%{output_name}`, must be one of `%{output_inclusion}`"
|
89
91
|
must:
|
90
92
|
default_error: "[%{service_class_name}] Output attribute `%{output_name}` must \"%{code}\""
|
91
93
|
syntax_error: "[%{service_class_name}] Syntax error inside `%{code}` of `%{output_name}` output attribute: %{exception_message}"
|
@@ -98,6 +100,8 @@ en:
|
|
98
100
|
default: "[%{service_class_name}] Output attribute `%{output_name}` does not match `%{format_name}` format"
|
99
101
|
wrong_pattern: "[%{service_class_name}] Output attribute `%{output_name}` does not match `%{format_name}` format"
|
100
102
|
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for output attribute `%{output_name}`"
|
103
|
+
inclusion:
|
104
|
+
default: "[%{service_class_name}] Wrong value in `%{output_name}`, must be one of `%{output_inclusion}`, got `%{value}`"
|
101
105
|
min:
|
102
106
|
default: "[%{service_class_name}] Output attribute `%{output_name}` received value `%{value}`, which is less than `%{option_value}`"
|
103
107
|
max:
|
@@ -106,8 +110,10 @@ en:
|
|
106
110
|
default: "[%{service_class_name}] Output attribute `%{output_name}` has the value `%{value}`, which is not a multiple of `%{option_value}`"
|
107
111
|
blank: "[%{service_class_name}] Output attribute `%{output_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
108
112
|
divided_by_0: "[%{service_class_name}] Output attribute `%{output_name}` has an invalid value `%{option_value}` in option `%{option_name}`"
|
113
|
+
schema:
|
114
|
+
wrong_type: "[%{service_class_name}] Wrong type of output attribute `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
115
|
+
wrong_element_type: "[%{service_class_name}] Wrong type in output attribute hash `%{output_name}`, expected `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
116
|
+
wrong_element_value: "[%{service_class_name}] Wrong value in output attribute hash `%{output_name}`, expected value of type `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
109
117
|
type:
|
110
118
|
default_error:
|
111
119
|
default: "[%{service_class_name}] Wrong type of output attribute `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
112
|
-
for_hash:
|
113
|
-
wrong_element_type: "[%{service_class_name}] Wrong type in output attribute hash `%{output_name}`, expected `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
data/config/locales/ru.yml
CHANGED
@@ -12,8 +12,6 @@ ru:
|
|
12
12
|
for_fetch: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
|
13
13
|
for_assign: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
|
14
14
|
validations:
|
15
|
-
inclusion:
|
16
|
-
default_error: "[%{service_class_name}] Неправильное значение в `%{input_name}`, должно быть одним из `%{input_inclusion}`"
|
17
15
|
must:
|
18
16
|
default_error: "[%{service_class_name}] Инпут `%{input_name}` должен \"%{code}\""
|
19
17
|
syntax_error: "[%{service_class_name}] Синтаксическая ошибка внутри `%{code}` инпута `%{input_name}`: %{exception_message}"
|
@@ -26,6 +24,8 @@ ru:
|
|
26
24
|
default: "[%{service_class_name}] Инпут `%{input_name}` не соответствует формату `%{format_name}`"
|
27
25
|
wrong_pattern: "[%{service_class_name}] Инпут `%{input_name}` не соответствует формату `%{format_name}`"
|
28
26
|
unknown: "[%{service_class_name}] Указан неизвестный формат `%{format_name}` у инпута `%{input_name}`"
|
27
|
+
inclusion:
|
28
|
+
default: "[%{service_class_name}] Неправильное значение в `%{input_name}`, должно быть одним из `%{input_inclusion}`, получено `%{value}`"
|
29
29
|
min:
|
30
30
|
default: "[%{service_class_name}] Инпут `%{input_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
|
31
31
|
max:
|
@@ -34,14 +34,16 @@ ru:
|
|
34
34
|
default: "[%{service_class_name}] Инпут `%{input_name}` имеет значение `%{value}`, которое не кратно `%{option_value}`"
|
35
35
|
blank: "[%{service_class_name}] Инпут `%{input_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
36
36
|
divided_by_0: "[%{service_class_name}] Инпут `%{input_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
37
|
+
schema:
|
38
|
+
wrong_type: "[%{service_class_name}] Неправильный тип инпута `%{input_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
39
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше инпута `%{input_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
40
|
+
wrong_element_value: "[%{service_class_name}] Неправильное значение в хеше инпута `%{input_name}`, для `%{key_name}` ожидалось значение с типом `%{expected_type}`, получено `%{given_type}`"
|
37
41
|
required:
|
38
42
|
default_error:
|
39
43
|
default: "[%{service_class_name}] Обязательный инпут `%{input_name}` отсутствует"
|
40
44
|
type:
|
41
45
|
default_error:
|
42
46
|
default: "[%{service_class_name}] Неправильный тип инпута `%{input_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
43
|
-
for_hash:
|
44
|
-
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше инпута `%{input_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
45
47
|
tools:
|
46
48
|
find_unnecessary:
|
47
49
|
error: "[%{service_class_name}] Неожиданные атрибуты: `%{unnecessary_attributes}`"
|
@@ -52,8 +54,6 @@ ru:
|
|
52
54
|
for_fetch: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
|
53
55
|
for_assign: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
|
54
56
|
validations:
|
55
|
-
inclusion:
|
56
|
-
default_error: "[%{service_class_name}] Неправильное значение в `%{internal_name}`, должно быть одним из `%{internal_inclusion}`"
|
57
57
|
must:
|
58
58
|
default_error: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` должен \"%{code}\""
|
59
59
|
syntax_error: "[%{service_class_name}] Синтаксическая ошибка внутри `%{code}` внутреннего атрибута `%{internal_name}`: %{exception_message}"
|
@@ -66,6 +66,8 @@ ru:
|
|
66
66
|
default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` не соответствует формату `%{format_name}`"
|
67
67
|
wrong_pattern: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` не соответствует формату `%{format_name}`"
|
68
68
|
unknown: "[%{service_class_name}] Указан неизвестный формат `%{format_name}` у внутреннего атрибута `%{internal_name}`"
|
69
|
+
inclusion:
|
70
|
+
default: "[%{service_class_name}] Неправильное значение в `%{internal_name}`, должно быть одним из `%{internal_inclusion}`, получено `%{value}`"
|
69
71
|
min:
|
70
72
|
default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
|
71
73
|
max:
|
@@ -74,18 +76,18 @@ ru:
|
|
74
76
|
default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` имеет значение `%{value}`, которое не кратно `%{option_value}`"
|
75
77
|
blank: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
76
78
|
divided_by_0: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
79
|
+
schema:
|
80
|
+
wrong_type: "[%{service_class_name}] Неправильный тип внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
81
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше внутреннего атрибута `%{internal_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
82
|
+
wrong_element_value: "[%{service_class_name}] Неправильное значение в хеше внутреннего атрибута `%{internal_name}`, для `%{key_name}` ожидалось значение с типом `%{expected_type}`, получено `%{given_type}`"
|
77
83
|
type:
|
78
84
|
default_error:
|
79
85
|
default: "[%{service_class_name}] Неправильный тип внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
80
|
-
for_hash:
|
81
|
-
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше внутреннего атрибута `%{internal_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
82
86
|
outputs:
|
83
87
|
undefined:
|
84
88
|
for_fetch: "[%{service_class_name}] Неизвестный выходящий атрибут `%{output_name}`"
|
85
89
|
for_assign: "[%{service_class_name}] Неизвестный выходящий атрибут `%{output_name}`"
|
86
90
|
validations:
|
87
|
-
inclusion:
|
88
|
-
default_error: "[%{service_class_name}] Неправильное значение в `%{output_name}`, должно быть одним из `%{output_inclusion}`"
|
89
91
|
must:
|
90
92
|
default_error: "[%{service_class_name}] Выходящий атрибут `%{output_name}` должен \"%{code}\""
|
91
93
|
syntax_error: "[%{service_class_name}] Синтаксическая ошибка внутри `%{code}` выходящего атрибута `%{output_name}`: %{exception_message}"
|
@@ -98,6 +100,8 @@ ru:
|
|
98
100
|
default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` не соответствует формату `%{format_name}`"
|
99
101
|
wrong_pattern: "[%{service_class_name}] Выходящий атрибут `%{output_name}` не соответствует формату `%{format_name}`"
|
100
102
|
unknown: "[%{service_class_name}] Указан неизвестный формат `%{format_name}` у выходящего атрибута `%{output_name}`"
|
103
|
+
inclusion:
|
104
|
+
default: "[%{service_class_name}] Неправильное значение в `%{output_name}`, должно быть одним из `%{output_inclusion}`, получено `%{value}`"
|
101
105
|
min:
|
102
106
|
default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
|
103
107
|
max:
|
@@ -106,8 +110,10 @@ ru:
|
|
106
110
|
default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` имеет значение `%{value}`, которое не кратно `%{option_value}`"
|
107
111
|
blank: "[%{service_class_name}] Выходящий атрибут `%{output_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
108
112
|
divided_by_0: "[%{service_class_name}] Выходящий атрибут `%{output_name}` имеет недопустимое значение `%{option_value}` в опции `%{option_name}`"
|
113
|
+
schema:
|
114
|
+
wrong_type: "[%{service_class_name}] Неправильный тип выходящего атрибута `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
115
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше выходящего атрибута `%{output_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
116
|
+
wrong_element_value: "[%{service_class_name}] Неправильное значение в хеше выходящего атрибута `%{output_name}`, для `%{key_name}` ожидалось значение с типом `%{expected_type}`, получено `%{given_type}`"
|
109
117
|
type:
|
110
118
|
default_error:
|
111
119
|
default: "[%{service_class_name}] Неправильный тип выходящего атрибута `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
112
|
-
for_hash:
|
113
|
-
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше выходящего атрибута `%{output_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
@@ -5,12 +5,16 @@ module Servactory
|
|
5
5
|
module OptionHelpers
|
6
6
|
class OptionHelpersCollection
|
7
7
|
extend Forwardable
|
8
|
-
def_delegators :@collection, :<<, :find, :merge
|
8
|
+
def_delegators :@collection, :<<, :filter, :map, :find, :merge
|
9
9
|
|
10
10
|
def initialize(collection = Set.new)
|
11
11
|
@collection = collection
|
12
12
|
end
|
13
13
|
|
14
|
+
def dynamic_options
|
15
|
+
OptionHelpersCollection.new(filter(&:dynamic_option?))
|
16
|
+
end
|
17
|
+
|
14
18
|
def find_by(name:)
|
15
19
|
find { |helper| helper.name == name }
|
16
20
|
end
|
@@ -71,19 +71,25 @@ module Servactory
|
|
71
71
|
def default_input_option_helpers
|
72
72
|
Set[
|
73
73
|
Servactory::Maintenance::Attributes::OptionHelper.new(name: :optional, equivalent: { required: false }),
|
74
|
-
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:)
|
74
|
+
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:),
|
75
|
+
Servactory::ToolKit::DynamicOptions::Schema.use(default_hash_mode_class_names:),
|
76
|
+
Servactory::ToolKit::DynamicOptions::Inclusion.use
|
75
77
|
]
|
76
78
|
end
|
77
79
|
|
78
80
|
def default_internal_option_helpers
|
79
81
|
Set[
|
80
|
-
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:)
|
82
|
+
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:),
|
83
|
+
Servactory::ToolKit::DynamicOptions::Schema.use(default_hash_mode_class_names:),
|
84
|
+
Servactory::ToolKit::DynamicOptions::Inclusion.use
|
81
85
|
]
|
82
86
|
end
|
83
87
|
|
84
88
|
def default_output_option_helpers
|
85
89
|
Set[
|
86
|
-
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:)
|
90
|
+
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names:),
|
91
|
+
Servactory::ToolKit::DynamicOptions::Schema.use(default_hash_mode_class_names:),
|
92
|
+
Servactory::ToolKit::DynamicOptions::Inclusion.use
|
87
93
|
]
|
88
94
|
end
|
89
95
|
end
|
@@ -51,10 +51,6 @@ module Servactory
|
|
51
51
|
input_value = @context.send(:servactory_service_warehouse).fetch_input(input.name)
|
52
52
|
input_value = input.default if input.optional? && input_value.blank?
|
53
53
|
|
54
|
-
if input.hash_mode? && (tmp_schema = input.schema.fetch(:is)).present?
|
55
|
-
input_value = prepare_hash_values_inside(object: input_value, schema: tmp_schema)
|
56
|
-
end
|
57
|
-
|
58
54
|
input_prepare = input.prepare.fetch(:in, nil)
|
59
55
|
input_value = input_prepare.call(value: input_value) if input_prepare.present?
|
60
56
|
|
@@ -66,37 +62,6 @@ module Servactory
|
|
66
62
|
end
|
67
63
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
|
68
64
|
|
69
|
-
def prepare_hash_values_inside(object:, schema:) # rubocop:disable Metrics/MethodLength
|
70
|
-
return object unless object.respond_to?(:fetch)
|
71
|
-
|
72
|
-
schema.to_h do |schema_key, schema_value|
|
73
|
-
attribute_type = schema_value.fetch(:type, String)
|
74
|
-
|
75
|
-
result =
|
76
|
-
if attribute_type == Hash
|
77
|
-
prepare_hash_values_inside(
|
78
|
-
object: object.fetch(schema_key, {}),
|
79
|
-
schema: schema_value.except(*RESERVED_ATTRIBUTES)
|
80
|
-
)
|
81
|
-
else
|
82
|
-
fetch_hash_values_from(
|
83
|
-
value: object.fetch(schema_key, {}),
|
84
|
-
schema_value:,
|
85
|
-
attribute_required: schema_value.fetch(:required, true)
|
86
|
-
)
|
87
|
-
end
|
88
|
-
|
89
|
-
[schema_key, result]
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def fetch_hash_values_from(value:, schema_value:, attribute_required:)
|
94
|
-
return value if attribute_required
|
95
|
-
return value if value.present?
|
96
|
-
|
97
|
-
schema_value.fetch(:default, nil)
|
98
|
-
end
|
99
|
-
|
100
65
|
def raise_error_for(type, name)
|
101
66
|
message_text = @context.send(:servactory_service_info).translate(
|
102
67
|
"inputs.undefined.for_#{type}",
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module Info
|
5
|
+
class Builder
|
6
|
+
attr_reader :inputs,
|
7
|
+
:internals,
|
8
|
+
:outputs
|
9
|
+
|
10
|
+
def self.build(...)
|
11
|
+
new.build(...)
|
12
|
+
end
|
13
|
+
|
14
|
+
def build(collection_of_inputs:, collection_of_internals:, collection_of_outputs:, config:)
|
15
|
+
dynamic_options = config.input_option_helpers.dynamic_options
|
16
|
+
|
17
|
+
build_inputs_with(collection_of_inputs:, dynamic_options:)
|
18
|
+
build_internals_with(collection_of_internals:, dynamic_options:)
|
19
|
+
build_outputs_with(collection_of_outputs:, dynamic_options:)
|
20
|
+
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def build_inputs_with(collection_of_inputs:, dynamic_options:)
|
27
|
+
@inputs = collection_of_inputs.to_h do |input|
|
28
|
+
options = build_options_for(input, dynamic_options)
|
29
|
+
options = enrich_options_for(input, options)
|
30
|
+
|
31
|
+
options[:required] = input.required
|
32
|
+
options[:default] = input.default
|
33
|
+
|
34
|
+
[
|
35
|
+
input.name,
|
36
|
+
options
|
37
|
+
]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_internals_with(collection_of_internals:, dynamic_options:)
|
42
|
+
@internals = collection_of_internals.to_h do |internal|
|
43
|
+
options = build_options_for(internal, dynamic_options)
|
44
|
+
options = enrich_options_for(internal, options)
|
45
|
+
|
46
|
+
[
|
47
|
+
internal.name,
|
48
|
+
options
|
49
|
+
]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def build_outputs_with(collection_of_outputs:, dynamic_options:)
|
54
|
+
@outputs = collection_of_outputs.to_h do |output|
|
55
|
+
options = build_options_for(output, dynamic_options)
|
56
|
+
options = enrich_options_for(output, options)
|
57
|
+
|
58
|
+
[
|
59
|
+
output.name,
|
60
|
+
options
|
61
|
+
]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
##########################################################################
|
66
|
+
|
67
|
+
def build_options_for(attribute, dynamic_options)
|
68
|
+
attribute.options.to_h do |key, value|
|
69
|
+
dynamic_option = dynamic_options.find_by(name: key)
|
70
|
+
|
71
|
+
next [nil, nil] if dynamic_option.nil?
|
72
|
+
|
73
|
+
body_key = dynamic_option.meta.fetch(:body_key)
|
74
|
+
|
75
|
+
option = build_option_from(body_key:, value:)
|
76
|
+
|
77
|
+
[
|
78
|
+
dynamic_option.name,
|
79
|
+
option
|
80
|
+
]
|
81
|
+
end.compact
|
82
|
+
end
|
83
|
+
|
84
|
+
def build_option_from(body_key:, value:)
|
85
|
+
{
|
86
|
+
body_key => value.is_a?(Hash) ? value.fetch(body_key, value) : value,
|
87
|
+
message: value.is_a?(Hash) ? value.fetch(:message, nil) : nil
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
def enrich_options_for(attribute, options)
|
92
|
+
actor = attribute.class::Actor.new(attribute)
|
93
|
+
must = attribute.collection_of_options.find_by(name: :must)
|
94
|
+
|
95
|
+
options.merge(
|
96
|
+
actor:,
|
97
|
+
types: attribute.types,
|
98
|
+
must: must.body
|
99
|
+
)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/servactory/info/dsl.rb
CHANGED
@@ -8,58 +8,15 @@ module Servactory
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module ClassMethods
|
11
|
-
def info
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
[
|
19
|
-
input.name,
|
20
|
-
{
|
21
|
-
actor:,
|
22
|
-
types: input.types,
|
23
|
-
required: input.required,
|
24
|
-
default: input.default,
|
25
|
-
inclusion: inclusion.body,
|
26
|
-
must: must.body
|
27
|
-
}
|
28
|
-
]
|
29
|
-
end,
|
30
|
-
|
31
|
-
internals: collection_of_internals.to_h do |internal|
|
32
|
-
actor = internal.class::Actor.new(internal)
|
33
|
-
inclusion = internal.collection_of_options.find_by(name: :inclusion)
|
34
|
-
must = internal.collection_of_options.find_by(name: :must)
|
35
|
-
|
36
|
-
[
|
37
|
-
internal.name,
|
38
|
-
{
|
39
|
-
actor:,
|
40
|
-
types: internal.types,
|
41
|
-
inclusion: inclusion.body,
|
42
|
-
must: must.body
|
43
|
-
}
|
44
|
-
]
|
45
|
-
end,
|
46
|
-
|
47
|
-
outputs: collection_of_outputs.to_h do |output|
|
48
|
-
actor = output.class::Actor.new(output)
|
49
|
-
inclusion = output.collection_of_options.find_by(name: :inclusion)
|
50
|
-
must = output.collection_of_options.find_by(name: :must)
|
51
|
-
|
52
|
-
[
|
53
|
-
output.name,
|
54
|
-
{
|
55
|
-
actor:,
|
56
|
-
types: output.types,
|
57
|
-
inclusion: inclusion.body,
|
58
|
-
must: must.body
|
59
|
-
}
|
60
|
-
]
|
61
|
-
end
|
11
|
+
def info
|
12
|
+
builder = Builder.build(
|
13
|
+
collection_of_inputs:,
|
14
|
+
collection_of_internals:,
|
15
|
+
collection_of_outputs:,
|
16
|
+
config:
|
62
17
|
)
|
18
|
+
|
19
|
+
Result.new(builder)
|
63
20
|
end
|
64
21
|
end
|
65
22
|
end
|
@@ -7,10 +7,10 @@ module Servactory
|
|
7
7
|
:internals,
|
8
8
|
:outputs
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
@inputs = inputs
|
12
|
-
@internals = internals
|
13
|
-
@outputs = outputs
|
10
|
+
def initialize(builder)
|
11
|
+
@inputs = builder.inputs
|
12
|
+
@internals = builder.internals
|
13
|
+
@outputs = builder.outputs
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -7,13 +7,15 @@ module Servactory
|
|
7
7
|
attr_reader :name,
|
8
8
|
:internal_name,
|
9
9
|
:types,
|
10
|
-
:
|
10
|
+
:default,
|
11
|
+
:options
|
11
12
|
|
12
|
-
def initialize(input) # rubocop:disable Metrics/MethodLength
|
13
|
+
def initialize(input) # rubocop:disable Metrics/MethodLength
|
13
14
|
@name = input.name
|
14
15
|
@internal_name = input.internal_name
|
15
16
|
@types = input.types
|
16
|
-
@
|
17
|
+
@default = input.default
|
18
|
+
@options = input.options
|
17
19
|
|
18
20
|
define_singleton_method(:system_name) { input.system_name }
|
19
21
|
define_singleton_method(:i18n_name) { input.i18n_name }
|
@@ -28,20 +30,19 @@ module Servactory
|
|
28
30
|
|
29
31
|
attr_reader :name,
|
30
32
|
:internal_name,
|
31
|
-
:collection_of_options
|
33
|
+
:collection_of_options,
|
34
|
+
:options
|
32
35
|
|
33
36
|
# rubocop:disable Style/KeywordParametersOrder
|
34
37
|
def initialize(
|
35
38
|
name,
|
36
39
|
*helpers,
|
37
40
|
as: nil,
|
38
|
-
hash_mode_class_names:,
|
39
41
|
option_helpers:,
|
40
42
|
**options
|
41
43
|
)
|
42
44
|
@name = name
|
43
45
|
@internal_name = as.presence || name
|
44
|
-
@hash_mode_class_names = hash_mode_class_names
|
45
46
|
@option_helpers = option_helpers
|
46
47
|
|
47
48
|
register_options(helpers:, options:)
|
@@ -68,19 +69,17 @@ module Servactory
|
|
68
69
|
|
69
70
|
options_registrar = Servactory::Maintenance::Attributes::Options::Registrar.register(
|
70
71
|
attribute: self,
|
71
|
-
hash_mode_class_names: @hash_mode_class_names,
|
72
72
|
options:,
|
73
73
|
features: {
|
74
74
|
required: true,
|
75
75
|
types: true,
|
76
76
|
default: true,
|
77
|
-
hash: true,
|
78
|
-
inclusion: true,
|
79
77
|
must: true,
|
80
78
|
prepare: true
|
81
79
|
}
|
82
80
|
)
|
83
81
|
|
82
|
+
@options = options
|
84
83
|
@collection_of_options = options_registrar.collection
|
85
84
|
end
|
86
85
|
|
@@ -6,12 +6,12 @@ module Servactory
|
|
6
6
|
class Actor
|
7
7
|
attr_reader :name,
|
8
8
|
:types,
|
9
|
-
:
|
9
|
+
:options
|
10
10
|
|
11
11
|
def initialize(internal)
|
12
12
|
@name = internal.name
|
13
13
|
@types = internal.types
|
14
|
-
@
|
14
|
+
@options = internal.options
|
15
15
|
|
16
16
|
define_singleton_method(:system_name) { internal.system_name }
|
17
17
|
define_singleton_method(:i18n_name) { internal.i18n_name }
|
@@ -23,17 +23,16 @@ module Servactory
|
|
23
23
|
end
|
24
24
|
|
25
25
|
attr_reader :name,
|
26
|
-
:collection_of_options
|
26
|
+
:collection_of_options,
|
27
|
+
:options
|
27
28
|
|
28
29
|
def initialize(
|
29
30
|
name,
|
30
31
|
*helpers,
|
31
|
-
hash_mode_class_names:,
|
32
32
|
option_helpers:,
|
33
33
|
**options
|
34
34
|
)
|
35
35
|
@name = name
|
36
|
-
@hash_mode_class_names = hash_mode_class_names
|
37
36
|
@option_helpers = option_helpers
|
38
37
|
|
39
38
|
register_options(helpers:, options:)
|
@@ -59,16 +58,14 @@ module Servactory
|
|
59
58
|
|
60
59
|
options_registrar = Servactory::Maintenance::Attributes::Options::Registrar.register(
|
61
60
|
attribute: self,
|
62
|
-
hash_mode_class_names: @hash_mode_class_names,
|
63
61
|
options:,
|
64
62
|
features: {
|
65
63
|
types: true,
|
66
|
-
hash: true,
|
67
|
-
inclusion: true,
|
68
64
|
must: true
|
69
65
|
}
|
70
66
|
)
|
71
67
|
|
68
|
+
@options = options
|
72
69
|
@collection_of_options = options_registrar.collection
|
73
70
|
end
|
74
71
|
|