foobara 0.0.57 → 0.0.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/projects/command/lib/foobara/command.rb +3 -0
- data/projects/command/src/command/concerns/shortcut_for_run.rb +62 -0
- data/projects/command/src/command.rb +3 -36
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/callbacks.rb +3 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/description.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/domain_mappers.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/entities.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/errors.rb +3 -2
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/errors_type.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/inputs.rb +7 -2
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/inputs_type.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/namespace.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/reflection.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/result.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/result_type.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/runtime.rb +1 -39
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/state_machine.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/subcommands.rb +1 -1
- data/projects/command/src/{concerns → command_pattern_implementation/concerns}/transactions.rb +1 -1
- data/projects/command/src/command_pattern_implementation.rb +38 -0
- data/projects/domain_mapper/src/domain_mapper.rb +3 -3
- data/projects/enumerated/src/values.rb +4 -0
- metadata +20 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73dea1ae2bd36b295db67678c8d5717458a386b0a1bd11fbf5fffd4adf117a6a
|
4
|
+
data.tar.gz: 1b99f0f9e5294302d13061240696c05d7c6542291aaaec8f6049c8f5eef69800
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b03089aee29a4d85bebc9dccbe8bfe32b3891fa81689fda604f28ab0d3c9909f516b34f73c6370bea9c3b4da3a49569cd9da57319245b482ada56142b0b8bf05
|
7
|
+
data.tar.gz: 931145ba8982bb71388135b95262b321f9b0ac3f1b9dc77ee8cd64e5f701083e0f46fb0332bb5844fb642ddfcebe268c3e6e12888a67f08f82fa574788b00a18
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
module Foobara
|
2
|
+
class Command
|
3
|
+
module Concerns
|
4
|
+
module ShortcutForRun
|
5
|
+
include Concern
|
6
|
+
|
7
|
+
on_include do
|
8
|
+
Command.after_subclass_defined do |subclass|
|
9
|
+
Command.all << subclass
|
10
|
+
# This results in being able to use the command class name instead of .run! if you want.
|
11
|
+
# So instead of DoIt.run!(inputs) you can just do DoIt(inputs)
|
12
|
+
# TODO: can we kill this? I don't think anything uses this nor would really need to.
|
13
|
+
# Calling code could define such helper methods if desired but could be a bad idea since it is nice for
|
14
|
+
# command calls to stick out as command calls which would be less obvious if they just looked like random
|
15
|
+
# method calls (except that they are class case instead of underscore case)
|
16
|
+
subclass.define_command_named_function
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module ClassMethods
|
21
|
+
def define_command_named_function
|
22
|
+
command_class = self
|
23
|
+
convenience_method_name = Foobara::Util.non_full_name(command_class)
|
24
|
+
containing_module = Foobara::Util.module_for(command_class) || Object
|
25
|
+
|
26
|
+
if containing_module.is_a?(::Class)
|
27
|
+
containing_module.singleton_class.define_method convenience_method_name do |*args, **opts, &block|
|
28
|
+
command_class.run!(*args, **opts, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
containing_module.define_method convenience_method_name do |*args, **opts, &block|
|
32
|
+
command_class.run!(*args, **opts, &block)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
containing_module.module_eval do
|
36
|
+
module_function
|
37
|
+
|
38
|
+
define_method convenience_method_name do |*args, **opts, &block|
|
39
|
+
command_class.run!(*args, **opts, &block)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def undefine_command_named_function
|
46
|
+
command_class = self
|
47
|
+
convenience_method_name = Foobara::Util.non_full_name(command_class)
|
48
|
+
containing_module = Foobara::Util.module_for(command_class) || Object
|
49
|
+
|
50
|
+
return unless containing_module.respond_to?(convenience_method_name)
|
51
|
+
|
52
|
+
containing_module.singleton_class.undef_method convenience_method_name
|
53
|
+
|
54
|
+
if containing_module.is_a?(::Class)
|
55
|
+
containing_module.undef_method convenience_method_name
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,40 +1,7 @@
|
|
1
1
|
module Foobara
|
2
2
|
class Command
|
3
|
-
include
|
4
|
-
|
5
|
-
include Concerns::
|
6
|
-
include Concerns::Namespace
|
7
|
-
|
8
|
-
include Concerns::InputsType
|
9
|
-
include Concerns::ErrorsType
|
10
|
-
include Concerns::ResultType
|
11
|
-
|
12
|
-
include Concerns::Inputs
|
13
|
-
include Concerns::Errors
|
14
|
-
include Concerns::Result
|
15
|
-
|
16
|
-
include Concerns::Runtime
|
17
|
-
include Concerns::Callbacks
|
18
|
-
include Concerns::StateMachine
|
19
|
-
include Concerns::Transactions
|
20
|
-
include Concerns::Entities
|
21
|
-
include Concerns::Subcommands
|
22
|
-
include Concerns::DomainMappers
|
23
|
-
include Concerns::Reflection
|
24
|
-
|
25
|
-
# TODO: this feels like a hack and shouldn't be necessary. Let's try to fix Concern class inheritance, instead.
|
26
|
-
self.subclass_defined_callbacks ||= Foobara::Callback::Registry::SingleAction.new
|
27
|
-
|
28
|
-
attr_reader :raw_inputs
|
29
|
-
|
30
|
-
def initialize(inputs = {})
|
31
|
-
@raw_inputs = inputs
|
32
|
-
super()
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
Command.after_subclass_defined do |subclass|
|
37
|
-
Command.all << subclass
|
38
|
-
subclass.define_command_named_function
|
3
|
+
include CommandPatternImplementation
|
4
|
+
# Maybe make ShortcutForRun optional and maybe even move it to a different repository?
|
5
|
+
include Concerns::ShortcutForRun
|
39
6
|
end
|
40
7
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Foobara
|
2
|
-
|
2
|
+
module CommandPatternImplementation
|
3
3
|
module Concerns
|
4
4
|
module Callbacks
|
5
5
|
include Concern
|
@@ -25,6 +25,8 @@ module Foobara
|
|
25
25
|
end
|
26
26
|
|
27
27
|
on_include do
|
28
|
+
self.subclass_defined_callbacks ||= Foobara::Callback::Registry::SingleAction.new
|
29
|
+
|
28
30
|
[self, singleton_class].each do |target|
|
29
31
|
%i[before after].each do |type|
|
30
32
|
target.define_method "#{type}_any_transition" do |&block|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Foobara
|
2
|
-
|
2
|
+
module CommandPatternImplementation
|
3
3
|
module Concerns
|
4
4
|
module Errors
|
5
5
|
include Concern
|
@@ -46,8 +46,9 @@ module Foobara
|
|
46
46
|
|
47
47
|
attr_reader :error_collection
|
48
48
|
|
49
|
-
def initialize
|
49
|
+
def initialize(...)
|
50
50
|
@error_collection = ErrorCollection.new
|
51
|
+
super
|
51
52
|
end
|
52
53
|
|
53
54
|
foobara_delegate :has_errors?, to: :error_collection
|
@@ -1,12 +1,17 @@
|
|
1
1
|
module Foobara
|
2
|
-
|
2
|
+
module CommandPatternImplementation
|
3
3
|
module Concerns
|
4
4
|
module Inputs
|
5
5
|
class UnexpectedInputValidationError < StandardError; end
|
6
6
|
|
7
7
|
include Concern
|
8
8
|
|
9
|
-
attr_reader :inputs
|
9
|
+
attr_reader :inputs, :raw_inputs
|
10
|
+
|
11
|
+
def initialize(inputs = {})
|
12
|
+
@raw_inputs = inputs
|
13
|
+
super()
|
14
|
+
end
|
10
15
|
|
11
16
|
def method_missing(method_name, *args, &)
|
12
17
|
if respond_to_missing_for_inputs?(method_name)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Foobara
|
2
|
-
|
2
|
+
module CommandPatternImplementation
|
3
3
|
module Concerns
|
4
4
|
module Runtime
|
5
5
|
include Concern
|
@@ -15,44 +15,6 @@ module Foobara
|
|
15
15
|
def run!(...)
|
16
16
|
new(...).run!
|
17
17
|
end
|
18
|
-
|
19
|
-
def define_command_named_function
|
20
|
-
command_class = self
|
21
|
-
convenience_method_name = Foobara::Util.non_full_name(command_class)
|
22
|
-
containing_module = Foobara::Util.module_for(command_class) || Object
|
23
|
-
|
24
|
-
if containing_module.is_a?(::Class)
|
25
|
-
containing_module.singleton_class.define_method convenience_method_name do |*args, **opts, &block|
|
26
|
-
command_class.run!(*args, **opts, &block)
|
27
|
-
end
|
28
|
-
|
29
|
-
containing_module.define_method convenience_method_name do |*args, **opts, &block|
|
30
|
-
command_class.run!(*args, **opts, &block)
|
31
|
-
end
|
32
|
-
else
|
33
|
-
containing_module.module_eval do
|
34
|
-
module_function
|
35
|
-
|
36
|
-
define_method convenience_method_name do |*args, **opts, &block|
|
37
|
-
command_class.run!(*args, **opts, &block)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def undefine_command_named_function
|
44
|
-
command_class = self
|
45
|
-
convenience_method_name = Foobara::Util.non_full_name(command_class)
|
46
|
-
containing_module = Foobara::Util.module_for(command_class) || Object
|
47
|
-
|
48
|
-
return unless containing_module.respond_to?(convenience_method_name)
|
49
|
-
|
50
|
-
containing_module.singleton_class.undef_method convenience_method_name
|
51
|
-
|
52
|
-
if containing_module.is_a?(::Class)
|
53
|
-
containing_module.undef_method convenience_method_name
|
54
|
-
end
|
55
|
-
end
|
56
18
|
end
|
57
19
|
|
58
20
|
attr_reader :outcome, :exception
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Foobara
|
2
|
+
# We distinguish between "Foobara Command" and the "command pattern".
|
3
|
+
#
|
4
|
+
# A "Foobara Command" encapsulates a high-level business operation and serves as the public interface to its domain.
|
5
|
+
#
|
6
|
+
# The "command pattern" encapsulates an operation behind an interface that supports .new(inputs), #run which returns
|
7
|
+
# an outcome which implements #success?, #result, and #errors.
|
8
|
+
#
|
9
|
+
# All "Foobara Command"s implement the "command pattern" but not all implementations of the "command pattern"
|
10
|
+
# are "Foobara Command"s. An example is DomainMappers. They happen to use the "command pattern" since it is a good
|
11
|
+
# fit but has nothing to do with a public interface high-level business operation encapsulation like a
|
12
|
+
# "Foobara Command" does.
|
13
|
+
module CommandPatternImplementation
|
14
|
+
include Concern
|
15
|
+
|
16
|
+
include TruncatedInspect
|
17
|
+
|
18
|
+
include CommandPatternImplementation::Concerns::Description
|
19
|
+
include CommandPatternImplementation::Concerns::Namespace
|
20
|
+
|
21
|
+
include CommandPatternImplementation::Concerns::InputsType
|
22
|
+
include CommandPatternImplementation::Concerns::ErrorsType
|
23
|
+
include CommandPatternImplementation::Concerns::ResultType
|
24
|
+
|
25
|
+
include CommandPatternImplementation::Concerns::Inputs
|
26
|
+
include CommandPatternImplementation::Concerns::Errors
|
27
|
+
include CommandPatternImplementation::Concerns::Result
|
28
|
+
|
29
|
+
include CommandPatternImplementation::Concerns::Runtime
|
30
|
+
include CommandPatternImplementation::Concerns::Callbacks
|
31
|
+
include CommandPatternImplementation::Concerns::StateMachine
|
32
|
+
include CommandPatternImplementation::Concerns::Transactions
|
33
|
+
include CommandPatternImplementation::Concerns::Entities
|
34
|
+
include CommandPatternImplementation::Concerns::Subcommands
|
35
|
+
include CommandPatternImplementation::Concerns::DomainMappers
|
36
|
+
include CommandPatternImplementation::Concerns::Reflection
|
37
|
+
end
|
38
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Foobara
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class DomainMapper
|
3
|
+
include CommandPatternImplementation
|
4
|
+
|
5
5
|
class << self
|
6
6
|
def map(value)
|
7
7
|
new(from: value).run
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.58
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-20 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bigdecimal
|
@@ -131,22 +131,24 @@ files:
|
|
131
131
|
- projects/callback/src/set.rb
|
132
132
|
- projects/command/lib/foobara/command.rb
|
133
133
|
- projects/command/src/command.rb
|
134
|
-
- projects/command/src/concerns/
|
135
|
-
- projects/command/src/
|
136
|
-
- projects/command/src/concerns/
|
137
|
-
- projects/command/src/concerns/
|
138
|
-
- projects/command/src/concerns/
|
139
|
-
- projects/command/src/concerns/
|
140
|
-
- projects/command/src/concerns/
|
141
|
-
- projects/command/src/concerns/
|
142
|
-
- projects/command/src/concerns/
|
143
|
-
- projects/command/src/concerns/
|
144
|
-
- projects/command/src/concerns/
|
145
|
-
- projects/command/src/concerns/
|
146
|
-
- projects/command/src/concerns/
|
147
|
-
- projects/command/src/concerns/
|
148
|
-
- projects/command/src/concerns/
|
149
|
-
- projects/command/src/concerns/
|
134
|
+
- projects/command/src/command/concerns/shortcut_for_run.rb
|
135
|
+
- projects/command/src/command_pattern_implementation.rb
|
136
|
+
- projects/command/src/command_pattern_implementation/concerns/callbacks.rb
|
137
|
+
- projects/command/src/command_pattern_implementation/concerns/description.rb
|
138
|
+
- projects/command/src/command_pattern_implementation/concerns/domain_mappers.rb
|
139
|
+
- projects/command/src/command_pattern_implementation/concerns/entities.rb
|
140
|
+
- projects/command/src/command_pattern_implementation/concerns/errors.rb
|
141
|
+
- projects/command/src/command_pattern_implementation/concerns/errors_type.rb
|
142
|
+
- projects/command/src/command_pattern_implementation/concerns/inputs.rb
|
143
|
+
- projects/command/src/command_pattern_implementation/concerns/inputs_type.rb
|
144
|
+
- projects/command/src/command_pattern_implementation/concerns/namespace.rb
|
145
|
+
- projects/command/src/command_pattern_implementation/concerns/reflection.rb
|
146
|
+
- projects/command/src/command_pattern_implementation/concerns/result.rb
|
147
|
+
- projects/command/src/command_pattern_implementation/concerns/result_type.rb
|
148
|
+
- projects/command/src/command_pattern_implementation/concerns/runtime.rb
|
149
|
+
- projects/command/src/command_pattern_implementation/concerns/state_machine.rb
|
150
|
+
- projects/command/src/command_pattern_implementation/concerns/subcommands.rb
|
151
|
+
- projects/command/src/command_pattern_implementation/concerns/transactions.rb
|
150
152
|
- projects/command/src/state_machine.rb
|
151
153
|
- projects/command/src/transformed_command.rb
|
152
154
|
- projects/command_connectors/lib/foobara/command_connectors.rb
|