servactory 2.7.0 → 2.9.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/configuration/factory.rb +1 -31
- data/lib/servactory/context/callable.rb +6 -4
- data/lib/servactory/result.rb +11 -0
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb +1 -1
- data/lib/servactory/utils.rb +28 -1
- data/lib/servactory/version.rb +2 -2
- metadata +16 -6
- data/lib/servactory/errors/failure.rb +0 -20
- data/lib/servactory/errors/input_error.rb +0 -20
- data/lib/servactory/errors/internal_error.rb +0 -20
- data/lib/servactory/errors/output_error.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca75399cdb14c4dc3b28703e9c3b2baf353f0612d8414de865f780a69dc56e74
|
4
|
+
data.tar.gz: 74c08748d40a6233942c5c4b0b34f7b0ccb0a63776468d98ea08fda660b826fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f48fd065703fde42c80f14dae2045ea1af0c31d66c5eece2ccd4cb94358c089d7ca4e59417588a6f40dbd77376786377ad4ef90285f4d6a545925d5ecc0f0f8e
|
7
|
+
data.tar.gz: c495107855b7a1939717457638e7171ef1deb9f979426dbdc5084c84ecc78b87bc38688a71df458a9afc5ee5befe7141c78122f7f071af00c5120ef15a0480a7
|
@@ -2,41 +2,11 @@
|
|
2
2
|
|
3
3
|
module Servactory
|
4
4
|
module Configuration
|
5
|
-
class Factory
|
5
|
+
class Factory
|
6
6
|
def initialize(config)
|
7
7
|
@config = config
|
8
8
|
end
|
9
9
|
|
10
|
-
# DEPRECATED: These configs must be deleted after release 2.4.
|
11
|
-
def input_error_class(input_error_class)
|
12
|
-
Kernel.warn "DEPRECATION WARNING: " \
|
13
|
-
"Configuration `input_error_class` is deprecated; " \
|
14
|
-
"use `internal_exception_class` instead. " \
|
15
|
-
"It will be removed in one of the next releases."
|
16
|
-
|
17
|
-
input_exception_class(input_error_class)
|
18
|
-
end
|
19
|
-
|
20
|
-
# DEPRECATED: These configs must be deleted after release 2.4.
|
21
|
-
def internal_error_class(internal_error_class)
|
22
|
-
Kernel.warn "DEPRECATION WARNING: " \
|
23
|
-
"Configuration `internal_error_class` is deprecated; " \
|
24
|
-
"use `internal_exception_class` instead. " \
|
25
|
-
"It will be removed in one of the next releases."
|
26
|
-
|
27
|
-
internal_exception_class(internal_error_class)
|
28
|
-
end
|
29
|
-
|
30
|
-
# DEPRECATED: These configs must be deleted after release 2.4.
|
31
|
-
def output_error_class(output_error_class)
|
32
|
-
Kernel.warn "DEPRECATION WARNING: " \
|
33
|
-
"Configuration `output_error_class` is deprecated; " \
|
34
|
-
"use `output_exception_class` instead. " \
|
35
|
-
"It will be removed in one of the next releases."
|
36
|
-
|
37
|
-
output_exception_class(output_error_class)
|
38
|
-
end
|
39
|
-
|
40
10
|
def input_exception_class(input_exception_class)
|
41
11
|
return @config.input_exception_class = input_exception_class if subclass_of_exception?(input_exception_class)
|
42
12
|
|
@@ -6,7 +6,7 @@ module Servactory
|
|
6
6
|
def call!(arguments = {})
|
7
7
|
context = send(:new)
|
8
8
|
|
9
|
-
_call!(context,
|
9
|
+
_call!(context, arguments)
|
10
10
|
|
11
11
|
config.result_class.success_for(context:)
|
12
12
|
rescue config.success_class => e
|
@@ -16,7 +16,7 @@ module Servactory
|
|
16
16
|
def call(arguments = {})
|
17
17
|
context = send(:new)
|
18
18
|
|
19
|
-
_call!(context,
|
19
|
+
_call!(context, arguments)
|
20
20
|
|
21
21
|
config.result_class.success_for(context:)
|
22
22
|
rescue config.success_class => e
|
@@ -27,10 +27,12 @@ module Servactory
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
def _call!(context,
|
30
|
+
def _call!(context, incoming_arguments)
|
31
|
+
incoming_arguments = Servactory::Utils.adapt(incoming_arguments)
|
32
|
+
|
31
33
|
context.send(
|
32
34
|
:_call!,
|
33
|
-
incoming_arguments
|
35
|
+
incoming_arguments:,
|
34
36
|
collection_of_inputs:,
|
35
37
|
collection_of_internals:,
|
36
38
|
collection_of_outputs:,
|
data/lib/servactory/result.rb
CHANGED
@@ -27,6 +27,9 @@ module Servactory
|
|
27
27
|
|
28
28
|
############################################################################
|
29
29
|
|
30
|
+
STATE_PREDICATE_NAMES = %i[success? failure?].freeze
|
31
|
+
private_constant :STATE_PREDICATE_NAMES
|
32
|
+
|
30
33
|
def self.success_for(context:)
|
31
34
|
new(context:).send(:as_success)
|
32
35
|
end
|
@@ -40,6 +43,14 @@ module Servactory
|
|
40
43
|
@exception = exception
|
41
44
|
end
|
42
45
|
|
46
|
+
def to_h
|
47
|
+
filtered = methods(false).filter do |key|
|
48
|
+
!key.in?(STATE_PREDICATE_NAMES) && !key.to_s.end_with?("?")
|
49
|
+
end
|
50
|
+
|
51
|
+
filtered.to_h { |key| [key, public_send(key)] }.compact
|
52
|
+
end
|
53
|
+
|
43
54
|
def inspect
|
44
55
|
"#<#{self.class.name} #{draw_result}>"
|
45
56
|
end
|
data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb
CHANGED
@@ -13,7 +13,7 @@ module Servactory
|
|
13
13
|
@attribute_type = attribute_type
|
14
14
|
@attribute_type_plural = attribute_type.to_s.pluralize.to_sym
|
15
15
|
@attribute_name = attribute_name
|
16
|
-
@attributes = attributes
|
16
|
+
@attributes = attributes.is_a?(FalseClass) ? attributes : Servactory::Utils.adapt(attributes)
|
17
17
|
|
18
18
|
@attribute_data = described_class.info.public_send(attribute_type_plural).fetch(attribute_name)
|
19
19
|
|
data/lib/servactory/utils.rb
CHANGED
@@ -2,7 +2,15 @@
|
|
2
2
|
|
3
3
|
module Servactory
|
4
4
|
module Utils
|
5
|
-
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def adapt(data)
|
8
|
+
if defined?(Datory::Base) && data.is_a?(Datory::Base)
|
9
|
+
data = Servactory::Utils.send(:instance_variables_to_hash_from, data)
|
10
|
+
end
|
11
|
+
|
12
|
+
data.symbolize_keys
|
13
|
+
end
|
6
14
|
|
7
15
|
def fetch_hash_with_desired_attribute(attribute)
|
8
16
|
return { input: attribute.class::Actor.new(attribute) } if really_input?(attribute)
|
@@ -97,5 +105,24 @@ module Servactory
|
|
97
105
|
class_or_name
|
98
106
|
end
|
99
107
|
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def instance_variables_to_hash_from(data) # rubocop:disable Metrics/MethodLength
|
112
|
+
data.instance_variables.to_h do |key|
|
113
|
+
value = data.instance_variable_get(key)
|
114
|
+
|
115
|
+
value =
|
116
|
+
if value.is_a?(Set) || value.is_a?(Array)
|
117
|
+
value.map { |item| instance_variables_to_hash_from(item) }
|
118
|
+
elsif value.is_a?(Datory::Base)
|
119
|
+
instance_variables_to_hash_from(value)
|
120
|
+
else
|
121
|
+
value
|
122
|
+
end
|
123
|
+
|
124
|
+
[key.to_s.delete_prefix("@"), value]
|
125
|
+
end
|
126
|
+
end
|
100
127
|
end
|
101
128
|
end
|
data/lib/servactory/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,6 +86,20 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '1.31'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: datory
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 2.1.0
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.1.0
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
104
|
name: pry
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -271,10 +285,6 @@ files:
|
|
271
285
|
- lib/servactory/context/workspace/outputs.rb
|
272
286
|
- lib/servactory/dsl.rb
|
273
287
|
- lib/servactory/engine.rb
|
274
|
-
- lib/servactory/errors/failure.rb
|
275
|
-
- lib/servactory/errors/input_error.rb
|
276
|
-
- lib/servactory/errors/internal_error.rb
|
277
|
-
- lib/servactory/errors/output_error.rb
|
278
288
|
- lib/servactory/exceptions/base.rb
|
279
289
|
- lib/servactory/exceptions/failure.rb
|
280
290
|
- lib/servactory/exceptions/input.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module Errors
|
5
|
-
# DEPRECATED: This class will be deleted after release 2.4.
|
6
|
-
class Failure < Servactory::Exceptions::Base
|
7
|
-
attr_reader :type,
|
8
|
-
:message,
|
9
|
-
:meta
|
10
|
-
|
11
|
-
def initialize(type: :base, message:, meta: nil) # rubocop:disable Style/KeywordParametersOrder
|
12
|
-
@type = type
|
13
|
-
@message = message
|
14
|
-
@meta = meta
|
15
|
-
|
16
|
-
super(message)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module Errors
|
5
|
-
# DEPRECATED: This class will be deleted after release 2.4.
|
6
|
-
class InputError < Servactory::Exceptions::Base
|
7
|
-
attr_reader :message,
|
8
|
-
:input_name,
|
9
|
-
:meta
|
10
|
-
|
11
|
-
def initialize(message:, input_name: nil, meta: nil)
|
12
|
-
@message = message
|
13
|
-
@input_name = input_name&.to_sym
|
14
|
-
@meta = meta
|
15
|
-
|
16
|
-
super(message)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module Errors
|
5
|
-
# DEPRECATED: This class will be deleted after release 2.4.
|
6
|
-
class InternalError < Servactory::Exceptions::Base
|
7
|
-
attr_reader :message,
|
8
|
-
:internal_name,
|
9
|
-
:meta
|
10
|
-
|
11
|
-
def initialize(message:, internal_name: nil, meta: nil)
|
12
|
-
@message = message
|
13
|
-
@internal_name = internal_name&.to_sym
|
14
|
-
@meta = meta
|
15
|
-
|
16
|
-
super(message)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module Errors
|
5
|
-
# DEPRECATED: This class will be deleted after release 2.4.
|
6
|
-
class OutputError < Servactory::Exceptions::Base
|
7
|
-
attr_reader :message,
|
8
|
-
:output_name,
|
9
|
-
:meta
|
10
|
-
|
11
|
-
def initialize(message:, output_name: nil, meta: nil)
|
12
|
-
@message = message
|
13
|
-
@output_name = output_name&.to_sym
|
14
|
-
@meta = meta
|
15
|
-
|
16
|
-
super(message)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|