servactory 2.15.1 → 2.16.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/actions/collection.rb +2 -1
- data/lib/servactory/actions/dsl.rb +1 -1
- data/lib/servactory/actions/stages/collection.rb +2 -1
- data/lib/servactory/actions/stages/stage.rb +2 -6
- data/lib/servactory/actions/tools/runner.rb +17 -17
- data/lib/servactory/configuration/actions/aliases/collection.rb +1 -0
- data/lib/servactory/configuration/actions/rescue_handlers/collection.rb +1 -0
- data/lib/servactory/configuration/actions/shortcuts/collection.rb +1 -0
- data/lib/servactory/configuration/collection_mode/class_names_collection.rb +1 -0
- data/lib/servactory/configuration/hash_mode/class_names_collection.rb +1 -0
- data/lib/servactory/configuration/option_helpers/option_helpers_collection.rb +1 -0
- data/lib/servactory/context/warehouse/inputs.rb +1 -5
- data/lib/servactory/context/warehouse/outputs.rb +1 -0
- data/lib/servactory/context/workspace/inputs.rb +1 -5
- data/lib/servactory/context/workspace/internals.rb +1 -4
- data/lib/servactory/context/workspace/outputs.rb +1 -4
- data/lib/servactory/info/builder.rb +24 -3
- data/lib/servactory/info/dsl.rb +6 -0
- data/lib/servactory/info/result.rb +3 -1
- data/lib/servactory/inputs/collection.rb +1 -0
- data/lib/servactory/inputs/tools/rules.rb +1 -5
- data/lib/servactory/inputs/tools/unnecessary.rb +1 -4
- data/lib/servactory/inputs/tools/validation.rb +10 -10
- data/lib/servactory/inputs/validations/errors.rb +1 -0
- data/lib/servactory/internals/collection.rb +1 -0
- data/lib/servactory/maintenance/attributes/options_collection.rb +2 -1
- data/lib/servactory/maintenance/attributes/tools/check_errors.rb +1 -0
- data/lib/servactory/maintenance/attributes/tools/validation.rb +4 -0
- data/lib/servactory/maintenance/attributes/validations/errors.rb +2 -1
- data/lib/servactory/outputs/collection.rb +1 -0
- data/lib/servactory/tool_kit/dynamic_options/inclusion.rb +3 -3
- data/lib/servactory/tool_kit/dynamic_options/multiple_of.rb +1 -1
- data/lib/servactory/utils.rb +1 -1
- data/lib/servactory/version.rb +2 -2
- 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: 2cff4c0f6ff8ecc7a499e738a23ba621757a674b5d1cf07707b75ac716cb3e1f
|
4
|
+
data.tar.gz: f0da2b67eb5d4e4e0126e1827182a8fd6efd659e3aa14082455fa439d163ff30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44596fe29886b3685039bfd9ee7e30d38c46ae3e2c1c4ac01007919a3c497e55c70a5b275df47bf44edff9b915b5cc52ea488d9fd04fd6a90edaa535b78db5d1
|
7
|
+
data.tar.gz: 11aa49b7b0d4ddaa1de5d3ad9a2c33c6d8db4900af44b361602e994e254a0be27879f9623065cd567965077aafbfbc1c606fba0879288ebedd6895705b743773
|
@@ -5,7 +5,8 @@ module Servactory
|
|
5
5
|
module Stages
|
6
6
|
class Collection
|
7
7
|
extend Forwardable
|
8
|
-
|
8
|
+
|
9
|
+
def_delegators :@collection, :<<, :each, :merge, :to_h, :sort_by, :size, :empty?
|
9
10
|
|
10
11
|
def initialize(collection = Set.new)
|
11
12
|
@collection = collection
|
@@ -32,17 +32,17 @@ module Servactory
|
|
32
32
|
|
33
33
|
wrapper = stage.wrapper
|
34
34
|
rollback = stage.rollback
|
35
|
-
|
35
|
+
actions = stage.actions.sorted_by_position
|
36
36
|
|
37
37
|
if wrapper.is_a?(Proc)
|
38
|
-
|
38
|
+
call_wrapper_with_actions(wrapper, rollback, actions)
|
39
39
|
else
|
40
|
-
|
40
|
+
call_actions(actions)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
45
|
-
wrapper.call(methods: -> {
|
44
|
+
def call_wrapper_with_actions(wrapper, rollback, actions) # rubocop:disable Metrics/MethodLength
|
45
|
+
wrapper.call(methods: -> { call_actions(actions) }, context: @context)
|
46
46
|
rescue StandardError => e
|
47
47
|
if rollback.present?
|
48
48
|
@context.send(rollback, e)
|
@@ -56,16 +56,16 @@ module Servactory
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
60
|
-
|
61
|
-
next if unnecessary_for_make?(
|
59
|
+
def call_actions(actions)
|
60
|
+
actions.each do |action|
|
61
|
+
next if unnecessary_for_make?(action)
|
62
62
|
|
63
|
-
|
63
|
+
call_action(action)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
68
|
-
@context.send(
|
67
|
+
def call_action(action)
|
68
|
+
@context.send(action.name)
|
69
69
|
rescue StandardError => e
|
70
70
|
rescue_with_handler(e) || raise
|
71
71
|
end
|
@@ -74,21 +74,21 @@ module Servactory
|
|
74
74
|
condition = stage.condition
|
75
75
|
is_condition_opposite = stage.is_condition_opposite
|
76
76
|
|
77
|
-
result =
|
77
|
+
result = checks_passed_for?(condition)
|
78
78
|
|
79
79
|
is_condition_opposite ? !result : result
|
80
80
|
end
|
81
81
|
|
82
|
-
def unnecessary_for_make?(
|
83
|
-
condition =
|
84
|
-
is_condition_opposite =
|
82
|
+
def unnecessary_for_make?(make_action)
|
83
|
+
condition = make_action.condition
|
84
|
+
is_condition_opposite = make_action.is_condition_opposite
|
85
85
|
|
86
|
-
result =
|
86
|
+
result = checks_passed_for?(condition)
|
87
87
|
|
88
88
|
is_condition_opposite ? !result : result
|
89
89
|
end
|
90
90
|
|
91
|
-
def
|
91
|
+
def checks_passed_for?(condition)
|
92
92
|
return false if condition.nil?
|
93
93
|
return !Servactory::Utils.true?(condition) unless condition.is_a?(Proc)
|
94
94
|
|
@@ -5,17 +5,19 @@ module Servactory
|
|
5
5
|
class Builder # rubocop:disable Metrics/ClassLength
|
6
6
|
attr_reader :inputs,
|
7
7
|
:internals,
|
8
|
-
:outputs
|
8
|
+
:outputs,
|
9
|
+
:stages
|
9
10
|
|
10
11
|
def self.build(...)
|
11
12
|
new.build(...)
|
12
13
|
end
|
13
14
|
|
14
|
-
def build(collection_of_inputs:, collection_of_internals:, collection_of_outputs:, config:)
|
15
|
+
def build(collection_of_inputs:, collection_of_internals:, collection_of_outputs:, collection_of_stages:, config:)
|
15
16
|
build_all_attributes(
|
16
17
|
inputs: collection_of_inputs,
|
17
18
|
internals: collection_of_internals,
|
18
19
|
outputs: collection_of_outputs,
|
20
|
+
stages: collection_of_stages,
|
19
21
|
config:
|
20
22
|
)
|
21
23
|
|
@@ -25,7 +27,7 @@ module Servactory
|
|
25
27
|
private
|
26
28
|
|
27
29
|
# rubocop:disable Metrics/MethodLength
|
28
|
-
def build_all_attributes(inputs:, internals:, outputs:, config:)
|
30
|
+
def build_all_attributes(inputs:, internals:, outputs:, stages:, config:)
|
29
31
|
build_input_attributes_with(
|
30
32
|
collection: inputs,
|
31
33
|
dynamic_options: config.input_option_helpers.dynamic_options
|
@@ -40,6 +42,8 @@ module Servactory
|
|
40
42
|
collection: outputs,
|
41
43
|
dynamic_options: config.output_option_helpers.dynamic_options
|
42
44
|
)
|
45
|
+
|
46
|
+
build_action_stages_with(collection: stages)
|
43
47
|
end
|
44
48
|
# rubocop:enable Metrics/MethodLength
|
45
49
|
|
@@ -65,6 +69,23 @@ module Servactory
|
|
65
69
|
)
|
66
70
|
end
|
67
71
|
|
72
|
+
def build_action_stages_with(collection:) # rubocop:disable Metrics/MethodLength
|
73
|
+
@stages = collection.to_h do |stage|
|
74
|
+
[
|
75
|
+
:"stage_#{stage.position}",
|
76
|
+
stage.actions.to_h do |action|
|
77
|
+
[
|
78
|
+
action.name,
|
79
|
+
{
|
80
|
+
position: action.position,
|
81
|
+
condition: action.condition
|
82
|
+
}
|
83
|
+
]
|
84
|
+
end
|
85
|
+
]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
68
89
|
def build_attributes_with(collection:, dynamic_options:, include_specific_options: false) # rubocop:disable Metrics/MethodLength
|
69
90
|
collection.to_h do |attribute|
|
70
91
|
options = process_options_for(
|
data/lib/servactory/info/dsl.rb
CHANGED
@@ -13,11 +13,17 @@ module Servactory
|
|
13
13
|
collection_of_inputs:,
|
14
14
|
collection_of_internals:,
|
15
15
|
collection_of_outputs:,
|
16
|
+
collection_of_stages:,
|
16
17
|
config:
|
17
18
|
)
|
18
19
|
|
19
20
|
Result.new(builder)
|
20
21
|
end
|
22
|
+
|
23
|
+
# API: Servactory Web
|
24
|
+
def servactory?
|
25
|
+
true
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
@@ -5,12 +5,14 @@ module Servactory
|
|
5
5
|
class Result
|
6
6
|
attr_reader :inputs,
|
7
7
|
:internals,
|
8
|
-
:outputs
|
8
|
+
:outputs,
|
9
|
+
:stages
|
9
10
|
|
10
11
|
def initialize(builder)
|
11
12
|
@inputs = builder.inputs
|
12
13
|
@internals = builder.internals
|
13
14
|
@outputs = builder.outputs
|
15
|
+
@stages = builder.stages
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -34,11 +34,7 @@ module Servactory
|
|
34
34
|
conflict_code: input.conflict_code
|
35
35
|
)
|
36
36
|
|
37
|
-
|
38
|
-
context: @context,
|
39
|
-
message: message_text,
|
40
|
-
input_name: input.name
|
41
|
-
)
|
37
|
+
@context.fail_input!(input.name, message: message_text)
|
42
38
|
end
|
43
39
|
end
|
44
40
|
end
|
@@ -21,10 +21,7 @@ module Servactory
|
|
21
21
|
unnecessary_attributes: unnecessary_attributes.join(", ")
|
22
22
|
)
|
23
23
|
|
24
|
-
|
25
|
-
context: @context,
|
26
|
-
message: message_text
|
27
|
-
)
|
24
|
+
@context.fail_input!(nil, message: message_text)
|
28
25
|
end
|
29
26
|
|
30
27
|
private
|
@@ -29,18 +29,21 @@ module Servactory
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def process_option(check_key, check_options, input:)
|
33
|
-
validation_classes_from(input)
|
32
|
+
def process_option(check_key, check_options, input:) # rubocop:disable Metrics/MethodLength
|
33
|
+
validation_classes = validation_classes_from(input)
|
34
|
+
return if validation_classes.empty?
|
35
|
+
|
36
|
+
validation_classes.each do |validation_class|
|
34
37
|
errors_from_checks = process_validation_class(
|
35
38
|
validation_class:,
|
36
39
|
input:,
|
37
40
|
check_key:,
|
38
41
|
check_options:
|
39
|
-
)
|
42
|
+
)
|
40
43
|
|
41
|
-
next if errors_from_checks.empty?
|
44
|
+
next if errors_from_checks.nil? || errors_from_checks.empty?
|
42
45
|
|
43
|
-
errors.merge(errors_from_checks)
|
46
|
+
errors.merge(errors_from_checks.to_a)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
@@ -62,7 +65,7 @@ module Servactory
|
|
62
65
|
########################################################################
|
63
66
|
|
64
67
|
def validation_classes_from(input)
|
65
|
-
input.collection_of_options.validation_classes
|
68
|
+
@validation_classes_cache ||= input.collection_of_options.validation_classes # rubocop:disable Naming/MemoizedInstanceVariableName
|
66
69
|
end
|
67
70
|
|
68
71
|
########################################################################
|
@@ -74,10 +77,7 @@ module Servactory
|
|
74
77
|
def raise_errors
|
75
78
|
return if (tmp_errors = errors.not_blank).empty?
|
76
79
|
|
77
|
-
|
78
|
-
context: @context,
|
79
|
-
message: tmp_errors.first
|
80
|
-
)
|
80
|
+
@context.fail_input!(nil, message: tmp_errors.first)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -30,6 +30,8 @@ module Servactory
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def process_option(check_key, check_options)
|
33
|
+
return if validation_classes.empty?
|
34
|
+
|
33
35
|
validation_classes.each do |validation_class|
|
34
36
|
errors_from_checks = process_validation_class(
|
35
37
|
validation_class:,
|
@@ -37,6 +39,8 @@ module Servactory
|
|
37
39
|
check_options:
|
38
40
|
)
|
39
41
|
|
42
|
+
next if errors_from_checks.nil? || errors_from_checks.empty?
|
43
|
+
|
40
44
|
errors.merge(errors_from_checks.to_a)
|
41
45
|
end
|
42
46
|
end
|
@@ -9,7 +9,7 @@ module Servactory
|
|
9
9
|
instance.must(:be_inclusion)
|
10
10
|
end
|
11
11
|
|
12
|
-
def condition_for_input_with(input:, value:, option:)
|
12
|
+
def condition_for_input_with(input:, value:, option:) # rubocop:disable Naming/PredicateMethod
|
13
13
|
if input.required? || (input.optional? && !value.nil?) # rubocop:disable Style/IfUnlessModifier
|
14
14
|
return option.value.include?(value)
|
15
15
|
end
|
@@ -21,11 +21,11 @@ module Servactory
|
|
21
21
|
true
|
22
22
|
end
|
23
23
|
|
24
|
-
def condition_for_internal_with(value:, option:, **)
|
24
|
+
def condition_for_internal_with(value:, option:, **) # rubocop:disable Naming/PredicateMethod
|
25
25
|
option.value.include?(value)
|
26
26
|
end
|
27
27
|
|
28
|
-
def condition_for_output_with(value:, option:, **)
|
28
|
+
def condition_for_output_with(value:, option:, **) # rubocop:disable Naming/PredicateMethod
|
29
29
|
option.value.include?(value)
|
30
30
|
end
|
31
31
|
|
@@ -20,7 +20,7 @@ module Servactory
|
|
20
20
|
common_condition_with(...)
|
21
21
|
end
|
22
22
|
|
23
|
-
def common_condition_with(value:, option:, **)
|
23
|
+
def common_condition_with(value:, option:, **) # rubocop:disable Naming/PredicateMethod
|
24
24
|
case value
|
25
25
|
when Integer, Float, Rational, BigDecimal
|
26
26
|
return false if option.value.blank?
|
data/lib/servactory/utils.rb
CHANGED
@@ -86,7 +86,7 @@ module Servactory
|
|
86
86
|
# https://github.com/rails/rails/blob/main/activerecord/lib/active_record/attribute_methods/query.rb
|
87
87
|
# @param value [#to_s]
|
88
88
|
# @return [Boolean]
|
89
|
-
def query_attribute(value) # rubocop:disable Metrics/MethodLength
|
89
|
+
def query_attribute(value) # rubocop:disable Metrics/MethodLength, Naming/PredicateMethod
|
90
90
|
case value
|
91
91
|
when true then true
|
92
92
|
when false, nil then false
|
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.
|
4
|
+
version: 2.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
@@ -338,7 +338,7 @@ metadata:
|
|
338
338
|
documentation_uri: https://servactory.com
|
339
339
|
source_code_uri: https://github.com/servactory/servactory
|
340
340
|
bug_tracker_uri: https://github.com/servactory/servactory/issues
|
341
|
-
changelog_uri: https://github.com/servactory/servactory/blob/
|
341
|
+
changelog_uri: https://github.com/servactory/servactory/blob/main/CHANGELOG.md
|
342
342
|
rubygems_mfa_required: 'true'
|
343
343
|
rdoc_options: []
|
344
344
|
require_paths:
|