core-event 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e13d20e07e469eaa28b8fda8cfdb55a81e13142959f448679d51c1477f3f44f5
4
- data.tar.gz: 43a00e18aba884d4f9bd00468856aeaf8f0c96a92dc9b50bd60be36f2ec25c83
3
+ metadata.gz: 0bca28e5be5d7527ff9759e2d41d437e3b3a01e642c3d6ab352464cc7ff055da
4
+ data.tar.gz: df4403866f60a53661546517f99d8994ab888c8c7cf1e4c6cee401763df2b600
5
5
  SHA512:
6
- metadata.gz: 1899688796c6f87462b76390d9227aa2c528805b421123abe81db8c4c01ebbd824ae2b9f3006c68f366e70b39a52b950055040ccec1c591bdf20f9093ac82c09
7
- data.tar.gz: 1ccd996291cc2cce213ad759edc0986e2b5659e65c0c5d23aff7c2883b2b466db84cd66c904a33351d256f6d748314dc6829b876659cdd013b666e3c9fdf3753
6
+ metadata.gz: 743ee53607f6dbe0d8229e0064988e053633f36db4236ea231c2a8be91b934c850886f6fb32ba0c62d1bb536606a0c6ad8cca820585ff4e355a69847bd6871c3
7
+ data.tar.gz: 25f8e34d178e796e2dcf9f1407413a25966f1d3e1343980184132e1aac2879d41db4efa5fa9b641b7ee4551d042dbc4a938c2a59ff78c54ea1665ee2e8d9ef0d
data/CHANGELOG.md CHANGED
@@ -1,34 +1,47 @@
1
- ## [v0.2.2](https://github.com/metabahn/corerb/releases/tag/2022-06-02)
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)
9
+
10
+ *released on 2023-05-06*
11
+
12
+ * `fix` [#131](https://github.com/bryanp/corerb/pull/131) Fix an issue with event state isolation ([bryanp](https://github.com/bryanp))
13
+
14
+ ## [v0.2.2](https://github.com/bryanp/corerb/releases/tag/2022-06-02)
2
15
 
3
16
  *released on 2022-06-02*
4
17
 
5
- * `fix` [#127](https://github.com/metabahn/corerb/pull/127) Accept all arguments in prepended finalize ([bryanp](https://github.com/bryanp))
18
+ * `fix` [#127](https://github.com/bryanp/corerb/pull/127) Accept all arguments in prepended finalize ([bryanp](https://github.com/bryanp))
6
19
 
7
- ## [v0.2.1](https://github.com/metabahn/corerb/releases/tag/2021-11-06)
20
+ ## [v0.2.1](https://github.com/bryanp/corerb/releases/tag/2021-11-06)
8
21
 
9
22
  *released on 2021-11-06*
10
23
 
11
- * `fix` [#106](https://github.com/metabahn/corerb/pull/106) Use pipeline controller in core-event ([bryanp](https://github.com/bryanp))
24
+ * `fix` [#106](https://github.com/bryanp/corerb/pull/106) Use pipeline controller in core-event ([bryanp](https://github.com/bryanp))
12
25
 
13
- ## [v0.2.0](https://github.com/metabahn/corerb/releases/tag/2021-11-03)
26
+ ## [v0.2.0](https://github.com/bryanp/corerb/releases/tag/2021-11-03)
14
27
 
15
28
  *released on 2021-11-03*
16
29
 
17
- * `fix` [#101](https://github.com/metabahn/corerb/pull/101) Prevent unnecessary recompiles of the event pipeline ([bryanp](https://github.com/bryanp))
18
- * `add` [#100](https://github.com/metabahn/corerb/pull/100) Add a finalizer to the event pipeline ([bryanp](https://github.com/bryanp))
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))
19
32
 
20
- ## [v0.1.0](https://github.com/metabahn/corerb/releases/tag/2021-10-24)
33
+ ## [v0.1.0](https://github.com/bryanp/corerb/releases/tag/2021-10-24)
21
34
 
22
35
  *released on 2021-10-24*
23
36
 
24
- * `fix` [#87](https://github.com/metabahn/corerb/pull/87) Yield to performing even when no callbacks are defined ([bryanp](https://github.com/bryanp))
25
- * `chg` [#79](https://github.com/metabahn/corerb/pull/79) Support halt/reject from callbacks ([bryanp](https://github.com/bryanp))
26
- * `chg` [#78](https://github.com/metabahn/corerb/pull/78) Add recompile support to eventable objects ([bryanp](https://github.com/bryanp))
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))
27
40
 
28
- ## [v0.0.0](https://github.com/metabahn/corerb/releases/tag/2021-07-15)
41
+ ## [v0.0.0](https://github.com/bryanp/corerb/releases/tag/2021-07-15)
29
42
 
30
43
  *released on 2021-07-15*
31
44
 
32
- * `add` [#60](https://github.com/metabahn/corerb/pull/60) Initial implementation of the core-event gem ([bryanp](https://github.com/bryanp))
45
+ * `add` [#60](https://github.com/bryanp/corerb/pull/60) Initial implementation of the core-event gem ([bryanp](https://github.com/bryanp))
33
46
 
34
47
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "core/pipeline/callable"
4
4
 
5
- require "is/inspectable"
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 Is::Inspectable
14
+ include Core::Inspect
15
15
  inspects without: [:@object, :@mutex, :@pipelines]
16
16
 
17
17
  def initialize(object)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Core
4
4
  module Event
5
- VERSION = "0.2.2"
5
+ VERSION = "0.3.0"
6
6
 
7
7
  def self.version
8
8
  VERSION
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.2.2
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: 2022-06-03 00:00:00.000000000 Z
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.3'
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.3'
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.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.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.5'
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.5'
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.1'
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.1'
68
+ version: '0.2'
69
69
  description: Adds events to Ruby objects.
70
- email: bryan@metabahn.com
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
- - lib/is/eventable.rb
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: '2.7'
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.3.13
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