servactory 2.6.0.rc4 → 2.6.0.rc5
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 -3
- data/config/locales/ru.yml +6 -3
- data/lib/servactory/configuration/class_names_collection.rb +14 -0
- data/lib/servactory/configuration/dsl.rb +2 -0
- data/lib/servactory/configuration/factory.rb +4 -0
- data/lib/servactory/configuration/setup.rb +11 -3
- data/lib/servactory/tool_kit/dynamic_options/consists_of.rb +33 -13
- data/lib/servactory/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 644c141dd6e3bdee996ffc4aad56a6e9b472ad964406923cc14fd1185541e2ae
|
|
4
|
+
data.tar.gz: 4036bed062dd8717f6288c72c498cca4a2a91401154a23266148a42cac2aa10a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '09e7437eedd68dc0c14a98ec4c6c5c922483fc9e3924425a0478bb8d1404c36ef0531fb2adb9d2094ff7fa20633f92fb44fa8bd5588c6d7b28372371fe709af8'
|
|
7
|
+
data.tar.gz: ac82354cffdb531261d50a12f0a54fb79bca2474fcf00b9851769ebcbe2a08c9c46fbb8edfb07bb8964142adac85e901d6773082001ffc0248746e8c448b77a1
|
data/config/locales/en.yml
CHANGED
|
@@ -20,7 +20,8 @@ en:
|
|
|
20
20
|
dynamic_options:
|
|
21
21
|
consists_of:
|
|
22
22
|
required: "[%{service_class_name}] Required element in input collection `%{input_name}` is missing"
|
|
23
|
-
wrong_type: "[%{service_class_name}] Wrong
|
|
23
|
+
wrong_type: "[%{service_class_name}] Wrong input collection type `%{input_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
24
|
+
wrong_element_type: "[%{service_class_name}] Wrong element type in input collection `%{input_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
24
25
|
format:
|
|
25
26
|
default: "[%{service_class_name}] Input `%{input_name}` does not match `%{format_name}` format"
|
|
26
27
|
wrong_pattern: "[%{service_class_name}] Input `%{input_name}` does not match `%{format_name}` format"
|
|
@@ -55,7 +56,8 @@ en:
|
|
|
55
56
|
dynamic_options:
|
|
56
57
|
consists_of:
|
|
57
58
|
required: "[%{service_class_name}] Required element in internal attribute collection `%{internal_name}` is missing"
|
|
58
|
-
wrong_type: "[%{service_class_name}] Wrong
|
|
59
|
+
wrong_type: "[%{service_class_name}] Wrong internal attribute collection type `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
60
|
+
wrong_element_type: "[%{service_class_name}] Wrong element type in internal attribute collection `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
59
61
|
format:
|
|
60
62
|
default: "[%{service_class_name}] Internal attribute `%{internal_name}` does not match `%{format_name}` format"
|
|
61
63
|
wrong_pattern: "[%{service_class_name}] Internal attribute `%{internal_name}` does not match `%{format_name}` format"
|
|
@@ -82,7 +84,8 @@ en:
|
|
|
82
84
|
dynamic_options:
|
|
83
85
|
consists_of:
|
|
84
86
|
required: "[%{service_class_name}] Required element in output attribute collection `%{output_name}` is missing"
|
|
85
|
-
wrong_type: "[%{service_class_name}] Wrong
|
|
87
|
+
wrong_type: "[%{service_class_name}] Wrong output attribute collection type `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
88
|
+
wrong_element_type: "[%{service_class_name}] Wrong element type in output attribute collection `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
86
89
|
format:
|
|
87
90
|
default: "[%{service_class_name}] Output attribute `%{output_name}` does not match `%{format_name}` format"
|
|
88
91
|
wrong_pattern: "[%{service_class_name}] Output attribute `%{output_name}` does not match `%{format_name}` format"
|
data/config/locales/ru.yml
CHANGED
|
@@ -20,7 +20,8 @@ ru:
|
|
|
20
20
|
dynamic_options:
|
|
21
21
|
consists_of:
|
|
22
22
|
required: "[%{service_class_name}] Отсутствует обязательный элемент в коллекции инпута `%{input_name}`"
|
|
23
|
-
wrong_type: "[%{service_class_name}] Неправильный тип
|
|
23
|
+
wrong_type: "[%{service_class_name}] Неправильный тип коллекции инпута `%{input_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
24
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип элемента в коллекции инпута `%{input_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
24
25
|
format:
|
|
25
26
|
default: "[%{service_class_name}] Инпут `%{input_name}` не соответствует формату `%{format_name}`"
|
|
26
27
|
wrong_pattern: "[%{service_class_name}] Инпут `%{input_name}` не соответствует формату `%{format_name}`"
|
|
@@ -55,7 +56,8 @@ ru:
|
|
|
55
56
|
dynamic_options:
|
|
56
57
|
consists_of:
|
|
57
58
|
required: "[%{service_class_name}] Отсутствует обязательный элемент в коллекции внутреннего атрибута `%{internal_name}`"
|
|
58
|
-
wrong_type: "[%{service_class_name}] Неправильный тип
|
|
59
|
+
wrong_type: "[%{service_class_name}] Неправильный тип коллекции внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
60
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип элемента в коллекции внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
59
61
|
format:
|
|
60
62
|
default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` не соответствует формату `%{format_name}`"
|
|
61
63
|
wrong_pattern: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` не соответствует формату `%{format_name}`"
|
|
@@ -82,7 +84,8 @@ ru:
|
|
|
82
84
|
dynamic_options:
|
|
83
85
|
consists_of:
|
|
84
86
|
required: "[%{service_class_name}] Отсутствует обязательный элемент в коллекции выходящего атрибута `%{output_name}`"
|
|
85
|
-
wrong_type: "[%{service_class_name}] Неправильный тип
|
|
87
|
+
wrong_type: "[%{service_class_name}] Неправильный тип коллекции выходящего атрибута `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
88
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип элемента в коллекции выходящего атрибута `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
86
89
|
format:
|
|
87
90
|
default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` не соответствует формату `%{format_name}`"
|
|
88
91
|
wrong_pattern: "[%{service_class_name}] Выходящий атрибут `%{output_name}` не соответствует формату `%{format_name}`"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Servactory
|
|
4
|
+
module Configuration
|
|
5
|
+
class ClassNamesCollection
|
|
6
|
+
extend Forwardable
|
|
7
|
+
def_delegators :@collection, :merge, :intersection
|
|
8
|
+
|
|
9
|
+
def initialize(collection)
|
|
10
|
+
@collection = collection
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -20,6 +20,8 @@ module Servactory
|
|
|
20
20
|
|
|
21
21
|
child.config.result_class = config.result_class
|
|
22
22
|
|
|
23
|
+
child.config.collection_mode_class_names = config.collection_mode_class_names
|
|
24
|
+
|
|
23
25
|
child.config.input_option_helpers = config.input_option_helpers
|
|
24
26
|
child.config.internal_option_helpers = config.internal_option_helpers
|
|
25
27
|
child.config.output_option_helpers = config.output_option_helpers
|
|
@@ -69,6 +69,10 @@ module Servactory
|
|
|
69
69
|
raise_error_about_wrong_result_class_with(:result_class, result_class)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
def collection_mode_class_names(collection_mode_class_names)
|
|
73
|
+
@config.collection_mode_class_names.merge(collection_mode_class_names)
|
|
74
|
+
end
|
|
75
|
+
|
|
72
76
|
def hash_mode_class_names(hash_mode_class_names)
|
|
73
77
|
@config.hash_mode_class_names.merge(hash_mode_class_names)
|
|
74
78
|
end
|
|
@@ -9,6 +9,7 @@ module Servactory
|
|
|
9
9
|
:success_class,
|
|
10
10
|
:failure_class,
|
|
11
11
|
:result_class,
|
|
12
|
+
:collection_mode_class_names,
|
|
12
13
|
:hash_mode_class_names,
|
|
13
14
|
:input_option_helpers,
|
|
14
15
|
:internal_option_helpers,
|
|
@@ -29,6 +30,9 @@ module Servactory
|
|
|
29
30
|
|
|
30
31
|
@result_class = Servactory::Result
|
|
31
32
|
|
|
33
|
+
@collection_mode_class_names =
|
|
34
|
+
Servactory::Configuration::ClassNamesCollection.new(default_collection_mode_class_names)
|
|
35
|
+
|
|
32
36
|
@hash_mode_class_names =
|
|
33
37
|
Servactory::Maintenance::HashMode::ClassNamesCollection.new(default_hash_mode_class_names)
|
|
34
38
|
|
|
@@ -56,6 +60,10 @@ module Servactory
|
|
|
56
60
|
|
|
57
61
|
private
|
|
58
62
|
|
|
63
|
+
def default_collection_mode_class_names
|
|
64
|
+
Set[Array, Set]
|
|
65
|
+
end
|
|
66
|
+
|
|
59
67
|
def default_hash_mode_class_names
|
|
60
68
|
Set[Hash]
|
|
61
69
|
end
|
|
@@ -63,19 +71,19 @@ module Servactory
|
|
|
63
71
|
def default_input_option_helpers
|
|
64
72
|
Set[
|
|
65
73
|
Servactory::Maintenance::Attributes::OptionHelper.new(name: :optional, equivalent: { required: false }),
|
|
66
|
-
Servactory::ToolKit::DynamicOptions::ConsistsOf.
|
|
74
|
+
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names: collection_mode_class_names)
|
|
67
75
|
]
|
|
68
76
|
end
|
|
69
77
|
|
|
70
78
|
def default_internal_option_helpers
|
|
71
79
|
Set[
|
|
72
|
-
Servactory::ToolKit::DynamicOptions::ConsistsOf.
|
|
80
|
+
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names: collection_mode_class_names)
|
|
73
81
|
]
|
|
74
82
|
end
|
|
75
83
|
|
|
76
84
|
def default_output_option_helpers
|
|
77
85
|
Set[
|
|
78
|
-
Servactory::ToolKit::DynamicOptions::ConsistsOf.
|
|
86
|
+
Servactory::ToolKit::DynamicOptions::ConsistsOf.use(collection_mode_class_names: collection_mode_class_names)
|
|
79
87
|
]
|
|
80
88
|
end
|
|
81
89
|
end
|
|
@@ -4,11 +4,14 @@ module Servactory
|
|
|
4
4
|
module ToolKit
|
|
5
5
|
module DynamicOptions
|
|
6
6
|
class ConsistsOf < Must
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
def self.use(option_name = :consists_of, collection_mode_class_names:)
|
|
8
|
+
instance = new(option_name, :type, false)
|
|
9
|
+
instance.assign(collection_mode_class_names)
|
|
10
|
+
instance.must(:consists_of)
|
|
11
|
+
end
|
|
9
12
|
|
|
10
|
-
def
|
|
11
|
-
|
|
13
|
+
def assign(collection_mode_class_names)
|
|
14
|
+
@collection_mode_class_names = collection_mode_class_names
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
def condition_for_input_with(input:, value:, option:)
|
|
@@ -25,23 +28,38 @@ module Servactory
|
|
|
25
28
|
|
|
26
29
|
def common_condition_with(attribute:, value:, option:)
|
|
27
30
|
return true if option.value == false
|
|
28
|
-
return false if
|
|
29
|
-
|
|
31
|
+
return [false, :wrong_type] if @collection_mode_class_names.intersection(attribute.types).empty?
|
|
32
|
+
|
|
33
|
+
values = value.respond_to?(:flatten) ? value&.flatten : value
|
|
30
34
|
|
|
31
|
-
validate_for!(values:
|
|
35
|
+
validate_for!(attribute: attribute, values: values, option: option)
|
|
32
36
|
end
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
39
|
+
def validate_for!(attribute:, values:, option:)
|
|
35
40
|
consists_of_types = Array(option.value)
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
if !consists_of_types.include?(NilClass) && !values&.all?(&:present?) &&
|
|
43
|
+
(
|
|
44
|
+
(
|
|
45
|
+
attribute.input? && (
|
|
46
|
+
(values.blank? && attribute.required?) ||
|
|
47
|
+
(values.present? && attribute.required?)
|
|
48
|
+
)
|
|
49
|
+
) || attribute.internal? || attribute.output?
|
|
50
|
+
)
|
|
51
|
+
return [false, :required]
|
|
52
|
+
end
|
|
38
53
|
|
|
39
|
-
return true if values.
|
|
54
|
+
return true if values.blank? && attribute.input? && attribute.optional?
|
|
55
|
+
|
|
56
|
+
return true if values.all? do |value|
|
|
40
57
|
consists_of_types.include?(value.class)
|
|
41
58
|
end
|
|
42
59
|
|
|
43
|
-
[false, :
|
|
60
|
+
[false, :wrong_element_type]
|
|
44
61
|
end
|
|
62
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
45
63
|
|
|
46
64
|
########################################################################
|
|
47
65
|
|
|
@@ -85,9 +103,11 @@ module Servactory
|
|
|
85
103
|
end
|
|
86
104
|
|
|
87
105
|
def given_type_for(values:, option_value:)
|
|
88
|
-
return
|
|
106
|
+
return "NilClass" if values.nil?
|
|
107
|
+
|
|
108
|
+
values = values&.flatten if values.respond_to?(:flatten)
|
|
89
109
|
|
|
90
|
-
values.
|
|
110
|
+
values.filter { |value| Array(option_value).exclude?(value.class) }.map(&:class).uniq.join(", ")
|
|
91
111
|
end
|
|
92
112
|
end
|
|
93
113
|
end
|
data/lib/servactory/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: servactory
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.6.0.
|
|
4
|
+
version: 2.6.0.rc5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anton Sokolov
|
|
@@ -256,6 +256,7 @@ files:
|
|
|
256
256
|
- lib/servactory/actions/tools/runner.rb
|
|
257
257
|
- lib/servactory/actions/workspace.rb
|
|
258
258
|
- lib/servactory/base.rb
|
|
259
|
+
- lib/servactory/configuration/class_names_collection.rb
|
|
259
260
|
- lib/servactory/configuration/dsl.rb
|
|
260
261
|
- lib/servactory/configuration/factory.rb
|
|
261
262
|
- lib/servactory/configuration/setup.rb
|