servactory 2.6.0 → 2.6.2
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 +1 -1
- data/config/locales/ru.yml +4 -3
- data/lib/generators/servactory/templates/services/application_service/base.rb +2 -0
- data/lib/servactory/info/dsl.rb +6 -6
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb +2 -2
- data/lib/servactory/tool_kit/dynamic_options/format.rb +16 -1
- 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: 0ce5565f3e907fc4f2739acfd68389a9d10bfc1a0dbfdcafe81692d631c4ec96
|
4
|
+
data.tar.gz: 2e7dae944a0fd40907dbe2cfdb2593ee6f43e1d4112641643f917c76fbe8a90b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8ff6b069089defb72497b5431ac790a59b019253fc10f2f6c5562184b6f42bb5457a28264efd19f3e1d5f1801c28e068f0c4315ddbaec8e8155cad3e13855b6
|
7
|
+
data.tar.gz: 6552a2df9438f6e7b3c9737ae814d61d835446396ad9ef0777eb805680923aa47e0b90de15662388dcde3baab3ae0640df35d79223f656f1335accbdcde64266
|
data/config/locales/en.yml
CHANGED
@@ -61,7 +61,7 @@ en:
|
|
61
61
|
format:
|
62
62
|
default: "[%{service_class_name}] Internal attribute `%{internal_name}` does not match `%{format_name}` format"
|
63
63
|
wrong_pattern: "[%{service_class_name}] Internal attribute `%{internal_name}` does not match `%{format_name}` format"
|
64
|
-
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for
|
64
|
+
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for internal attribute `%{internal_name}`"
|
65
65
|
min:
|
66
66
|
default: "[%{service_class_name}] Internal attribute `%{internal_name}` received value `%{value}`, which is less than `%{option_value}`"
|
67
67
|
max:
|
data/config/locales/ru.yml
CHANGED
@@ -95,6 +95,7 @@ ru:
|
|
95
95
|
max:
|
96
96
|
default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` получил значение `%{value}`, которое больше `%{option_value}`"
|
97
97
|
type:
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
default_error:
|
99
|
+
default: "[%{service_class_name}] Неправильный тип выходящего атрибута `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
100
|
+
for_hash:
|
101
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше выходящего атрибута `%{output_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
data/lib/servactory/info/dsl.rb
CHANGED
@@ -11,14 +11,14 @@ module Servactory
|
|
11
11
|
def info # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
12
12
|
Servactory::Info::Result.new(
|
13
13
|
inputs: collection_of_inputs.to_h do |input|
|
14
|
-
|
14
|
+
actor = input.class::Actor.new(input)
|
15
15
|
inclusion = input.collection_of_options.find_by(name: :inclusion)
|
16
16
|
must = input.collection_of_options.find_by(name: :must)
|
17
17
|
|
18
18
|
[
|
19
19
|
input.name,
|
20
20
|
{
|
21
|
-
|
21
|
+
actor: actor,
|
22
22
|
types: input.types,
|
23
23
|
required: input.required,
|
24
24
|
default: input.default,
|
@@ -29,14 +29,14 @@ module Servactory
|
|
29
29
|
end,
|
30
30
|
|
31
31
|
internals: collection_of_internals.to_h do |internal|
|
32
|
-
|
32
|
+
actor = internal.class::Actor.new(internal)
|
33
33
|
inclusion = internal.collection_of_options.find_by(name: :inclusion)
|
34
34
|
must = internal.collection_of_options.find_by(name: :must)
|
35
35
|
|
36
36
|
[
|
37
37
|
internal.name,
|
38
38
|
{
|
39
|
-
|
39
|
+
actor: actor,
|
40
40
|
types: internal.types,
|
41
41
|
inclusion: inclusion.body,
|
42
42
|
must: must.body
|
@@ -45,14 +45,14 @@ module Servactory
|
|
45
45
|
end,
|
46
46
|
|
47
47
|
outputs: collection_of_outputs.to_h do |output|
|
48
|
-
|
48
|
+
actor = output.class::Actor.new(output)
|
49
49
|
inclusion = output.collection_of_options.find_by(name: :inclusion)
|
50
50
|
must = output.collection_of_options.find_by(name: :must)
|
51
51
|
|
52
52
|
[
|
53
53
|
output.name,
|
54
54
|
{
|
55
|
-
|
55
|
+
actor: actor,
|
56
56
|
types: output.types,
|
57
57
|
inclusion: inclusion.body,
|
58
58
|
must: must.body
|
data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb
CHANGED
@@ -145,11 +145,11 @@ module Servactory
|
|
145
145
|
service_class = Struct.new(:class_name, keyword_init: true)
|
146
146
|
service = service_class.new(class_name: described_class.name)
|
147
147
|
|
148
|
-
|
148
|
+
input_actor = attribute_data.fetch(:actor)
|
149
149
|
|
150
150
|
input_required_message = input_required_message.call(
|
151
151
|
service: service,
|
152
|
-
input:
|
152
|
+
input: input_actor,
|
153
153
|
value: wrong_value
|
154
154
|
)
|
155
155
|
end
|
@@ -82,11 +82,25 @@ module Servactory
|
|
82
82
|
common_condition_with(...)
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
86
|
+
def common_condition_with(value:, option:, input: nil, internal: nil, output: nil)
|
86
87
|
option_value = option.value&.to_sym
|
87
88
|
|
88
89
|
return [false, :unknown] unless @formats.key?(option_value)
|
89
90
|
|
91
|
+
attribute = Utils.define_attribute_with(input: input, internal: internal, output: output)
|
92
|
+
|
93
|
+
if value.blank? &&
|
94
|
+
(
|
95
|
+
(attribute.input? && attribute.optional?) ||
|
96
|
+
(
|
97
|
+
(attribute.internal? || attribute.output?) &&
|
98
|
+
attribute.types.include?(NilClass)
|
99
|
+
)
|
100
|
+
)
|
101
|
+
return true
|
102
|
+
end
|
103
|
+
|
90
104
|
format_options = @formats.fetch(option_value)
|
91
105
|
|
92
106
|
format_pattern = option.properties.fetch(:pattern, format_options.fetch(:pattern))
|
@@ -95,6 +109,7 @@ module Servactory
|
|
95
109
|
|
96
110
|
option.properties.fetch(:validator, format_options.fetch(:validator)).call(value: value)
|
97
111
|
end
|
112
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
98
113
|
|
99
114
|
########################################################################
|
100
115
|
|
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.6.
|
4
|
+
version: 2.6.2
|
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-05-
|
11
|
+
date: 2024-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|