callable_tree 0.3.3 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callable_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - jsmmr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-19 00:00:00.000000000 Z
11
+ date: 2022-03-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Builds a tree by linking callable nodes. The nodes that match the conditions
14
14
  are called in a chain from the root node to the leaf node. These are like nested
@@ -33,23 +33,32 @@ files:
33
33
  - bin/console
34
34
  - bin/setup
35
35
  - callable_tree.gemspec
36
+ - examples/builder/hooks-caller.rb
37
+ - examples/builder/internal-broadcastable.rb
38
+ - examples/builder/internal-composable.rb
39
+ - examples/builder/internal-seekable.rb
40
+ - examples/builder/logging.rb
36
41
  - examples/docs/animals.json
37
42
  - examples/docs/animals.xml
38
43
  - examples/docs/fruits.json
39
44
  - examples/docs/fruits.xml
40
45
  - examples/external-verbosify.rb
41
- - examples/hooks-call.rb
46
+ - examples/hooks-caller.rb
42
47
  - examples/identity.rb
43
- - examples/internal-broadcast.rb
44
- - examples/internal-compose.rb
45
- - examples/internal-seek.rb
48
+ - examples/internal-broadcastable.rb
49
+ - examples/internal-composable.rb
50
+ - examples/internal-seekable.rb
46
51
  - examples/logging.rb
47
52
  - lib/callable_tree.rb
48
53
  - lib/callable_tree/node.rb
54
+ - lib/callable_tree/node/builder.rb
49
55
  - lib/callable_tree/node/external.rb
56
+ - lib/callable_tree/node/external/builder.rb
50
57
  - lib/callable_tree/node/external/verbose.rb
51
- - lib/callable_tree/node/hooks/call.rb
58
+ - lib/callable_tree/node/hooks/caller.rb
59
+ - lib/callable_tree/node/hooks/matcher.rb
52
60
  - lib/callable_tree/node/internal.rb
61
+ - lib/callable_tree/node/internal/builder.rb
53
62
  - lib/callable_tree/node/internal/strategy.rb
54
63
  - lib/callable_tree/node/internal/strategy/broadcast.rb
55
64
  - lib/callable_tree/node/internal/strategy/compose.rb
@@ -62,7 +71,7 @@ licenses:
62
71
  metadata:
63
72
  homepage_uri: https://github.com/jsmmr/ruby_callable_tree
64
73
  source_code_uri: https://github.com/jsmmr/ruby_callable_tree
65
- changelog_uri: https://github.com/jsmmr/ruby_callable_tree/blob/v0.3.3/CHANGELOG.md
74
+ changelog_uri: https://github.com/jsmmr/ruby_callable_tree/blob/v0.3.6/CHANGELOG.md
66
75
  post_install_message:
67
76
  rdoc_options: []
68
77
  require_paths:
@@ -78,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
87
  - !ruby/object:Gem::Version
79
88
  version: '0'
80
89
  requirements: []
81
- rubygems_version: 3.3.3
90
+ rubygems_version: 3.3.7
82
91
  signing_key:
83
92
  specification_version: 4
84
93
  summary: Builds a tree by linking callable nodes. The nodes that match the conditions
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CallableTree
4
- module Node
5
- module Hooks
6
- module Call
7
- def self.included(_subclass)
8
- raise ::CallableTree::Error, "#{self} must be prepended"
9
- end
10
-
11
- def before_call(&block)
12
- clone.before_call!(&block)
13
- end
14
-
15
- def before_call!(&block)
16
- before_callbacks << block
17
- self
18
- end
19
-
20
- def around_call(&block)
21
- clone.around_call!(&block)
22
- end
23
-
24
- def around_call!(&block)
25
- around_callbacks << block
26
- self
27
- end
28
-
29
- def after_call(&block)
30
- clone.after_call!(&block)
31
- end
32
-
33
- def after_call!(&block)
34
- after_callbacks << block
35
- self
36
- end
37
-
38
- def call(*inputs, **options)
39
- input_head, *input_tail = inputs
40
-
41
- input_head = before_callbacks.reduce(input_head) do |input_head, callable|
42
- callable.call(input_head, *input_tail, self, **options)
43
- end
44
-
45
- output = super(input_head, *input_tail, **options)
46
-
47
- output = around_callbacks.reduce(output) do |output, callable|
48
- callable.call(input_head, *input_tail, self, **options) { output }
49
- end
50
-
51
- after_callbacks.reduce(output) do |output, callable|
52
- callable.call(output, self, **options)
53
- end
54
- end
55
-
56
- def before_callbacks
57
- @before_callbacks ||= []
58
- end
59
-
60
- def around_callbacks
61
- @around_callbacks ||= []
62
- end
63
-
64
- def after_callbacks
65
- @after_callbacks ||= []
66
- end
67
-
68
- private
69
-
70
- attr_writer :before_callbacks, :around_callbacks, :after_callbacks
71
-
72
- def initialize_copy(_node)
73
- super
74
- self.before_callbacks = before_callbacks.map(&:itself)
75
- self.around_callbacks = around_callbacks.map(&:itself)
76
- self.after_callbacks = after_callbacks.map(&:itself)
77
- end
78
- end
79
- end
80
- end
81
- end