servactory 2.11.0 → 2.12.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/servactory/context/warehouse/base.rb +25 -0
- data/lib/servactory/context/warehouse/inputs.rb +56 -0
- data/lib/servactory/context/warehouse/internals.rb +10 -0
- data/lib/servactory/context/warehouse/outputs.rb +12 -0
- data/lib/servactory/context/warehouse/setup.rb +73 -0
- data/lib/servactory/context/workspace/inputs.rb +3 -3
- data/lib/servactory/context/workspace/internals.rb +2 -2
- data/lib/servactory/context/workspace/outputs.rb +2 -2
- data/lib/servactory/context/workspace.rb +2 -2
- data/lib/servactory/inputs/tools/unnecessary.rb +1 -1
- data/lib/servactory/inputs/tools/validation.rb +1 -1
- data/lib/servactory/inputs/tools/{store.rb → warehouse.rb} +2 -2
- data/lib/servactory/inputs/workspace.rb +1 -1
- data/lib/servactory/result.rb +1 -1
- data/lib/servactory/test_kit/result.rb +3 -3
- data/lib/servactory/version.rb +2 -2
- metadata +10 -6
- data/lib/servactory/context/store.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42d8f2391ba24198b46219e80408d7bf1d304faca0dfd5a99e89ac841d246fe4
|
4
|
+
data.tar.gz: 93748b84e352a85641a18e2f50f7fbc1668c7d037a613b95f8ed47fe02fce079
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45895d6e4182f0ccdb4fd0c37e030232d809d8fb14d6117f793c5abac5292ceb172d5cd1aeb1fc48cb3cbda70e0ce4ba08a8752744f4776f431136b2c7b1dc8e
|
7
|
+
data.tar.gz: 97e972f65d377eec5eb1224d54c440e7cca90c66a32fd2fd398e87c482f355110fbc39453cfdca799b45e59af259bf5e393c039181e23f59ecb41bbfe5d478aa
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module Context
|
5
|
+
module Warehouse
|
6
|
+
class Base
|
7
|
+
def initialize(arguments = {})
|
8
|
+
@arguments = arguments
|
9
|
+
end
|
10
|
+
|
11
|
+
# def fetch!(name)
|
12
|
+
# @arguments.fetch(name)
|
13
|
+
# end
|
14
|
+
|
15
|
+
def fetch(name, default_value)
|
16
|
+
@arguments.fetch(name, default_value)
|
17
|
+
end
|
18
|
+
|
19
|
+
def assign(key, value)
|
20
|
+
@arguments[key] = value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module Context
|
5
|
+
module Warehouse
|
6
|
+
class Inputs < Base
|
7
|
+
def initialize(context, arguments = {})
|
8
|
+
@context = context
|
9
|
+
|
10
|
+
super(arguments)
|
11
|
+
end
|
12
|
+
|
13
|
+
def names
|
14
|
+
@arguments.keys
|
15
|
+
end
|
16
|
+
|
17
|
+
def merge!(arguments)
|
18
|
+
@arguments.merge!(arguments)
|
19
|
+
end
|
20
|
+
|
21
|
+
##########################################################################
|
22
|
+
|
23
|
+
def method_missing(name, *_args)
|
24
|
+
input_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
|
25
|
+
|
26
|
+
input_value = @arguments.fetch(input_name) { raise_error_for(input_name) }
|
27
|
+
|
28
|
+
if name.to_s.end_with?("?") && @context.class.config.predicate_methods_enabled?
|
29
|
+
Servactory::Utils.query_attribute(input_value)
|
30
|
+
else
|
31
|
+
input_value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def respond_to_missing?(name, *)
|
36
|
+
@arguments.fetch(name) { raise_error_for(name) }
|
37
|
+
end
|
38
|
+
|
39
|
+
##########################################################################
|
40
|
+
|
41
|
+
def raise_error_for(input_name)
|
42
|
+
message_text = @context.send(:servactory_service_info).translate(
|
43
|
+
"inputs.undefined.for_fetch",
|
44
|
+
input_name:
|
45
|
+
)
|
46
|
+
|
47
|
+
raise @context.class.config.input_exception_class.new(
|
48
|
+
context: @context,
|
49
|
+
message: message_text,
|
50
|
+
input_name:
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module Context
|
5
|
+
module Warehouse
|
6
|
+
class Setup
|
7
|
+
def initialize(context)
|
8
|
+
@context = context
|
9
|
+
end
|
10
|
+
|
11
|
+
def assign_inputs(arguments)
|
12
|
+
context_data[:inputs].merge!(arguments)
|
13
|
+
end
|
14
|
+
|
15
|
+
def fetch_input(name)
|
16
|
+
inputs.fetch(name, nil)
|
17
|
+
end
|
18
|
+
|
19
|
+
def assign_internal(name, value)
|
20
|
+
assign_attribute(:internals, name, value)
|
21
|
+
end
|
22
|
+
|
23
|
+
def fetch_internal(name)
|
24
|
+
internals.fetch(name, nil)
|
25
|
+
end
|
26
|
+
|
27
|
+
def assign_output(name, value)
|
28
|
+
assign_attribute(:outputs, name, value)
|
29
|
+
end
|
30
|
+
|
31
|
+
def fetch_output(name)
|
32
|
+
outputs.fetch(name, nil)
|
33
|
+
end
|
34
|
+
|
35
|
+
def inputs
|
36
|
+
@inputs ||= context_data.fetch(:inputs)
|
37
|
+
end
|
38
|
+
|
39
|
+
def internals
|
40
|
+
@internals ||= context_data.fetch(:internals)
|
41
|
+
end
|
42
|
+
|
43
|
+
def outputs
|
44
|
+
@outputs ||= context_data.fetch(:outputs)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def assign_attribute(section, name, value)
|
50
|
+
context_data[section].assign(name, value)
|
51
|
+
end
|
52
|
+
|
53
|
+
def context_data
|
54
|
+
@context_data ||= state.fetch(context_id)
|
55
|
+
end
|
56
|
+
|
57
|
+
def state
|
58
|
+
{
|
59
|
+
context_id => {
|
60
|
+
inputs: Servactory::Context::Warehouse::Inputs.new(@context),
|
61
|
+
internals: Servactory::Context::Warehouse::Internals.new,
|
62
|
+
outputs: Servactory::Context::Warehouse::Outputs.new
|
63
|
+
}
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
def context_id
|
68
|
+
@context_id ||= "context_#{@context.object_id}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -40,7 +40,7 @@ module Servactory
|
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize,
|
43
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
|
44
44
|
def fetch_with(name:, &block)
|
45
45
|
input_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
|
46
46
|
|
@@ -48,7 +48,7 @@ module Servactory
|
|
48
48
|
|
49
49
|
return yield if input.nil?
|
50
50
|
|
51
|
-
input_value = @context.send(:
|
51
|
+
input_value = @context.send(:servactory_service_warehouse).fetch_input(input.name)
|
52
52
|
input_value = input.default if input.optional? && input_value.blank?
|
53
53
|
|
54
54
|
if input.hash_mode? && (tmp_schema = input.schema.fetch(:is)).present?
|
@@ -64,7 +64,7 @@ module Servactory
|
|
64
64
|
input_value
|
65
65
|
end
|
66
66
|
end
|
67
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize,
|
67
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
|
68
68
|
|
69
69
|
def prepare_hash_values_inside(object:, schema:) # rubocop:disable Metrics/MethodLength
|
70
70
|
return object unless object.respond_to?(:fetch)
|
@@ -50,7 +50,7 @@ module Servactory
|
|
50
50
|
value:
|
51
51
|
)
|
52
52
|
|
53
|
-
@context.send(:
|
53
|
+
@context.send(:servactory_service_warehouse).assign_internal(internal.name, value)
|
54
54
|
end
|
55
55
|
|
56
56
|
def fetch_with(name:, &block) # rubocop:disable Metrics/AbcSize, Lint/UnusedMethodArgument
|
@@ -59,7 +59,7 @@ module Servactory
|
|
59
59
|
|
60
60
|
return yield if internal.nil?
|
61
61
|
|
62
|
-
internal_value = @context.send(:
|
62
|
+
internal_value = @context.send(:servactory_service_warehouse).fetch_internal(internal.name)
|
63
63
|
|
64
64
|
if name.to_s.end_with?("?") && @context.class.config.predicate_methods_enabled?
|
65
65
|
Servactory::Utils.query_attribute(internal_value)
|
@@ -50,7 +50,7 @@ module Servactory
|
|
50
50
|
value:
|
51
51
|
)
|
52
52
|
|
53
|
-
@context.send(:
|
53
|
+
@context.send(:servactory_service_warehouse).assign_output(output.name, value)
|
54
54
|
end
|
55
55
|
|
56
56
|
def fetch_with(name:, &block) # rubocop:disable Metrics/AbcSize, Lint/UnusedMethodArgument
|
@@ -59,7 +59,7 @@ module Servactory
|
|
59
59
|
|
60
60
|
return yield if output.nil?
|
61
61
|
|
62
|
-
output_value = @context.send(:
|
62
|
+
output_value = @context.send(:servactory_service_warehouse).fetch_output(output.name)
|
63
63
|
|
64
64
|
if name.to_s.end_with?("?") && @context.class.config.predicate_methods_enabled?
|
65
65
|
Servactory::Utils.query_attribute(output_value)
|
@@ -126,8 +126,8 @@ module Servactory
|
|
126
126
|
@servactory_service_info ||= self.class::Actor.new(self)
|
127
127
|
end
|
128
128
|
|
129
|
-
def
|
130
|
-
@
|
129
|
+
def servactory_service_warehouse
|
130
|
+
@servactory_service_warehouse ||= Warehouse::Setup.new(self)
|
131
131
|
end
|
132
132
|
end
|
133
133
|
end
|
@@ -51,7 +51,7 @@ module Servactory
|
|
51
51
|
validation_class.check(
|
52
52
|
context: @context,
|
53
53
|
attribute: input,
|
54
|
-
value: @context.send(:
|
54
|
+
value: @context.send(:servactory_service_warehouse).fetch_input(input.name),
|
55
55
|
check_key:,
|
56
56
|
check_options:
|
57
57
|
)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Servactory
|
4
4
|
module Inputs
|
5
5
|
module Tools
|
6
|
-
class
|
6
|
+
class Warehouse
|
7
7
|
def self.assign(...)
|
8
8
|
new(...).assign
|
9
9
|
end
|
@@ -14,7 +14,7 @@ module Servactory
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def assign
|
17
|
-
@context.send(:
|
17
|
+
@context.send(:servactory_service_warehouse).assign_inputs(adapted_arguments)
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
@@ -8,7 +8,7 @@ module Servactory
|
|
8
8
|
def call!(incoming_arguments:, **)
|
9
9
|
super
|
10
10
|
|
11
|
-
Tools::
|
11
|
+
Tools::Warehouse.assign(self, incoming_arguments)
|
12
12
|
|
13
13
|
Tools::Unnecessary.find!(self, collection_of_inputs)
|
14
14
|
Tools::Rules.check!(self, collection_of_inputs)
|
data/lib/servactory/result.rb
CHANGED
@@ -116,7 +116,7 @@ module Servactory
|
|
116
116
|
|
117
117
|
def outputs
|
118
118
|
@outputs ||= Outputs.new(
|
119
|
-
outputs: @context.send(:
|
119
|
+
outputs: @context.send(:servactory_service_warehouse).outputs,
|
120
120
|
predicate_methods_enabled: if @context.is_a?(Servactory::TestKit::Result)
|
121
121
|
true
|
122
122
|
else
|
@@ -17,7 +17,7 @@ module Servactory
|
|
17
17
|
|
18
18
|
def initialize(attributes = {})
|
19
19
|
attributes.each_pair do |name, value|
|
20
|
-
|
20
|
+
servactory_service_warehouse.assign_output(name, value)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -25,8 +25,8 @@ module Servactory
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
def
|
29
|
-
@
|
28
|
+
def servactory_service_warehouse
|
29
|
+
@servactory_service_warehouse ||= Servactory::Context::Warehouse::Setup.new(self)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/servactory/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +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.12.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-02-08 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|
@@ -189,14 +189,14 @@ dependencies:
|
|
189
189
|
requirements:
|
190
190
|
- - ">="
|
191
191
|
- !ruby/object:Gem::Version
|
192
|
-
version: '0.
|
192
|
+
version: '0.5'
|
193
193
|
type: :development
|
194
194
|
prerelease: false
|
195
195
|
version_requirements: !ruby/object:Gem::Requirement
|
196
196
|
requirements:
|
197
197
|
- - ">="
|
198
198
|
- !ruby/object:Gem::Version
|
199
|
-
version: '0.
|
199
|
+
version: '0.5'
|
200
200
|
- !ruby/object:Gem::Dependency
|
201
201
|
name: steep
|
202
202
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,7 +249,11 @@ files:
|
|
249
249
|
- lib/servactory/configuration/setup.rb
|
250
250
|
- lib/servactory/context/callable.rb
|
251
251
|
- lib/servactory/context/dsl.rb
|
252
|
-
- lib/servactory/context/
|
252
|
+
- lib/servactory/context/warehouse/base.rb
|
253
|
+
- lib/servactory/context/warehouse/inputs.rb
|
254
|
+
- lib/servactory/context/warehouse/internals.rb
|
255
|
+
- lib/servactory/context/warehouse/outputs.rb
|
256
|
+
- lib/servactory/context/warehouse/setup.rb
|
253
257
|
- lib/servactory/context/workspace.rb
|
254
258
|
- lib/servactory/context/workspace/inputs.rb
|
255
259
|
- lib/servactory/context/workspace/internals.rb
|
@@ -268,9 +272,9 @@ files:
|
|
268
272
|
- lib/servactory/inputs/dsl.rb
|
269
273
|
- lib/servactory/inputs/input.rb
|
270
274
|
- lib/servactory/inputs/tools/rules.rb
|
271
|
-
- lib/servactory/inputs/tools/store.rb
|
272
275
|
- lib/servactory/inputs/tools/unnecessary.rb
|
273
276
|
- lib/servactory/inputs/tools/validation.rb
|
277
|
+
- lib/servactory/inputs/tools/warehouse.rb
|
274
278
|
- lib/servactory/inputs/translator/required.rb
|
275
279
|
- lib/servactory/inputs/validations/base.rb
|
276
280
|
- lib/servactory/inputs/validations/errors.rb
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module Context
|
5
|
-
class Store
|
6
|
-
def initialize(context)
|
7
|
-
@context = context
|
8
|
-
end
|
9
|
-
|
10
|
-
def assign_inputs(arguments)
|
11
|
-
context_data[:inputs].merge!(arguments)
|
12
|
-
end
|
13
|
-
|
14
|
-
def fetch_input(name)
|
15
|
-
inputs.fetch(name, nil)
|
16
|
-
end
|
17
|
-
|
18
|
-
def assign_internal(name, value)
|
19
|
-
assign_attribute(:internals, name, value)
|
20
|
-
end
|
21
|
-
|
22
|
-
def fetch_internal(name)
|
23
|
-
internals.fetch(name, nil)
|
24
|
-
end
|
25
|
-
|
26
|
-
def assign_output(name, value)
|
27
|
-
assign_attribute(:outputs, name, value)
|
28
|
-
end
|
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
|
-
|
42
|
-
def outputs
|
43
|
-
@outputs ||= context_data.fetch(:outputs)
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def assign_attribute(section, name, value)
|
49
|
-
context_data[section].merge!({ name => value })
|
50
|
-
end
|
51
|
-
|
52
|
-
def context_data
|
53
|
-
@context_data ||= state.fetch(context_id)
|
54
|
-
end
|
55
|
-
|
56
|
-
def state
|
57
|
-
{
|
58
|
-
context_id => {
|
59
|
-
inputs: {},
|
60
|
-
internals: {},
|
61
|
-
outputs: {}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
def context_id
|
67
|
-
@context_id ||= "context_#{@context.object_id}"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|