servactory 2.9.2 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/servactory/actions/tools/runner.rb +11 -2
- data/lib/servactory/context/callable.rb +0 -2
- data/lib/servactory/context/store.rb +21 -8
- data/lib/servactory/context/workspace/inputs.rb +2 -3
- data/lib/servactory/context/workspace.rb +1 -5
- data/lib/servactory/inputs/tools/store.rb +28 -0
- data/lib/servactory/inputs/tools/unnecessary.rb +4 -3
- data/lib/servactory/inputs/tools/validation.rb +2 -3
- data/lib/servactory/inputs/workspace.rb +5 -3
- data/lib/servactory/maintenance/attributes/option.rb +4 -4
- data/lib/servactory/test_kit/rspec/matchers.rb +3 -3
- data/lib/servactory/version.rb +2 -2
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a14d75bf3c1035ecffff36644b509241bdea300d28b56aa91e15e933c9184cb1
|
4
|
+
data.tar.gz: 062d490213f603fa45571b4217f3a8f8a892e92fdfd348e6702b2c71246d9480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95b646ef01984996b9a9607e2a01a6adb324e76d0b637a78f4de73105840a3c17af27b20ca2286805161f5eb134da3b9b616d8ec7de6b5fc86bcc7847e265bfc
|
7
|
+
data.tar.gz: 61e57e674dbd46d934da1cbbe63b8574cd890913ca9ae63082529e627140105d724ba3e1a761c73a081eac7cb94169752dfd424cd7b9a17c3629910937e8917e
|
@@ -41,10 +41,19 @@ module Servactory
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def call_wrapper_with_methods(wrapper, rollback, methods)
|
44
|
+
def call_wrapper_with_methods(wrapper, rollback, methods) # rubocop:disable Metrics/MethodLength
|
45
45
|
wrapper.call(methods: -> { call_methods(methods) }, context: @context)
|
46
46
|
rescue StandardError => e
|
47
|
-
|
47
|
+
if rollback.present?
|
48
|
+
@context.send(rollback, e)
|
49
|
+
else
|
50
|
+
@context.fail!(
|
51
|
+
message: e.message,
|
52
|
+
meta: {
|
53
|
+
original_exception: e
|
54
|
+
}
|
55
|
+
)
|
56
|
+
end
|
48
57
|
end
|
49
58
|
|
50
59
|
def call_methods(methods)
|
@@ -7,22 +7,38 @@ module Servactory
|
|
7
7
|
@context = context
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
|
10
|
+
def assign_inputs(arguments)
|
11
|
+
context_data[:inputs].merge!(arguments)
|
12
|
+
end
|
13
|
+
|
14
|
+
def fetch_input(name)
|
15
|
+
inputs.fetch(name, nil)
|
12
16
|
end
|
13
17
|
|
14
18
|
def assign_internal(name, value)
|
15
19
|
assign_attribute(:internals, name, value)
|
16
20
|
end
|
17
21
|
|
18
|
-
def
|
19
|
-
|
22
|
+
def fetch_internal(name)
|
23
|
+
internals.fetch(name, nil)
|
20
24
|
end
|
21
25
|
|
22
26
|
def assign_output(name, value)
|
23
27
|
assign_attribute(:outputs, name, value)
|
24
28
|
end
|
25
29
|
|
30
|
+
def fetch_output(name)
|
31
|
+
outputs.fetch(name, nil)
|
32
|
+
end
|
33
|
+
|
34
|
+
def inputs
|
35
|
+
@inputs ||= context_data.fetch(:inputs)
|
36
|
+
end
|
37
|
+
|
38
|
+
def internals
|
39
|
+
@internals ||= context_data.fetch(:internals)
|
40
|
+
end
|
41
|
+
|
26
42
|
def outputs
|
27
43
|
@outputs ||= context_data.fetch(:outputs)
|
28
44
|
end
|
@@ -33,10 +49,6 @@ module Servactory
|
|
33
49
|
context_data[section].merge!({ name => value })
|
34
50
|
end
|
35
51
|
|
36
|
-
def internals
|
37
|
-
@internals ||= context_data.fetch(:internals)
|
38
|
-
end
|
39
|
-
|
40
52
|
def context_data
|
41
53
|
@context_data ||= state.fetch(context_id)
|
42
54
|
end
|
@@ -44,6 +56,7 @@ module Servactory
|
|
44
56
|
def state
|
45
57
|
{
|
46
58
|
context_id => {
|
59
|
+
inputs: {},
|
47
60
|
internals: {},
|
48
61
|
outputs: {}
|
49
62
|
}
|
@@ -7,9 +7,8 @@ module Servactory
|
|
7
7
|
RESERVED_ATTRIBUTES = %i[type required default].freeze
|
8
8
|
private_constant :RESERVED_ATTRIBUTES
|
9
9
|
|
10
|
-
def initialize(context:,
|
10
|
+
def initialize(context:, collection_of_inputs:)
|
11
11
|
@context = context
|
12
|
-
@incoming_arguments = incoming_arguments
|
13
12
|
@collection_of_inputs = collection_of_inputs
|
14
13
|
end
|
15
14
|
|
@@ -49,7 +48,7 @@ module Servactory
|
|
49
48
|
|
50
49
|
return yield if input.nil?
|
51
50
|
|
52
|
-
input_value = @
|
51
|
+
input_value = @context.send(:servactory_service_store).fetch_input(input.name)
|
53
52
|
input_value = input.default if input.optional? && input_value.blank?
|
54
53
|
|
55
54
|
if input.hash_mode? && (tmp_schema = input.schema.fetch(:is)).present?
|
@@ -23,7 +23,6 @@ module Servactory
|
|
23
23
|
def inputs
|
24
24
|
@inputs ||= Inputs.new(
|
25
25
|
context: self,
|
26
|
-
incoming_arguments:,
|
27
26
|
collection_of_inputs:
|
28
27
|
)
|
29
28
|
end
|
@@ -83,8 +82,7 @@ module Servactory
|
|
83
82
|
|
84
83
|
private
|
85
84
|
|
86
|
-
attr_reader :
|
87
|
-
:collection_of_inputs,
|
85
|
+
attr_reader :collection_of_inputs,
|
88
86
|
:collection_of_internals,
|
89
87
|
:collection_of_outputs
|
90
88
|
|
@@ -105,13 +103,11 @@ module Servactory
|
|
105
103
|
end
|
106
104
|
|
107
105
|
def call!(
|
108
|
-
incoming_arguments:,
|
109
106
|
collection_of_inputs:,
|
110
107
|
collection_of_internals:,
|
111
108
|
collection_of_outputs:,
|
112
109
|
**
|
113
110
|
)
|
114
|
-
@incoming_arguments = incoming_arguments
|
115
111
|
@collection_of_inputs = collection_of_inputs
|
116
112
|
@collection_of_internals = collection_of_internals
|
117
113
|
@collection_of_outputs = collection_of_outputs
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module Inputs
|
5
|
+
module Tools
|
6
|
+
class Store
|
7
|
+
def self.assign(...)
|
8
|
+
new(...).assign
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(context, incoming_arguments)
|
12
|
+
@context = context
|
13
|
+
@incoming_arguments = incoming_arguments
|
14
|
+
end
|
15
|
+
|
16
|
+
def assign
|
17
|
+
@context.send(:servactory_service_store).assign_inputs(adapted_arguments)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def adapted_arguments
|
23
|
+
Servactory::Utils.adapt(@incoming_arguments)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -8,9 +8,8 @@ module Servactory
|
|
8
8
|
new(...).find!
|
9
9
|
end
|
10
10
|
|
11
|
-
def initialize(context,
|
11
|
+
def initialize(context, collection_of_inputs)
|
12
12
|
@context = context
|
13
|
-
@incoming_arguments = incoming_arguments
|
14
13
|
@collection_of_inputs = collection_of_inputs
|
15
14
|
end
|
16
15
|
|
@@ -31,7 +30,9 @@ module Servactory
|
|
31
30
|
private
|
32
31
|
|
33
32
|
def unnecessary_attributes
|
34
|
-
@unnecessary_attributes ||=
|
33
|
+
@unnecessary_attributes ||=
|
34
|
+
@context.send(:servactory_service_store).inputs.keys -
|
35
|
+
@collection_of_inputs.names
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
@@ -8,9 +8,8 @@ module Servactory
|
|
8
8
|
new(...).validate!
|
9
9
|
end
|
10
10
|
|
11
|
-
def initialize(context,
|
11
|
+
def initialize(context, collection_of_inputs)
|
12
12
|
@context = context
|
13
|
-
@incoming_arguments = incoming_arguments
|
14
13
|
@collection_of_inputs = collection_of_inputs
|
15
14
|
end
|
16
15
|
|
@@ -52,7 +51,7 @@ module Servactory
|
|
52
51
|
validation_class.check(
|
53
52
|
context: @context,
|
54
53
|
attribute: input,
|
55
|
-
value: @
|
54
|
+
value: @context.send(:servactory_service_store).fetch_input(input.name),
|
56
55
|
check_key:,
|
57
56
|
check_options:
|
58
57
|
)
|
@@ -5,12 +5,14 @@ module Servactory
|
|
5
5
|
module Workspace
|
6
6
|
private
|
7
7
|
|
8
|
-
def call!(incoming_arguments:,
|
8
|
+
def call!(incoming_arguments:, **)
|
9
9
|
super
|
10
10
|
|
11
|
-
Tools::
|
11
|
+
Tools::Store.assign(self, incoming_arguments)
|
12
|
+
|
13
|
+
Tools::Unnecessary.find!(self, collection_of_inputs)
|
12
14
|
Tools::Rules.check!(self, collection_of_inputs)
|
13
|
-
Tools::Validation.validate!(self,
|
15
|
+
Tools::Validation.validate!(self, collection_of_inputs)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -108,12 +108,12 @@ module Servactory
|
|
108
108
|
return if @define_methods.blank?
|
109
109
|
|
110
110
|
@define_methods_template ||= @define_methods.map do |define_method|
|
111
|
-
<<-RUBY
|
112
|
-
def #{define_method.name}
|
113
|
-
#{define_method.content.call(option: @body)}
|
111
|
+
<<-RUBY.squish
|
112
|
+
def #{define_method.name};
|
113
|
+
#{define_method.content.call(option: @body)};
|
114
114
|
end
|
115
115
|
RUBY
|
116
|
-
end.join("
|
116
|
+
end.join("; ")
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -151,14 +151,14 @@ module Servactory
|
|
151
151
|
MESSAGE
|
152
152
|
end
|
153
153
|
|
154
|
-
|
154
|
+
received_value = actual.public_send(key)
|
155
155
|
next if actual.public_send(key) == value
|
156
156
|
|
157
157
|
break <<~MESSAGE
|
158
158
|
Incorrect result value for #{key}:
|
159
159
|
|
160
|
-
expected #{
|
161
|
-
got #{
|
160
|
+
expected #{value.inspect}
|
161
|
+
got #{received_value.inspect}
|
162
162
|
MESSAGE
|
163
163
|
end
|
164
164
|
end
|
data/lib/servactory/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-01 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -269,6 +268,7 @@ files:
|
|
269
268
|
- lib/servactory/inputs/dsl.rb
|
270
269
|
- lib/servactory/inputs/input.rb
|
271
270
|
- lib/servactory/inputs/tools/rules.rb
|
271
|
+
- lib/servactory/inputs/tools/store.rb
|
272
272
|
- lib/servactory/inputs/tools/unnecessary.rb
|
273
273
|
- lib/servactory/inputs/tools/validation.rb
|
274
274
|
- lib/servactory/inputs/translator/required.rb
|
@@ -334,7 +334,6 @@ metadata:
|
|
334
334
|
bug_tracker_uri: https://github.com/servactory/servactory/issues
|
335
335
|
changelog_uri: https://github.com/servactory/servactory/blob/master/CHANGELOG.md
|
336
336
|
rubygems_mfa_required: 'true'
|
337
|
-
post_install_message:
|
338
337
|
rdoc_options: []
|
339
338
|
require_paths:
|
340
339
|
- lib
|
@@ -349,8 +348,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
349
348
|
- !ruby/object:Gem::Version
|
350
349
|
version: '0'
|
351
350
|
requirements: []
|
352
|
-
rubygems_version: 3.
|
353
|
-
signing_key:
|
351
|
+
rubygems_version: 3.6.2
|
354
352
|
specification_version: 4
|
355
353
|
summary: A set of tools for building reliable services of any complexity
|
356
354
|
test_files: []
|