servactory 2.15.1 → 2.16.0.rc2
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 +1 -1
- data/lib/servactory/actions/dsl.rb +1 -1
- data/lib/servactory/actions/stages/collection.rb +1 -1
- data/lib/servactory/actions/stages/stage.rb +2 -6
- data/lib/servactory/actions/tools/runner.rb +14 -14
- data/lib/servactory/context/warehouse/inputs.rb +1 -5
- 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 +23 -3
- data/lib/servactory/info/dsl.rb +6 -0
- data/lib/servactory/info/result.rb +3 -1
- 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/maintenance/attributes/options_collection.rb +2 -1
- data/lib/servactory/maintenance/attributes/tools/validation.rb +4 -0
- data/lib/servactory/maintenance/attributes/validations/errors.rb +1 -1
- data/lib/servactory/version.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ff6af883d52092f1fd6589a77d962a3bd8b346ca5b8f40ffe4489b993e023e3
|
4
|
+
data.tar.gz: 8eb05b74076fa1c75e6688ffa1503daaca3f5f0a43d32d621eeda3912456d4cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bf62d2f5546ccf038ba21009e9cca29d27dfe10431d1117bd020e5c537d45afc10f1323b2ce34ae87b7e43d750b4cae767277390d51de81c3692fe984fb7aaf
|
7
|
+
data.tar.gz: 0c1c762bccd20fc0d9738a6c5788dd27d874567306adeb6edabe5d2ba0522fdabd0c507ac97d63ca9b35dba7fa4475ff9c54c6ffdb76ebd819e58d092e9acf98
|
@@ -5,7 +5,7 @@ module Servactory
|
|
5
5
|
module Stages
|
6
6
|
class Collection
|
7
7
|
extend Forwardable
|
8
|
-
def_delegators :@collection, :<<, :each, :merge, :sort_by, :size, :empty?
|
8
|
+
def_delegators :@collection, :<<, :each, :merge, :to_h, :sort_by, :size, :empty?
|
9
9
|
|
10
10
|
def initialize(collection = Set.new)
|
11
11
|
@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
|
@@ -79,9 +79,9 @@ module Servactory
|
|
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
86
|
result = prepare_condition_for(condition)
|
87
87
|
|
@@ -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,22 @@ 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.map do |action|
|
77
|
+
{
|
78
|
+
action.name => {
|
79
|
+
position: action.position,
|
80
|
+
condition: action.condition
|
81
|
+
}
|
82
|
+
}
|
83
|
+
end
|
84
|
+
]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
68
88
|
def build_attributes_with(collection:, dynamic_options:, include_specific_options: false) # rubocop:disable Metrics/MethodLength
|
69
89
|
collection.to_h do |attribute|
|
70
90
|
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
|
data/lib/servactory/version.rb
CHANGED