servactory 1.1.0 → 1.2.0
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/lib/servactory/context/dsl.rb +10 -8
- data/lib/servactory/input_arguments/checks/inclusion.rb +1 -1
- data/lib/servactory/input_arguments/checks/must.rb +5 -6
- data/lib/servactory/input_arguments/checks/required.rb +1 -1
- data/lib/servactory/input_arguments/checks/type.rb +1 -1
- data/lib/servactory/input_arguments/input_argument.rb +6 -6
- data/lib/servactory/input_arguments/tools/check.rb +10 -5
- data/lib/servactory/input_arguments/tools/prepare.rb +7 -3
- data/lib/servactory/internal_arguments/internal_argument.rb +2 -2
- data/lib/servactory/internal_arguments/tools/prepare.rb +5 -3
- data/lib/servactory/output_arguments/output_argument.rb +3 -3
- data/lib/servactory/output_arguments/tools/prepare.rb +8 -4
- data/lib/servactory/stage/dsl.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: 9ef221cf056da7376cec0a04e0dd92ddba328f34163fe050d74e3f0158eb1e17
|
4
|
+
data.tar.gz: 2bc1b62867fb2e6c09692bfd76c315bbf739202b445fc99e46511b6dd3437c6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 126ca96b81dcbea82334b216f9b911c33282aca4c66c26d511655339cd56184ce6fac7475420184f6fcd4681d34afe210f8ebffe18e0894c635c6bcbdc045754
|
7
|
+
data.tar.gz: 22675c25495d5e2b3edfda926c5392985294c78c03e0e2d6f8930b8a8d5a7618dc94dd7cec413fba5b6ce234d23bbeea44c68cf58fc95d0e223c73c437721b43
|
@@ -15,7 +15,9 @@ module Servactory
|
|
15
15
|
|
16
16
|
input_arguments_workbench.find_unnecessary!
|
17
17
|
input_arguments_workbench.check_rules!
|
18
|
-
output_arguments_workbench.find_conflicts_in!(
|
18
|
+
output_arguments_workbench.find_conflicts_in!(
|
19
|
+
collection_of_internal_arguments: collection_of_internal_arguments
|
20
|
+
)
|
19
21
|
|
20
22
|
prepare_data
|
21
23
|
|
@@ -25,7 +27,7 @@ module Servactory
|
|
25
27
|
|
26
28
|
Servactory::Result.prepare_for(
|
27
29
|
context: context_store.context,
|
28
|
-
collection_of_output_arguments:
|
30
|
+
collection_of_output_arguments: collection_of_output_arguments
|
29
31
|
)
|
30
32
|
end
|
31
33
|
|
@@ -34,10 +36,10 @@ module Servactory
|
|
34
36
|
attr_reader :context_store
|
35
37
|
|
36
38
|
def assign_data_with(arguments)
|
37
|
-
input_arguments_workbench.assign(context: context_store.context, arguments:) # 1
|
38
|
-
internal_arguments_workbench.assign(context: context_store.context)
|
39
|
-
output_arguments_workbench.assign(context: context_store.context)
|
40
|
-
stage_handyman&.assign(context: context_store.context)
|
39
|
+
input_arguments_workbench.assign(context: context_store.context, arguments: arguments) # 1
|
40
|
+
internal_arguments_workbench.assign(context: context_store.context) # 2
|
41
|
+
output_arguments_workbench.assign(context: context_store.context) # 3
|
42
|
+
stage_handyman&.assign(context: context_store.context) # 4
|
41
43
|
end
|
42
44
|
|
43
45
|
def prepare_data
|
@@ -47,10 +49,10 @@ module Servactory
|
|
47
49
|
internal_arguments_workbench.prepare # 3
|
48
50
|
end
|
49
51
|
|
50
|
-
def configuration(&)
|
52
|
+
def configuration(&block)
|
51
53
|
context_configuration = Servactory::Context::Configuration.new
|
52
54
|
|
53
|
-
context_configuration.instance_eval(&)
|
55
|
+
context_configuration.instance_eval(&block)
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
@@ -13,7 +13,7 @@ module Servactory
|
|
13
13
|
def self.check(context:, input:, value:, check_key:, **)
|
14
14
|
return unless should_be_checked_for?(input, check_key)
|
15
15
|
|
16
|
-
new(context
|
16
|
+
new(context: context, input: input, value: value).check
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.should_be_checked_for?(input, check_key)
|
@@ -14,7 +14,7 @@ module Servactory
|
|
14
14
|
def self.check(context:, input:, value:, check_key:, check_options:)
|
15
15
|
return unless should_be_checked_for?(input, check_key)
|
16
16
|
|
17
|
-
new(context
|
17
|
+
new(context: context, input: input, value: value, check_options: check_options).check
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.should_be_checked_for?(input, check_key)
|
@@ -42,7 +42,7 @@ module Servactory
|
|
42
42
|
DEFAULT_MESSAGE,
|
43
43
|
service_class_name: @context.class.name,
|
44
44
|
input: @input,
|
45
|
-
code:
|
45
|
+
code: code
|
46
46
|
)
|
47
47
|
end
|
48
48
|
|
@@ -57,16 +57,15 @@ module Servactory
|
|
57
57
|
return if check.call(value: @value)
|
58
58
|
|
59
59
|
message.presence || DEFAULT_MESSAGE
|
60
|
-
rescue StandardError =>
|
60
|
+
rescue StandardError => _e
|
61
61
|
message_text =
|
62
|
-
"[#{@context.class.name}] Syntax error inside `#{code}` of "
|
63
|
-
"`#{@input.name}` input: [#{e.class}] #{e.message}"
|
62
|
+
"[#{@context.class.name}] Syntax error inside `#{code}` of `#{@input.name}` input"
|
64
63
|
|
65
64
|
add_error(
|
66
65
|
message_text,
|
67
66
|
service_class_name: @context.class.name,
|
68
67
|
input: @input,
|
69
|
-
code:
|
68
|
+
code: code
|
70
69
|
)
|
71
70
|
end
|
72
71
|
end
|
@@ -17,7 +17,7 @@ module Servactory
|
|
17
17
|
def self.check(context:, input:, value:, **)
|
18
18
|
return unless should_be_checked_for?(input)
|
19
19
|
|
20
|
-
new(context
|
20
|
+
new(context: context, input: input, value: value).check
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.should_be_checked_for?(input)
|
@@ -19,7 +19,7 @@ module Servactory
|
|
19
19
|
def self.check(context:, input:, value:, check_key:, check_options:)
|
20
20
|
return unless should_be_checked_for?(input, value, check_key)
|
21
21
|
|
22
|
-
new(context
|
22
|
+
new(context: context, input: input, value: value, types: check_options).check
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.should_be_checked_for?(input, value, check_key)
|
@@ -26,12 +26,12 @@ module Servactory
|
|
26
26
|
|
27
27
|
def options_for_checks
|
28
28
|
{
|
29
|
-
types
|
30
|
-
inclusion
|
31
|
-
must
|
32
|
-
required
|
33
|
-
# internal
|
34
|
-
default:
|
29
|
+
types: types,
|
30
|
+
inclusion: inclusion,
|
31
|
+
must: must,
|
32
|
+
required: required,
|
33
|
+
# internal: internal,
|
34
|
+
default: default
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
@@ -28,13 +28,18 @@ module Servactory
|
|
28
28
|
|
29
29
|
def process_input(input)
|
30
30
|
input.options_for_checks.each do |check_key, check_options|
|
31
|
-
process_option(check_key, check_options, input:)
|
31
|
+
process_option(check_key, check_options, input: input)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def process_option(check_key, check_options, input:)
|
36
36
|
check_classes.each do |check_class|
|
37
|
-
errors_from_checks = process_check_class(
|
37
|
+
errors_from_checks = process_check_class(
|
38
|
+
check_class,
|
39
|
+
input: input,
|
40
|
+
check_key: check_key,
|
41
|
+
check_options: check_options
|
42
|
+
)
|
38
43
|
|
39
44
|
@errors.push(*errors_from_checks)
|
40
45
|
end
|
@@ -43,10 +48,10 @@ module Servactory
|
|
43
48
|
def process_check_class(check_class, input:, check_key:, check_options:)
|
44
49
|
check_class.check(
|
45
50
|
context: @context,
|
46
|
-
input
|
51
|
+
input: input,
|
47
52
|
value: @incoming_arguments.fetch(input.name, nil),
|
48
|
-
check_key
|
49
|
-
check_options:
|
53
|
+
check_key: check_key,
|
54
|
+
check_options: check_options
|
50
55
|
)
|
51
56
|
end
|
52
57
|
|
@@ -43,7 +43,7 @@ module Servactory
|
|
43
43
|
|
44
44
|
@context.assign_inputs(Servactory::Inputs.new(**@inputs_variables))
|
45
45
|
|
46
|
-
@context.class.class_eval(context_internal_variables_template)
|
46
|
+
@context.class.class_eval(context_internal_variables_template) if context_internal_variables_template.present?
|
47
47
|
|
48
48
|
@internal_variables.each do |input_name, input_value|
|
49
49
|
@context.instance_variable_set(:"@#{input_name}", input_value)
|
@@ -79,8 +79,12 @@ module Servactory
|
|
79
79
|
# private attr_reader(*[:attr_1]);
|
80
80
|
#
|
81
81
|
def context_internal_variables_template
|
82
|
-
|
83
|
-
|
82
|
+
return if @internal_variables.blank?
|
83
|
+
|
84
|
+
@context_internal_variables_template ||= <<-RUBY.squish
|
85
|
+
private;
|
86
|
+
|
87
|
+
attr_reader(*#{@internal_variables.keys});
|
84
88
|
RUBY
|
85
89
|
end
|
86
90
|
end
|
@@ -42,14 +42,16 @@ module Servactory
|
|
42
42
|
define_method(:#{internal_argument.name}=) do |value|;
|
43
43
|
Servactory::InternalArguments::Checks::Type.check!(
|
44
44
|
context: self,
|
45
|
-
internal_argument
|
46
|
-
value:
|
45
|
+
internal_argument: internal_argument,
|
46
|
+
value: value
|
47
47
|
);
|
48
48
|
|
49
49
|
instance_variable_set(:@#{internal_argument.name}, value);
|
50
50
|
end;
|
51
51
|
|
52
|
-
private
|
52
|
+
private;
|
53
|
+
|
54
|
+
attr_reader :#{internal_argument.name};
|
53
55
|
RUBY
|
54
56
|
end
|
55
57
|
end
|
@@ -35,21 +35,25 @@ module Servactory
|
|
35
35
|
# instance_variable_set(:@user, value);
|
36
36
|
# end;
|
37
37
|
#
|
38
|
-
# private
|
38
|
+
# private;
|
39
|
+
#
|
40
|
+
# attr_reader :user;
|
39
41
|
#
|
40
42
|
def context_output_argument_template_for(output_argument)
|
41
43
|
<<-RUBY.squish
|
42
44
|
define_method(:#{output_argument.name}=) do |value|;
|
43
45
|
Servactory::OutputArguments::Checks::Type.check!(
|
44
46
|
context: self,
|
45
|
-
output_argument
|
46
|
-
value:
|
47
|
+
output_argument: output_argument,
|
48
|
+
value: value
|
47
49
|
);
|
48
50
|
|
49
51
|
instance_variable_set(:@#{output_argument.name}, value);
|
50
52
|
end;
|
51
53
|
|
52
|
-
private
|
54
|
+
private;
|
55
|
+
|
56
|
+
attr_reader :#{output_argument.name};
|
53
57
|
RUBY
|
54
58
|
end
|
55
59
|
end
|
data/lib/servactory/stage/dsl.rb
CHANGED
@@ -12,10 +12,10 @@ module Servactory
|
|
12
12
|
|
13
13
|
attr_reader :stage_handyman
|
14
14
|
|
15
|
-
def stage(&)
|
15
|
+
def stage(&block)
|
16
16
|
@stage_factory ||= Factory.new
|
17
17
|
|
18
|
-
@stage_factory.instance_eval(&)
|
18
|
+
@stage_factory.instance_eval(&block)
|
19
19
|
|
20
20
|
@stage_handyman = Handyman.work_in(@stage_factory)
|
21
21
|
|
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
@@ -223,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
223
|
requirements:
|
224
224
|
- - ">="
|
225
225
|
- !ruby/object:Gem::Version
|
226
|
-
version:
|
226
|
+
version: 2.7.0
|
227
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
228
|
requirements:
|
229
229
|
- - ">="
|