servactory 1.5.1 → 1.6.0
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/README.md +87 -50
- data/config/locales/en.yml +5 -5
- data/lib/servactory/base.rb +4 -4
- data/lib/servactory/configuration/factory.rb +6 -6
- data/lib/servactory/configuration/setup.rb +6 -6
- data/lib/servactory/context/callable.rb +21 -22
- data/lib/servactory/context/configuration.rb +6 -6
- data/lib/servactory/context/workspace/inputs.rb +13 -0
- data/lib/servactory/context/workspace.rb +9 -7
- data/lib/servactory/errors/base.rb +2 -1
- data/lib/servactory/errors/collection.rb +25 -0
- data/lib/servactory/errors/failure.rb +11 -1
- data/lib/servactory/errors/input_error.rb +17 -0
- data/lib/servactory/errors/internal_error.rb +15 -0
- data/lib/servactory/errors/output_error.rb +15 -0
- data/lib/servactory/{input_arguments → inputs}/checks/base.rb +3 -3
- data/lib/servactory/{input_arguments → inputs}/checks/errors.rb +1 -1
- data/lib/servactory/{input_arguments → inputs}/checks/inclusion.rb +7 -4
- data/lib/servactory/{input_arguments → inputs}/checks/must.rb +3 -3
- data/lib/servactory/{input_arguments → inputs}/checks/required.rb +2 -2
- data/lib/servactory/{input_arguments → inputs}/checks/type.rb +3 -3
- data/lib/servactory/{input_arguments → inputs}/collection.rb +1 -1
- data/lib/servactory/{input_arguments → inputs}/define_input_conflict.rb +1 -1
- data/lib/servactory/{input_arguments → inputs}/define_input_method.rb +1 -1
- data/lib/servactory/inputs/dsl.rb +36 -0
- data/lib/servactory/{input_arguments/input_argument.rb → inputs/input.rb} +13 -12
- data/lib/servactory/{input_arguments → inputs}/option.rb +5 -3
- data/lib/servactory/{input_arguments → inputs}/options_collection.rb +1 -1
- data/lib/servactory/{input_arguments → inputs}/tools/check.rb +5 -5
- data/lib/servactory/{input_arguments → inputs}/tools/check_errors.rb +1 -1
- data/lib/servactory/{input_arguments → inputs}/tools/find_unnecessary.rb +6 -6
- data/lib/servactory/{input_arguments → inputs}/tools/prepare.rb +5 -5
- data/lib/servactory/inputs/tools/rules.rb +46 -0
- data/lib/servactory/{input_arguments → inputs}/workbench.rb +8 -8
- data/lib/servactory/internals/checks/base.rb +17 -0
- data/lib/servactory/{internal_arguments → internals}/checks/type.rb +8 -8
- data/lib/servactory/{output_arguments → internals}/collection.rb +1 -1
- data/lib/servactory/internals/dsl.rb +33 -0
- data/lib/servactory/{internal_arguments/internal_argument.rb → internals/internal.rb} +2 -2
- data/lib/servactory/internals/tools/prepare.rb +60 -0
- data/lib/servactory/{internal_arguments → internals}/workbench.rb +5 -5
- data/lib/servactory/{make_methods → methods}/collection.rb +1 -1
- data/lib/servactory/methods/dsl.rb +33 -0
- data/lib/servactory/{make_methods/make_method.rb → methods/method.rb} +2 -2
- data/lib/servactory/{make_methods → methods}/workbench.rb +5 -5
- data/lib/servactory/outputs/checks/base.rb +17 -0
- data/lib/servactory/{output_arguments → outputs}/checks/type.rb +8 -8
- data/lib/servactory/{internal_arguments → outputs}/collection.rb +1 -1
- data/lib/servactory/outputs/dsl.rb +33 -0
- data/lib/servactory/{output_arguments/output_argument.rb → outputs/output.rb} +2 -2
- data/lib/servactory/{output_arguments → outputs}/tools/conflicts.rb +7 -7
- data/lib/servactory/outputs/tools/prepare.rb +62 -0
- data/lib/servactory/outputs/workbench.rb +31 -0
- data/lib/servactory/result.rb +4 -4
- data/lib/servactory/utils.rb +2 -0
- data/lib/servactory/version.rb +2 -2
- metadata +59 -46
- data/lib/servactory/context/workspace/error.rb +0 -19
- data/lib/servactory/context/workspace/errors.rb +0 -33
- data/lib/servactory/errors/input_argument_error.rb +0 -7
- data/lib/servactory/errors/internal_argument_error.rb +0 -7
- data/lib/servactory/errors/output_argument_error.rb +0 -7
- data/lib/servactory/input_arguments/dsl.rb +0 -36
- data/lib/servactory/input_arguments/tools/rules.rb +0 -43
- data/lib/servactory/inputs.rb +0 -9
- data/lib/servactory/internal_arguments/checks/base.rb +0 -17
- data/lib/servactory/internal_arguments/dsl.rb +0 -33
- data/lib/servactory/internal_arguments/tools/prepare.rb +0 -60
- data/lib/servactory/make_methods/dsl.rb +0 -33
- data/lib/servactory/output_arguments/checks/base.rb +0 -17
- data/lib/servactory/output_arguments/dsl.rb +0 -33
- data/lib/servactory/output_arguments/tools/prepare.rb +0 -62
- data/lib/servactory/output_arguments/workbench.rb +0 -31
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module InputArguments
|
5
|
-
module DSL
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def inherited(child)
|
12
|
-
super
|
13
|
-
|
14
|
-
child.send(:collection_of_input_arguments).merge(collection_of_input_arguments)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def input(name, **options)
|
20
|
-
collection_of_input_arguments << InputArgument.new(
|
21
|
-
name,
|
22
|
-
**options
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
def collection_of_input_arguments
|
27
|
-
@collection_of_input_arguments ||= Collection.new
|
28
|
-
end
|
29
|
-
|
30
|
-
def input_arguments_workbench
|
31
|
-
@input_arguments_workbench ||= Workbench.work_with(collection_of_input_arguments)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module InputArguments
|
5
|
-
module Tools
|
6
|
-
class Rules
|
7
|
-
def self.check!(...)
|
8
|
-
new(...).check!
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(context, collection_of_input_arguments)
|
12
|
-
@context = context
|
13
|
-
@collection_of_input_arguments = collection_of_input_arguments
|
14
|
-
end
|
15
|
-
|
16
|
-
def check!
|
17
|
-
@collection_of_input_arguments.each do |input_argument|
|
18
|
-
check_for!(input_argument)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def check_for!(input_argument)
|
25
|
-
return unless input_argument.with_conflicts?
|
26
|
-
|
27
|
-
raise_error_for(input_argument)
|
28
|
-
end
|
29
|
-
|
30
|
-
def raise_error_for(input_argument)
|
31
|
-
message_text = I18n.t(
|
32
|
-
"servactory.input_arguments.tools.rules.error",
|
33
|
-
service_class_name: @context.class.name,
|
34
|
-
input_name: input_argument.name,
|
35
|
-
conflict_code: input_argument.conflict_code
|
36
|
-
)
|
37
|
-
|
38
|
-
raise Servactory.configuration.input_argument_error_class, message_text
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/lib/servactory/inputs.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module InternalArguments
|
5
|
-
module Checks
|
6
|
-
class Base
|
7
|
-
protected
|
8
|
-
|
9
|
-
def raise_error_with(message, **arguments)
|
10
|
-
message = message.call(**arguments) if message.is_a?(Proc)
|
11
|
-
|
12
|
-
raise Servactory.configuration.internal_argument_error_class, message
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module InternalArguments
|
5
|
-
module DSL
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def inherited(child)
|
12
|
-
super
|
13
|
-
|
14
|
-
child.send(:collection_of_internal_arguments).merge(collection_of_internal_arguments)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def internal(name, **options)
|
20
|
-
collection_of_internal_arguments << InternalArgument.new(name, **options)
|
21
|
-
end
|
22
|
-
|
23
|
-
def collection_of_internal_arguments
|
24
|
-
@collection_of_internal_arguments ||= Collection.new
|
25
|
-
end
|
26
|
-
|
27
|
-
def internal_arguments_workbench
|
28
|
-
@internal_arguments_workbench ||= Workbench.work_with(collection_of_internal_arguments)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module InternalArguments
|
5
|
-
module Tools
|
6
|
-
class Prepare
|
7
|
-
def self.prepare(...)
|
8
|
-
new(...).prepare
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(context, collection_of_internal_arguments)
|
12
|
-
@context = context
|
13
|
-
@collection_of_internal_arguments = collection_of_internal_arguments
|
14
|
-
end
|
15
|
-
|
16
|
-
def prepare
|
17
|
-
@collection_of_internal_arguments.each do |internal_argument|
|
18
|
-
create_instance_variable_for(internal_argument)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def create_instance_variable_for(internal_argument)
|
25
|
-
@context.instance_variable_set(:"@#{internal_argument.name}", nil)
|
26
|
-
|
27
|
-
@context.class.class_eval(context_internal_argument_template_for(internal_argument))
|
28
|
-
end
|
29
|
-
|
30
|
-
# EXAMPLE:
|
31
|
-
#
|
32
|
-
# define_method(:user=) do |value|
|
33
|
-
# Servactory::InternalArguments::Checks::Type.check!( context: self, internal_argument:, value: )
|
34
|
-
#
|
35
|
-
# instance_variable_set(:@user, value)
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
# private attr_reader :user
|
39
|
-
#
|
40
|
-
def context_internal_argument_template_for(internal_argument)
|
41
|
-
<<-RUBY
|
42
|
-
define_method(:#{internal_argument.name}=) do |value|
|
43
|
-
Servactory::InternalArguments::Checks::Type.check!(
|
44
|
-
context: self,
|
45
|
-
internal_argument: internal_argument,
|
46
|
-
value: value
|
47
|
-
)
|
48
|
-
|
49
|
-
instance_variable_set(:@#{internal_argument.name}, value)
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
attr_reader :#{internal_argument.name}
|
55
|
-
RUBY
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module MakeMethods
|
5
|
-
module DSL
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def inherited(child)
|
12
|
-
super
|
13
|
-
|
14
|
-
child.send(:collection_of_make_methods).merge(collection_of_make_methods)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def make(name, **options)
|
20
|
-
collection_of_make_methods << MakeMethod.new(name, **options)
|
21
|
-
end
|
22
|
-
|
23
|
-
def collection_of_make_methods
|
24
|
-
@collection_of_make_methods ||= Collection.new
|
25
|
-
end
|
26
|
-
|
27
|
-
def make_methods_workbench
|
28
|
-
@make_methods_workbench ||= Workbench.work_with(collection_of_make_methods)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module OutputArguments
|
5
|
-
module Checks
|
6
|
-
class Base
|
7
|
-
protected
|
8
|
-
|
9
|
-
def raise_error_with(message, **arguments)
|
10
|
-
message = message.call(**arguments) if message.is_a?(Proc)
|
11
|
-
|
12
|
-
raise Servactory.configuration.output_argument_error_class, message
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module OutputArguments
|
5
|
-
module DSL
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def inherited(child)
|
12
|
-
super
|
13
|
-
|
14
|
-
child.send(:collection_of_output_arguments).merge(collection_of_output_arguments)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def output(name, **options)
|
20
|
-
collection_of_output_arguments << OutputArgument.new(name, **options)
|
21
|
-
end
|
22
|
-
|
23
|
-
def collection_of_output_arguments
|
24
|
-
@collection_of_output_arguments ||= Collection.new
|
25
|
-
end
|
26
|
-
|
27
|
-
def output_arguments_workbench
|
28
|
-
@output_arguments_workbench ||= Workbench.work_with(collection_of_output_arguments)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module OutputArguments
|
5
|
-
module Tools
|
6
|
-
class Prepare
|
7
|
-
def self.prepare(...)
|
8
|
-
new(...).prepare
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(context, collection_of_output_arguments)
|
12
|
-
@context = context
|
13
|
-
@collection_of_output_arguments = collection_of_output_arguments
|
14
|
-
end
|
15
|
-
|
16
|
-
def prepare
|
17
|
-
@collection_of_output_arguments.each do |output_argument|
|
18
|
-
create_instance_variable_for(output_argument)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def create_instance_variable_for(output_argument)
|
25
|
-
@context.instance_variable_set(:"@#{output_argument.name}", nil)
|
26
|
-
|
27
|
-
@context.class.class_eval(context_output_argument_template_for(output_argument))
|
28
|
-
end
|
29
|
-
|
30
|
-
# EXAMPLE:
|
31
|
-
#
|
32
|
-
# define_method(:user=) do |value|
|
33
|
-
# Servactory::InternalArguments::Checks::Type.check!( context: self, output_argument:, value: )
|
34
|
-
#
|
35
|
-
# instance_variable_set(:@user, value)
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
# private
|
39
|
-
#
|
40
|
-
# attr_reader :user
|
41
|
-
#
|
42
|
-
def context_output_argument_template_for(output_argument)
|
43
|
-
<<-RUBY
|
44
|
-
define_method(:#{output_argument.name}=) do |value|
|
45
|
-
Servactory::OutputArguments::Checks::Type.check!(
|
46
|
-
context: self,
|
47
|
-
output_argument: output_argument,
|
48
|
-
value: value
|
49
|
-
)
|
50
|
-
|
51
|
-
instance_variable_set(:@#{output_argument.name}, value)
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
attr_reader :#{output_argument.name}
|
57
|
-
RUBY
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module OutputArguments
|
5
|
-
class Workbench
|
6
|
-
def self.work_with(...)
|
7
|
-
new(...)
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize(collection_of_output_arguments)
|
11
|
-
@collection_of_output_arguments = collection_of_output_arguments
|
12
|
-
end
|
13
|
-
|
14
|
-
def assign(context:)
|
15
|
-
@context = context
|
16
|
-
end
|
17
|
-
|
18
|
-
def find_conflicts_in!(collection_of_internal_arguments:)
|
19
|
-
Tools::Conflicts.check!(context, collection_of_output_arguments, collection_of_internal_arguments)
|
20
|
-
end
|
21
|
-
|
22
|
-
def prepare
|
23
|
-
Tools::Prepare.prepare(context, collection_of_output_arguments)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
attr_reader :context, :collection_of_output_arguments
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|