servactory 2.2.3 → 2.3.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/configuration/dsl.rb +3 -3
- data/lib/servactory/configuration/factory.rb +60 -5
- data/lib/servactory/configuration/setup.rb +7 -7
- data/lib/servactory/context/workspace/inputs.rb +1 -1
- data/lib/servactory/context/workspace/internals.rb +1 -1
- data/lib/servactory/context/workspace/outputs.rb +1 -1
- data/lib/servactory/context/workspace.rb +3 -3
- data/lib/servactory/errors/failure.rb +1 -0
- data/lib/servactory/errors/input_error.rb +1 -0
- data/lib/servactory/errors/internal_error.rb +1 -0
- data/lib/servactory/errors/output_error.rb +1 -0
- data/lib/servactory/exceptions/failure.rb +19 -0
- data/lib/servactory/exceptions/input.rb +17 -0
- data/lib/servactory/exceptions/internal.rb +17 -0
- data/lib/servactory/exceptions/output.rb +17 -0
- data/lib/servactory/inputs/tools/rules.rb +1 -1
- data/lib/servactory/inputs/tools/unnecessary.rb +1 -1
- data/lib/servactory/inputs/tools/validation.rb +1 -1
- data/lib/servactory/maintenance/attributes/tools/validation.rb +1 -1
- data/lib/servactory/version.rb +2 -2
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5662ba4d5b8ad475c0cd03c3b74d8ab74f4b319799ae16b7a125bb6be7493337
|
4
|
+
data.tar.gz: ed21fb0f82de78b4672da98b7692d857da56d96fb4e855c39ada1b303b32535c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b50b74907895549d97c97b09dfeada580bf98e1dd53d96eb25ebdde73da447177350f2cabff2278adb78353b798f1f64c694ffe9f3c950b2ba6242f1442db12
|
7
|
+
data.tar.gz: bad8e985072c7a6c1b47a7392d04b7e9adeedfcfc4d269082c74c50c3f31a5060d09faac462bc07e45b5b5609a51528fc13fc5cbee316ba31aa8eed0a6eb8b0f
|
@@ -11,9 +11,9 @@ module Servactory
|
|
11
11
|
def inherited(child) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
12
12
|
super
|
13
13
|
|
14
|
-
child.config.
|
15
|
-
child.config.
|
16
|
-
child.config.
|
14
|
+
child.config.input_exception_class = config.input_exception_class
|
15
|
+
child.config.internal_exception_class = config.internal_exception_class
|
16
|
+
child.config.output_exception_class = config.output_exception_class
|
17
17
|
|
18
18
|
child.config.success_class = config.success_class
|
19
19
|
child.config.failure_class = config.failure_class
|
@@ -7,20 +7,60 @@ module Servactory
|
|
7
7
|
@config = config
|
8
8
|
end
|
9
9
|
|
10
|
+
# DEPRECATED: These configs must be deleted after release 2.4.
|
10
11
|
def input_error_class(input_error_class)
|
11
|
-
|
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)
|
12
28
|
end
|
13
29
|
|
30
|
+
# DEPRECATED: These configs must be deleted after release 2.4.
|
14
31
|
def output_error_class(output_error_class)
|
15
|
-
|
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)
|
16
38
|
end
|
17
39
|
|
18
|
-
def
|
19
|
-
@config.
|
40
|
+
def input_exception_class(input_exception_class)
|
41
|
+
return @config.input_exception_class = input_exception_class if subclass_of_exception?(input_exception_class)
|
42
|
+
|
43
|
+
raise_error_about_wrong_exception_class_with(:input_exception_class, input_exception_class)
|
44
|
+
end
|
45
|
+
|
46
|
+
def internal_exception_class(internal_exception_class)
|
47
|
+
if subclass_of_exception?(internal_exception_class)
|
48
|
+
return @config.internal_exception_class = internal_exception_class
|
49
|
+
end
|
50
|
+
|
51
|
+
raise_error_about_wrong_exception_class_with(:internal_exception_class, internal_exception_class)
|
52
|
+
end
|
53
|
+
|
54
|
+
def output_exception_class(output_exception_class)
|
55
|
+
return @config.output_exception_class = output_exception_class if subclass_of_exception?(output_exception_class)
|
56
|
+
|
57
|
+
raise_error_about_wrong_exception_class_with(:output_exception_class, output_exception_class)
|
20
58
|
end
|
21
59
|
|
22
60
|
def failure_class(failure_class)
|
23
|
-
@config.failure_class = failure_class
|
61
|
+
return @config.failure_class = failure_class if subclass_of_exception?(failure_class)
|
62
|
+
|
63
|
+
raise_error_about_wrong_exception_class_with(:failure_class, failure_class)
|
24
64
|
end
|
25
65
|
|
26
66
|
def collection_mode_class_names(collection_mode_class_names)
|
@@ -50,6 +90,21 @@ module Servactory
|
|
50
90
|
def action_shortcuts(action_shortcuts)
|
51
91
|
@config.action_shortcuts.merge(action_shortcuts)
|
52
92
|
end
|
93
|
+
|
94
|
+
##########################################################################
|
95
|
+
|
96
|
+
def subclass_of_exception?(value)
|
97
|
+
value.is_a?(Class) && value <= Exception
|
98
|
+
end
|
99
|
+
|
100
|
+
##########################################################################
|
101
|
+
|
102
|
+
def raise_error_about_wrong_exception_class_with(config_name, value)
|
103
|
+
raise ArgumentError,
|
104
|
+
"Error in `#{config_name}` configuration. " \
|
105
|
+
"The `#{value}` value must be a subclass of `Exception`. " \
|
106
|
+
"See example configuration here: https://servactory.com/guide/configuration"
|
107
|
+
end
|
53
108
|
end
|
54
109
|
end
|
55
110
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module Servactory
|
4
4
|
module Configuration
|
5
5
|
class Setup
|
6
|
-
attr_accessor :
|
7
|
-
:
|
8
|
-
:
|
6
|
+
attr_accessor :input_exception_class,
|
7
|
+
:internal_exception_class,
|
8
|
+
:output_exception_class,
|
9
9
|
:success_class,
|
10
10
|
:failure_class,
|
11
11
|
:collection_mode_class_names,
|
@@ -17,12 +17,12 @@ module Servactory
|
|
17
17
|
:action_shortcuts
|
18
18
|
|
19
19
|
def initialize # rubocop:disable Metrics/MethodLength
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
20
|
+
@input_exception_class = Servactory::Exceptions::Input
|
21
|
+
@internal_exception_class = Servactory::Exceptions::Internal
|
22
|
+
@output_exception_class = Servactory::Exceptions::Output
|
23
23
|
|
24
24
|
@success_class = Servactory::Exceptions::Success
|
25
|
-
@failure_class = Servactory::
|
25
|
+
@failure_class = Servactory::Exceptions::Failure
|
26
26
|
|
27
27
|
@collection_mode_class_names =
|
28
28
|
Servactory::Maintenance::CollectionMode::ClassNamesCollection.new(default_collection_mode_class_names)
|
@@ -104,7 +104,7 @@ module Servactory
|
|
104
104
|
input_name: name
|
105
105
|
)
|
106
106
|
|
107
|
-
raise @context.class.config.
|
107
|
+
raise @context.class.config.input_exception_class.new(message: message_text, input_name: name)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -30,21 +30,21 @@ module Servactory
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def fail_input!(input_name, message:)
|
33
|
-
raise self.class.config.
|
33
|
+
raise self.class.config.input_exception_class.new(
|
34
34
|
input_name: input_name,
|
35
35
|
message: message
|
36
36
|
)
|
37
37
|
end
|
38
38
|
|
39
39
|
def fail_internal!(internal_name, message:)
|
40
|
-
raise self.class.config.
|
40
|
+
raise self.class.config.internal_exception_class.new(
|
41
41
|
internal_name: internal_name,
|
42
42
|
message: message
|
43
43
|
)
|
44
44
|
end
|
45
45
|
|
46
46
|
def fail_output!(output_name, message:)
|
47
|
-
raise self.class.config.
|
47
|
+
raise self.class.config.output_exception_class.new(
|
48
48
|
output_name: output_name,
|
49
49
|
message: message
|
50
50
|
)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module Exceptions
|
5
|
+
class Failure < Base
|
6
|
+
attr_reader :type,
|
7
|
+
:message,
|
8
|
+
:meta
|
9
|
+
|
10
|
+
def initialize(type: :base, message:, meta: nil) # rubocop:disable Style/KeywordParametersOrder
|
11
|
+
@type = type
|
12
|
+
@message = message
|
13
|
+
@meta = meta
|
14
|
+
|
15
|
+
super(message)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module Exceptions
|
5
|
+
class Input < Base
|
6
|
+
attr_reader :message,
|
7
|
+
:input_name
|
8
|
+
|
9
|
+
def initialize(message:, input_name: nil)
|
10
|
+
@message = message
|
11
|
+
@input_name = input_name&.to_sym
|
12
|
+
|
13
|
+
super(message)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module Exceptions
|
5
|
+
class Internal < Base
|
6
|
+
attr_reader :message,
|
7
|
+
:internal_name
|
8
|
+
|
9
|
+
def initialize(message:, internal_name: nil)
|
10
|
+
@message = message
|
11
|
+
@internal_name = internal_name&.to_sym
|
12
|
+
|
13
|
+
super(message)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module Exceptions
|
5
|
+
class Output < Base
|
6
|
+
attr_reader :message,
|
7
|
+
:output_name
|
8
|
+
|
9
|
+
def initialize(message:, output_name: nil)
|
10
|
+
@message = message
|
11
|
+
@output_name = output_name&.to_sym
|
12
|
+
|
13
|
+
super(message)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -23,7 +23,7 @@ module Servactory
|
|
23
23
|
unnecessary_attributes: unnecessary_attributes.join(", ")
|
24
24
|
)
|
25
25
|
|
26
|
-
raise @context.class.config.
|
26
|
+
raise @context.class.config.input_exception_class.new(message: message_text)
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
@@ -73,7 +73,7 @@ module Servactory
|
|
73
73
|
def raise_errors
|
74
74
|
return if (tmp_errors = errors.not_blank).empty?
|
75
75
|
|
76
|
-
raise @context.class.config.
|
76
|
+
raise @context.class.config.input_exception_class.new(message: tmp_errors.first)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -71,7 +71,7 @@ module Servactory
|
|
71
71
|
return if (tmp_errors = errors.not_blank).empty?
|
72
72
|
|
73
73
|
raise @context.class.config
|
74
|
-
.public_send(:"#{@attribute.system_name}
|
74
|
+
.public_send(:"#{@attribute.system_name}_exception_class")
|
75
75
|
.new(message: tmp_errors.first)
|
76
76
|
end
|
77
77
|
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.3.0
|
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-03-
|
11
|
+
date: 2024-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -265,6 +265,10 @@ files:
|
|
265
265
|
- lib/servactory/errors/internal_error.rb
|
266
266
|
- lib/servactory/errors/output_error.rb
|
267
267
|
- lib/servactory/exceptions/base.rb
|
268
|
+
- lib/servactory/exceptions/failure.rb
|
269
|
+
- lib/servactory/exceptions/input.rb
|
270
|
+
- lib/servactory/exceptions/internal.rb
|
271
|
+
- lib/servactory/exceptions/output.rb
|
268
272
|
- lib/servactory/exceptions/success.rb
|
269
273
|
- lib/servactory/info/dsl.rb
|
270
274
|
- lib/servactory/info/result.rb
|