core-event 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -14
- data/lib/core/event/callable.rb +2 -2
- data/lib/core/event/version.rb +1 -1
- data/lib/core/event.rb +66 -2
- metadata +14 -15
- data/lib/is/eventable.rb +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bca28e5be5d7527ff9759e2d41d437e3b3a01e642c3d6ab352464cc7ff055da
|
4
|
+
data.tar.gz: df4403866f60a53661546517f99d8994ab888c8c7cf1e4c6cee401763df2b600
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 743ee53607f6dbe0d8229e0064988e053633f36db4236ea231c2a8be91b934c850886f6fb32ba0c62d1bb536606a0c6ad8cca820585ff4e355a69847bd6871c3
|
7
|
+
data.tar.gz: 25f8e34d178e796e2dcf9f1407413a25966f1d3e1343980184132e1aac2879d41db4efa5fa9b641b7ee4551d042dbc4a938c2a59ff78c54ea1665ee2e8d9ef0d
|
data/CHANGELOG.md
CHANGED
@@ -1,40 +1,47 @@
|
|
1
|
-
## [v0.
|
1
|
+
## [v0.3.0](https://github.com/bryanp/corerb/releases/tag/2023-12-24)
|
2
|
+
|
3
|
+
*released on 2023-12-24*
|
4
|
+
|
5
|
+
* `dep` [#143](https://github.com/bryanp/corerb/pull/143) Deprecate `Is::*` and `Refine::*` namespaces ([bryanp](https://github.com/bryanp))
|
6
|
+
* `dep` [#135](https://github.com/bryanp/corerb/pull/135) Remove Ruby 2 support ([bryanp](https://github.com/bryanp))
|
7
|
+
|
8
|
+
## [v0.2.3](https://github.com/bryanp/corerb/releases/tag/2023-05-06)
|
2
9
|
|
3
10
|
*released on 2023-05-06*
|
4
11
|
|
5
12
|
* `fix` [#131](https://github.com/bryanp/corerb/pull/131) Fix an issue with event state isolation ([bryanp](https://github.com/bryanp))
|
6
13
|
|
7
|
-
## [v0.2.2](https://github.com/
|
14
|
+
## [v0.2.2](https://github.com/bryanp/corerb/releases/tag/2022-06-02)
|
8
15
|
|
9
16
|
*released on 2022-06-02*
|
10
17
|
|
11
|
-
* `fix` [#127](https://github.com/
|
18
|
+
* `fix` [#127](https://github.com/bryanp/corerb/pull/127) Accept all arguments in prepended finalize ([bryanp](https://github.com/bryanp))
|
12
19
|
|
13
|
-
## [v0.2.1](https://github.com/
|
20
|
+
## [v0.2.1](https://github.com/bryanp/corerb/releases/tag/2021-11-06)
|
14
21
|
|
15
22
|
*released on 2021-11-06*
|
16
23
|
|
17
|
-
* `fix` [#106](https://github.com/
|
24
|
+
* `fix` [#106](https://github.com/bryanp/corerb/pull/106) Use pipeline controller in core-event ([bryanp](https://github.com/bryanp))
|
18
25
|
|
19
|
-
## [v0.2.0](https://github.com/
|
26
|
+
## [v0.2.0](https://github.com/bryanp/corerb/releases/tag/2021-11-03)
|
20
27
|
|
21
28
|
*released on 2021-11-03*
|
22
29
|
|
23
|
-
* `fix` [#101](https://github.com/
|
24
|
-
* `add` [#100](https://github.com/
|
30
|
+
* `fix` [#101](https://github.com/bryanp/corerb/pull/101) Prevent unnecessary recompiles of the event pipeline ([bryanp](https://github.com/bryanp))
|
31
|
+
* `add` [#100](https://github.com/bryanp/corerb/pull/100) Add a finalizer to the event pipeline ([bryanp](https://github.com/bryanp))
|
25
32
|
|
26
|
-
## [v0.1.0](https://github.com/
|
33
|
+
## [v0.1.0](https://github.com/bryanp/corerb/releases/tag/2021-10-24)
|
27
34
|
|
28
35
|
*released on 2021-10-24*
|
29
36
|
|
30
|
-
* `fix` [#87](https://github.com/
|
31
|
-
* `chg` [#79](https://github.com/
|
32
|
-
* `chg` [#78](https://github.com/
|
37
|
+
* `fix` [#87](https://github.com/bryanp/corerb/pull/87) Yield to performing even when no callbacks are defined ([bryanp](https://github.com/bryanp))
|
38
|
+
* `chg` [#79](https://github.com/bryanp/corerb/pull/79) Support halt/reject from callbacks ([bryanp](https://github.com/bryanp))
|
39
|
+
* `chg` [#78](https://github.com/bryanp/corerb/pull/78) Add recompile support to eventable objects ([bryanp](https://github.com/bryanp))
|
33
40
|
|
34
|
-
## [v0.0.0](https://github.com/
|
41
|
+
## [v0.0.0](https://github.com/bryanp/corerb/releases/tag/2021-07-15)
|
35
42
|
|
36
43
|
*released on 2021-07-15*
|
37
44
|
|
38
|
-
* `add` [#60](https://github.com/
|
45
|
+
* `add` [#60](https://github.com/bryanp/corerb/pull/60) Initial implementation of the core-event gem ([bryanp](https://github.com/bryanp))
|
39
46
|
|
40
47
|
|
data/lib/core/event/callable.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "core/pipeline/callable"
|
4
4
|
|
5
|
-
require "
|
5
|
+
require "core/inspect"
|
6
6
|
|
7
7
|
require_relative "compiler"
|
8
8
|
|
@@ -11,7 +11,7 @@ module Core
|
|
11
11
|
# [public] Manages and calls an event pipeline.
|
12
12
|
#
|
13
13
|
class Callable
|
14
|
-
include
|
14
|
+
include Core::Inspect
|
15
15
|
inspects without: [:@object, :@mutex, :@pipelines]
|
16
16
|
|
17
17
|
def initialize(object)
|
data/lib/core/event/version.rb
CHANGED
data/lib/core/event.rb
CHANGED
@@ -1,9 +1,73 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "core/extension"
|
4
|
+
require "core/pipeline/behavior/controller"
|
5
|
+
require "core/state"
|
6
|
+
|
3
7
|
module Core
|
8
|
+
# [public] Add events and callbacks to an object.
|
9
|
+
#
|
4
10
|
module Event
|
11
|
+
require_relative "event/callable"
|
5
12
|
require_relative "event/version"
|
13
|
+
|
14
|
+
extend Core::Extension
|
15
|
+
|
16
|
+
applies do |extended:|
|
17
|
+
# [public] The current eventable pipeline.
|
18
|
+
#
|
19
|
+
state :events, default: Core::Event::Callable.new(extended ? singleton_class : self)
|
20
|
+
end
|
21
|
+
|
22
|
+
extends :definition do
|
23
|
+
# [public] Defines one or more events by name.
|
24
|
+
#
|
25
|
+
def event(*defined_events)
|
26
|
+
events.register(*defined_events)
|
27
|
+
end
|
28
|
+
|
29
|
+
# [public] Defines a callback to be called during, before, and/or after the given events.
|
30
|
+
#
|
31
|
+
def callback(*during, before: [], after: [], method: nil, context: nil, &block)
|
32
|
+
events.callback(*during, before: before, after: after, method: method, context: context, &block)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
extends :implementation, dependencies: [Core::Pipeline::Behavior::Controller, Core::State] do
|
37
|
+
# [public] Calls callbacks for the given event with the given arguments.
|
38
|
+
#
|
39
|
+
def performing(event, ...)
|
40
|
+
events.performing(self, event, ...)
|
41
|
+
end
|
42
|
+
|
43
|
+
# [public] Calls before callbacks for the given event with the given arguments.
|
44
|
+
#
|
45
|
+
def starting(event, ...)
|
46
|
+
events.starting(self, event, ...)
|
47
|
+
end
|
48
|
+
|
49
|
+
# [public] Calls after callbacks for the given event with the given arguments.
|
50
|
+
#
|
51
|
+
def finished(event, ...)
|
52
|
+
events.finished(self, event, ...)
|
53
|
+
end
|
54
|
+
|
55
|
+
# [public] Defines a callback to be called during, before, and/or after the given events, isolated to the instance.
|
56
|
+
#
|
57
|
+
def callback(*during, before: [], after: [], method: nil, context: nil, &block)
|
58
|
+
events.relocate(singleton_class)
|
59
|
+
events.callback(*during, before: before, after: after, method: method, context: context, &block)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
extends :implementation, prepend: true do
|
64
|
+
# [public]
|
65
|
+
#
|
66
|
+
def finalize(...)
|
67
|
+
super if defined?(super)
|
68
|
+
events.finalize
|
69
|
+
self
|
70
|
+
end
|
71
|
+
end
|
6
72
|
end
|
7
73
|
end
|
8
|
-
|
9
|
-
require_relative "../is/eventable"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: core-event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: core-extension
|
@@ -16,58 +16,58 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: core-inspect
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: core-pipeline
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
47
|
+
version: '0.6'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
54
|
+
version: '0.6'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: core-state
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.2'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.2'
|
69
69
|
description: Adds events to Ruby objects.
|
70
|
-
email: bryan@
|
70
|
+
email: bryan@bryanp.org
|
71
71
|
executables: []
|
72
72
|
extensions: []
|
73
73
|
extra_rdoc_files: []
|
@@ -78,8 +78,7 @@ files:
|
|
78
78
|
- lib/core/event/callable.rb
|
79
79
|
- lib/core/event/compiler.rb
|
80
80
|
- lib/core/event/version.rb
|
81
|
-
|
82
|
-
homepage: https://github.com/metabahn/corerb/
|
81
|
+
homepage: https://github.com/bryanp/corerb/
|
83
82
|
licenses:
|
84
83
|
- MPL-2.0
|
85
84
|
metadata: {}
|
@@ -91,14 +90,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
90
|
requirements:
|
92
91
|
- - ">="
|
93
92
|
- !ruby/object:Gem::Version
|
94
|
-
version: '
|
93
|
+
version: '3.0'
|
95
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
95
|
requirements:
|
97
96
|
- - ">="
|
98
97
|
- !ruby/object:Gem::Version
|
99
98
|
version: '0'
|
100
99
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
100
|
+
rubygems_version: 3.5.1
|
102
101
|
signing_key:
|
103
102
|
specification_version: 4
|
104
103
|
summary: Adds events to Ruby objects.
|
data/lib/is/eventable.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "is/extension"
|
4
|
-
require "is/pipeline/controller"
|
5
|
-
require "is/stateful"
|
6
|
-
|
7
|
-
require_relative "../core/event/callable"
|
8
|
-
|
9
|
-
module Is
|
10
|
-
# [public] Adds events and callbacks to an object.
|
11
|
-
#
|
12
|
-
module Eventable
|
13
|
-
extend Is::Extension
|
14
|
-
|
15
|
-
applies do |extended:|
|
16
|
-
# [public] The current eventable pipeline.
|
17
|
-
#
|
18
|
-
state :events, default: Core::Event::Callable.new(extended ? singleton_class : self)
|
19
|
-
end
|
20
|
-
|
21
|
-
extends :definition do
|
22
|
-
# [public] Defines one or more events by name.
|
23
|
-
#
|
24
|
-
def event(*defined_events)
|
25
|
-
events.register(*defined_events)
|
26
|
-
end
|
27
|
-
|
28
|
-
# [public] Defines a callback to be called during, before, and/or after the given events.
|
29
|
-
#
|
30
|
-
def callback(*during, before: [], after: [], method: nil, context: nil, &block)
|
31
|
-
events.callback(*during, before: before, after: after, method: method, context: context, &block)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
extends :implementation, dependencies: [Is::Pipeline::Controller, Is::Stateful] do
|
36
|
-
# [public] Calls callbacks for the given event with the given arguments.
|
37
|
-
#
|
38
|
-
def performing(event, ...)
|
39
|
-
events.performing(self, event, ...)
|
40
|
-
end
|
41
|
-
|
42
|
-
# [public] Calls before callbacks for the given event with the given arguments.
|
43
|
-
#
|
44
|
-
def starting(event, ...)
|
45
|
-
events.starting(self, event, ...)
|
46
|
-
end
|
47
|
-
|
48
|
-
# [public] Calls after callbacks for the given event with the given arguments.
|
49
|
-
#
|
50
|
-
def finished(event, ...)
|
51
|
-
events.finished(self, event, ...)
|
52
|
-
end
|
53
|
-
|
54
|
-
# [public] Defines a callback to be called during, before, and/or after the given events, isolated to the instance.
|
55
|
-
#
|
56
|
-
def callback(*during, before: [], after: [], method: nil, context: nil, &block)
|
57
|
-
events.relocate(singleton_class)
|
58
|
-
events.callback(*during, before: before, after: after, method: method, context: context, &block)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
extends :implementation, prepend: true do
|
63
|
-
# [public]
|
64
|
-
#
|
65
|
-
def finalize(...)
|
66
|
-
super if defined?(super)
|
67
|
-
events.finalize
|
68
|
-
self
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|