eventception 0.0.1 → 0.1.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/CHANGELOG.md +21 -2
- data/Gemfile.lock +16 -1
- data/LICENSE +165 -0
- data/README.md +11 -1
- data/eventception.gemspec +4 -1
- data/examples/todo_list/run.rb +18 -0
- data/examples/todo_list/todo.rb +19 -0
- data/examples/todo_list/todo_created_event.rb +19 -0
- data/examples/todo_list/todo_listener.rb +19 -0
- data/lib/eventception.rb +1 -0
- data/lib/eventception/base_subscriber.rb +19 -0
- data/lib/eventception/dispatcher.rb +76 -0
- data/lib/eventception/event.rb +19 -0
- data/lib/eventception/immutable_dispatcher.rb +122 -0
- data/lib/eventception/listener_handler.rb +19 -0
- data/lib/eventception/priority_listeners.rb +19 -0
- data/lib/eventception/version.rb +1 -1
- data/pkg/eventception-0.0.1.gem +0 -0
- data/spec/eventception/dispatcher_spec.rb +20 -0
- data/spec/eventception/immutable_dispatcher_spec.rb +61 -0
- data/spec/eventception/listener_handler_spec.rb +19 -0
- data/spec/examples/todo_list_spec.rb +19 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/listener.rb +19 -0
- data/spec/support/subscriber.rb +19 -0
- data/spec/support/test_event.rb +19 -0
- metadata +49 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f854c8c737febfffaab07c28270e82c956f874a4
|
4
|
+
data.tar.gz: 288483563809c33e1caf0c013ceaa13a8d982542
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdfbee3158f0324e2cdc53ffbea7ae1784067bc151a6522fded984daab89ff25acb24acf39cabfc78997d5160f0e4488bc113c8cc4b6089ce682daa0a531a083
|
7
|
+
data.tar.gz: efdf934fe595c79c3dc467fd2252a3756894865ff93ee10d3f037044ba6b07c39ab75a446c83b354519cf258c0a42bbf31c490223c2c1d719e569bd02da2e629
|
data/CHANGELOG.md
CHANGED
@@ -3,8 +3,27 @@ All notable changes to this project will be documented in this file. This change
|
|
3
3
|
|
4
4
|
## [Unreleased]
|
5
5
|
|
6
|
-
|
6
|
+
#### Adds
|
7
|
+
|
8
|
+
* Your contribution here.
|
9
|
+
|
10
|
+
#### Changes
|
11
|
+
|
12
|
+
* Your contribution here.
|
13
|
+
|
14
|
+
## v0.1.0 - 2017-07-14
|
15
|
+
|
16
|
+
#### Adds
|
17
|
+
|
18
|
+
* [#13](https://github.com/dcsg/eventception/pull/13): Add an Immutable Dispatcher - [@dcsg](https://github.com/dcsg).
|
19
|
+
|
20
|
+
#### Changes
|
21
|
+
|
22
|
+
* [#11](https://github.com/dcsg/eventception/pull/11): Change the license from MIT to GNU LGPLv3 - [@dcsg](https://github.com/dcsg).
|
23
|
+
|
24
|
+
## v0.0.1 - 2017-07-13
|
7
25
|
|
8
26
|
First release
|
9
27
|
|
10
|
-
[Unreleased]: https://github.com/dcsg/eventception/compare/
|
28
|
+
[Unreleased]: https://github.com/dcsg/eventception/compare/v0.1.0...HEAD
|
29
|
+
[v0.1.0]: https://github.com/dcsg/eventception/compare/v0.0.1...v0.1.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
eventception (0.0
|
4
|
+
eventception (0.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -10,6 +10,8 @@ GEM
|
|
10
10
|
byebug (9.0.6)
|
11
11
|
coderay (1.1.1)
|
12
12
|
diff-lcs (1.3)
|
13
|
+
docile (1.1.5)
|
14
|
+
json (2.0.3)
|
13
15
|
method_source (0.8.2)
|
14
16
|
parallel (1.11.2)
|
15
17
|
parser (2.4.0.0)
|
@@ -46,6 +48,16 @@ GEM
|
|
46
48
|
ruby-progressbar (~> 1.7)
|
47
49
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
48
50
|
ruby-progressbar (1.8.1)
|
51
|
+
simplecov (0.14.1)
|
52
|
+
docile (~> 1.1.0)
|
53
|
+
json (>= 1.8, < 3)
|
54
|
+
simplecov-html (~> 0.10.0)
|
55
|
+
simplecov-html (0.10.1)
|
56
|
+
simplecov-json (0.2)
|
57
|
+
json
|
58
|
+
simplecov
|
59
|
+
simplecov-rcov (0.2.3)
|
60
|
+
simplecov (>= 0.4.1)
|
49
61
|
slop (3.6.0)
|
50
62
|
unicode-display_width (1.3.0)
|
51
63
|
|
@@ -60,6 +72,9 @@ DEPENDENCIES
|
|
60
72
|
rake
|
61
73
|
rspec (~> 3.6)
|
62
74
|
rubocop
|
75
|
+
simplecov
|
76
|
+
simplecov-json
|
77
|
+
simplecov-rcov
|
63
78
|
|
64
79
|
BUNDLED WITH
|
65
80
|
1.15.1
|
data/LICENSE
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## Eventception
|
2
2
|
|
3
|
-
[](https://travis-ci.org/dcsg/eventception)
|
3
|
+
[](https://travis-ci.org/dcsg/eventception) [](https://codeclimate.com/github/dcsg/eventception) [](https://codeclimate.com/github/dcsg/eventception/coverage)
|
4
4
|
|
5
5
|
Eventception is a lightweight and simple Ruby Event System inspired on [Symfony Event Dispatcher](https://symfony.com/doc/current/components/event_dispatcher.html).
|
6
6
|
|
@@ -78,8 +78,18 @@ dispatcher.dispatch(TodoCreatedEvent::NAME, event)
|
|
78
78
|
# STDOUT: created a new to-do with title: 'My To-do'
|
79
79
|
```
|
80
80
|
|
81
|
+
## LICENSE
|
82
|
+
|
83
|
+
Licensed under [GNU LGPLv3](https://github.com/dcsg/eventception/blob/master/LICENSE)
|
84
|
+
|
81
85
|
## Contributing
|
82
86
|
|
87
|
+
1. Fork it
|
88
|
+
2. Create your feature branch (git checkout -b my-new-feature)
|
89
|
+
3. Commit your changes (git commit -am 'Add some feature')
|
90
|
+
4. Push to the branch (git push origin my-new-feature)
|
91
|
+
5. Create new Pull Request
|
92
|
+
|
83
93
|
## Contributors
|
84
94
|
|
85
95
|
* [Daniel Gomes](https://github.com/dcsg)
|
data/eventception.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.homepage = 'https://github.com/dcsg/eventception'
|
12
12
|
spec.summary = 'Eventception - a lightweight and simple Ruby Event System.'
|
13
13
|
spec.description = 'A lightweight and simple Ruby Event System inspired on Symfony Event Dispatcher.'
|
14
|
-
spec.license = '
|
14
|
+
spec.license = 'LGPL-3.0+'
|
15
15
|
|
16
16
|
spec.files = Dir['**/*'].keep_if { |file| File.file?(file) }
|
17
17
|
spec.test_files = Dir['spec/**/*']
|
@@ -22,6 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency 'rspec', '~> 3.6'
|
23
23
|
spec.add_development_dependency 'rake'
|
24
24
|
spec.add_development_dependency 'rubocop'
|
25
|
+
spec.add_development_dependency 'simplecov'
|
26
|
+
spec.add_development_dependency 'simplecov-json'
|
27
|
+
spec.add_development_dependency 'simplecov-rcov'
|
25
28
|
spec.add_development_dependency 'pry'
|
26
29
|
spec.add_development_dependency 'pry-byebug' unless RUBY_PLATFORM == 'java'
|
27
30
|
spec.add_development_dependency 'pry-debugger-jruby' if RUBY_PLATFORM == 'java'
|
data/examples/todo_list/run.rb
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
1
19
|
require 'eventception'
|
2
20
|
require_relative 'todo_created_event'
|
3
21
|
require_relative 'todo_listener'
|
data/examples/todo_list/todo.rb
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
1
20
|
module TodoList
|
2
21
|
class Todo
|
3
22
|
attr_reader :title
|
@@ -1,7 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Eventception: A lightweight and simple Ruby Event System
|
4
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
5
|
+
#
|
6
|
+
# This file is part of Eventception.
|
7
|
+
#
|
8
|
+
# Eventception is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# Eventception is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU Lesser General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU Lesser General Public License
|
19
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
3
21
|
require 'eventception'
|
4
22
|
|
23
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
5
24
|
module TodoList
|
6
25
|
class TodoCreatedEvent < Eventception::Event
|
7
26
|
NAME = 'todo.created'.freeze
|
@@ -1,3 +1,22 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
1
20
|
module TodoList
|
2
21
|
class TodoListener
|
3
22
|
def on_creation(event)
|
data/lib/eventception.rb
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Eventception: A lightweight and simple Ruby Event System
|
4
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
5
|
+
#
|
6
|
+
# This file is part of Eventception.
|
7
|
+
#
|
8
|
+
# Eventception is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# Eventception is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU Lesser General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU Lesser General Public License
|
19
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
3
22
|
module Eventception
|
4
23
|
class BaseSubscriber
|
5
24
|
def subscribed_events
|
@@ -1,6 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Eventception: A lightweight and simple Ruby Event System
|
4
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
5
|
+
#
|
6
|
+
# This file is part of Eventception.
|
7
|
+
#
|
8
|
+
# Eventception is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# Eventception is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU Lesser General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU Lesser General Public License
|
19
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
1
21
|
require 'eventception/priority_listeners'
|
2
22
|
require 'eventception/listener_handler'
|
3
23
|
|
24
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
25
|
+
# @author Ivo Anjo <ivo.anjo@ist.utl.pt>
|
4
26
|
module Eventception
|
5
27
|
class Dispatcher
|
6
28
|
private
|
@@ -69,6 +91,10 @@ module Eventception
|
|
69
91
|
|
70
92
|
# Gets all listeners for the specific event sorted by descending priority.
|
71
93
|
#
|
94
|
+
# == Parameters:
|
95
|
+
# event_name::
|
96
|
+
# The name of the event
|
97
|
+
#
|
72
98
|
# == Returns:
|
73
99
|
# The event listeners for the specific event sorted by descending priority.
|
74
100
|
#
|
@@ -82,6 +108,10 @@ module Eventception
|
|
82
108
|
|
83
109
|
# Checks whether are any registered listeners for the specific event.
|
84
110
|
#
|
111
|
+
# == Parameters:
|
112
|
+
# event_name::
|
113
|
+
# The name of the event
|
114
|
+
#
|
85
115
|
# == Returns:
|
86
116
|
# Boolean
|
87
117
|
#
|
@@ -96,9 +126,14 @@ module Eventception
|
|
96
126
|
# The event to listen on
|
97
127
|
# listener::
|
98
128
|
# The listener
|
129
|
+
# listener_method::
|
130
|
+
# The name of the method to be executed in the listener
|
99
131
|
# priority::
|
100
132
|
# The higher this value, the earlier an event listener will be triggered in the chain (defaults to 0)
|
101
133
|
#
|
134
|
+
# == Returns:
|
135
|
+
# Nil
|
136
|
+
#
|
102
137
|
def add_listener(event_name:, listener:, listener_method:, priority: 0)
|
103
138
|
event_listeners[event_name][priority] << ListenerHandler.new(listener, listener_method)
|
104
139
|
sorted.delete(event_name)
|
@@ -106,6 +141,19 @@ module Eventception
|
|
106
141
|
nil
|
107
142
|
end
|
108
143
|
|
144
|
+
# Removes an event listener from the specified events.
|
145
|
+
#
|
146
|
+
# == Parameters:
|
147
|
+
# event_name::
|
148
|
+
# The event to listen on
|
149
|
+
# listener::
|
150
|
+
# The listener
|
151
|
+
# listener_method::
|
152
|
+
# The name of the method to be executed in the listener
|
153
|
+
#
|
154
|
+
# == Returns:
|
155
|
+
# Nil
|
156
|
+
#
|
109
157
|
def remove_listener(event_name:, listener:, listener_method:)
|
110
158
|
return unless listeners_for?(event_name: event_name)
|
111
159
|
|
@@ -118,6 +166,8 @@ module Eventception
|
|
118
166
|
end
|
119
167
|
|
120
168
|
event_listeners.delete(event_name) if listener_for_event.empty?
|
169
|
+
|
170
|
+
nil
|
121
171
|
end
|
122
172
|
|
123
173
|
# Add an event subscriber.
|
@@ -128,6 +178,9 @@ module Eventception
|
|
128
178
|
# subscriber::
|
129
179
|
# The subscriber
|
130
180
|
#
|
181
|
+
# == Returns:
|
182
|
+
# Nil
|
183
|
+
#
|
131
184
|
def add_subscriber(subscriber:)
|
132
185
|
subscriber.subscribed_events.each do |event_subscribed|
|
133
186
|
add_listener(
|
@@ -137,8 +190,21 @@ module Eventception
|
|
137
190
|
priority: event_subscribed[:priority] || 0,
|
138
191
|
)
|
139
192
|
end
|
193
|
+
|
194
|
+
nil
|
140
195
|
end
|
141
196
|
|
197
|
+
# Removes an event subscriber.
|
198
|
+
#
|
199
|
+
# The subscriber is asked for all the events he is interested in and added as a listener for these events.
|
200
|
+
#
|
201
|
+
# == Parameters:
|
202
|
+
# subscriber::
|
203
|
+
# The subscriber
|
204
|
+
#
|
205
|
+
# == Returns:
|
206
|
+
# Nil
|
207
|
+
#
|
142
208
|
def remove_subscriber(subscriber:)
|
143
209
|
subscriber.subscribed_events.each do |event_subscribed|
|
144
210
|
remove_listener(
|
@@ -147,6 +213,8 @@ module Eventception
|
|
147
213
|
listener_method: event_subscribed.fetch(:listener_method),
|
148
214
|
)
|
149
215
|
end
|
216
|
+
|
217
|
+
nil
|
150
218
|
end
|
151
219
|
|
152
220
|
protected
|
@@ -161,6 +229,9 @@ module Eventception
|
|
161
229
|
# event::
|
162
230
|
# The event
|
163
231
|
#
|
232
|
+
# == Returns:
|
233
|
+
# Nil
|
234
|
+
#
|
164
235
|
def do_dispatch(listeners:, event:)
|
165
236
|
listeners.each do |_priority, priority_listeners|
|
166
237
|
priority_listeners.each do |listener_handler|
|
@@ -181,8 +252,13 @@ module Eventception
|
|
181
252
|
# event_name::
|
182
253
|
# The event name
|
183
254
|
#
|
255
|
+
# == Returns:
|
256
|
+
# Nil
|
257
|
+
#
|
184
258
|
def sort_listeners(event_name)
|
185
259
|
sorted[event_name] = event_listeners[event_name].sort_by { |key, _| -key }.to_h
|
260
|
+
|
261
|
+
nil
|
186
262
|
end
|
187
263
|
end
|
188
264
|
end
|
data/lib/eventception/event.rb
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
1
20
|
module Eventception
|
2
21
|
class Event
|
3
22
|
private
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Eventception: A lightweight and simple Ruby Event System
|
4
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
5
|
+
#
|
6
|
+
# This file is part of Eventception.
|
7
|
+
#
|
8
|
+
# Eventception is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# Eventception is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU Lesser General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU Lesser General Public License
|
19
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
22
|
+
module Eventception
|
23
|
+
class ImmutableDispatcher
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :dispatcher
|
27
|
+
|
28
|
+
public
|
29
|
+
|
30
|
+
# Creates an unmodifiable proxy for an event dispatcher.
|
31
|
+
#
|
32
|
+
# == Parameters:
|
33
|
+
# listeners::
|
34
|
+
# Array of event listeners
|
35
|
+
# subscribers::
|
36
|
+
# Array of event subscribers
|
37
|
+
#
|
38
|
+
# == Returns:
|
39
|
+
# Nil
|
40
|
+
#
|
41
|
+
def initialize(listeners: [], subscribers: [])
|
42
|
+
@dispatcher = Eventception::Dispatcher.new
|
43
|
+
|
44
|
+
listeners.each do |listener|
|
45
|
+
dispatcher.add_listener(
|
46
|
+
event_name: listener.fetch(:event_name),
|
47
|
+
listener: listener.fetch(:listener),
|
48
|
+
listener_method: listener.fetch(:listener_method),
|
49
|
+
priority: listener.fetch(:priority, 0),
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
subscribers.each { |subscriber| dispatcher.add_subscriber(subscriber: subscriber) }
|
54
|
+
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
|
58
|
+
# Dispatches an event to all registered listeners.
|
59
|
+
#
|
60
|
+
# == Parameters:
|
61
|
+
# event_name::
|
62
|
+
# The name of the event to dispatch. The name of
|
63
|
+
# the event is the name of the method that is
|
64
|
+
# invoked on listeners.
|
65
|
+
# event::
|
66
|
+
# The event to pass to the event handlers/listeners
|
67
|
+
# If not supplied, an empty Event instance is created.
|
68
|
+
#
|
69
|
+
# == Returns:
|
70
|
+
# The Event.
|
71
|
+
#
|
72
|
+
def dispatch(event_name:, event: Eventception::Event.new)
|
73
|
+
dispatcher.dispatch(event_name: event_name, event: event)
|
74
|
+
|
75
|
+
event
|
76
|
+
end
|
77
|
+
|
78
|
+
# Gets all listeners sorted by descending priority.
|
79
|
+
#
|
80
|
+
# == Returns:
|
81
|
+
# All event listeners sorted by event_name and descending priority.
|
82
|
+
#
|
83
|
+
def listeners
|
84
|
+
dispatcher.listeners
|
85
|
+
end
|
86
|
+
|
87
|
+
# Checks whether are any registered listeners.
|
88
|
+
#
|
89
|
+
# == Returns:
|
90
|
+
# Boolean
|
91
|
+
#
|
92
|
+
def listeners?
|
93
|
+
dispatcher.listeners?
|
94
|
+
end
|
95
|
+
|
96
|
+
# Gets all listeners for the specific event sorted by descending priority.
|
97
|
+
#
|
98
|
+
# == Parameters:
|
99
|
+
# event_name::
|
100
|
+
# The name of the event
|
101
|
+
#
|
102
|
+
# == Returns:
|
103
|
+
# The event listeners for the specific event sorted by descending priority.
|
104
|
+
#
|
105
|
+
def listeners_for(event_name:)
|
106
|
+
dispatcher.listeners_for(event_name: event_name)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Checks whether are any registered listeners for the specific event.
|
110
|
+
#
|
111
|
+
# == Parameters:
|
112
|
+
# event_name::
|
113
|
+
# The name of the event
|
114
|
+
#
|
115
|
+
# == Returns:
|
116
|
+
# Boolean
|
117
|
+
#
|
118
|
+
def listeners_for?(event_name:)
|
119
|
+
dispatcher.listeners_for?(event_name: event_name)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -1,3 +1,22 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
1
20
|
module Eventception
|
2
21
|
class ListenerHandler
|
3
22
|
attr_reader :listener
|
@@ -1,3 +1,22 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# @author Ivo Anjo <ivo.anjo@ist.utl.pt>
|
1
20
|
module Eventception
|
2
21
|
class PriorityListeners
|
3
22
|
include Enumerable
|
data/lib/eventception/version.rb
CHANGED
data/pkg/eventception-0.0.1.gem
CHANGED
Binary file
|
@@ -1,9 +1,29 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
1
19
|
require 'spec_helper'
|
2
20
|
require 'support/listener'
|
3
21
|
require 'support/subscriber'
|
4
22
|
require 'support/test_event'
|
5
23
|
require 'eventception/listener_handler'
|
6
24
|
|
25
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
26
|
+
# @author Ivo Anjo <ivo.anjo@ist.utl.pt>
|
7
27
|
describe Eventception::Dispatcher do
|
8
28
|
subject(:dispatcher) { described_class.new }
|
9
29
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
require 'support/listener'
|
21
|
+
require 'support/subscriber'
|
22
|
+
require 'support/test_event'
|
23
|
+
|
24
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
25
|
+
describe Eventception::ImmutableDispatcher do
|
26
|
+
subject(:dispatcher) { described_class.new(listeners: listeners, subscribers: subscribers) }
|
27
|
+
|
28
|
+
let(:listener) { Eventception::Support::Listener.new }
|
29
|
+
let(:listener_method) { 'on_before' }
|
30
|
+
let(:listeners) { [] }
|
31
|
+
let(:subscriber) { Eventception::Support::Subscriber.new }
|
32
|
+
let(:subscribers) { [] }
|
33
|
+
let(:event_name) { :on_after }
|
34
|
+
let(:priority) { 0 }
|
35
|
+
|
36
|
+
describe '#initialize' do
|
37
|
+
context 'when one listener is provided' do
|
38
|
+
let(:listeners) {
|
39
|
+
[
|
40
|
+
{event_name: event_name, listener: listener, listener_method: listener_method, priority: priority},
|
41
|
+
]
|
42
|
+
}
|
43
|
+
|
44
|
+
it 'then a listener is registered' do
|
45
|
+
expect(dispatcher.listeners?).to be true
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'then it have one listener registered' do
|
49
|
+
expect(dispatcher.listeners.size).to eq 1
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'then a listener for the event \'on_before\' is registered' do
|
53
|
+
expect(dispatcher.listeners_for?(event_name: event_name)).to be true
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'then no listeners are registered for an invalid event name' do
|
57
|
+
expect(dispatcher.listeners_for?(event_name: :invalid)).to be false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -1,3 +1,21 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
1
19
|
require 'eventception'
|
2
20
|
require 'spec_helper'
|
3
21
|
require 'support/listener'
|
@@ -5,6 +23,7 @@ require 'support/subscriber'
|
|
5
23
|
require 'support/test_event'
|
6
24
|
require 'support/listener'
|
7
25
|
|
26
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
8
27
|
describe Eventception::ListenerHandler do
|
9
28
|
subject(:event_handler) { described_class.new(listener, listener_method) }
|
10
29
|
|
@@ -1,3 +1,22 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# @author Ivo Anjo <ivo.anjo@ist.utl.pt>
|
1
20
|
RSpec.describe 'TodoList example' do
|
2
21
|
it 'runs without error' do
|
3
22
|
load File.expand_path('../../../examples/todo_list/run.rb', Pathname.new(__FILE__).realpath)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
1
19
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
20
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
21
|
|
@@ -5,3 +23,17 @@ require 'eventception'
|
|
5
23
|
|
6
24
|
RSpec.configure do |config|
|
7
25
|
end
|
26
|
+
|
27
|
+
if ENV['SIMPLECOV_ENABLED'] == '1'
|
28
|
+
require 'simplecov'
|
29
|
+
require 'simplecov-json'
|
30
|
+
require 'simplecov-rcov'
|
31
|
+
|
32
|
+
SimpleCov.formatters = [
|
33
|
+
SimpleCov::Formatter::HTMLFormatter,
|
34
|
+
SimpleCov::Formatter::JSONFormatter,
|
35
|
+
SimpleCov::Formatter::RcovFormatter,
|
36
|
+
]
|
37
|
+
|
38
|
+
SimpleCov.start
|
39
|
+
end
|
data/spec/support/listener.rb
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
1
20
|
module Eventception
|
2
21
|
module Support
|
3
22
|
class Listener
|
data/spec/support/subscriber.rb
CHANGED
@@ -1,6 +1,25 @@
|
|
1
|
+
# Eventception: A lightweight and simple Ruby Event System
|
2
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
3
|
+
#
|
4
|
+
# This file is part of Eventception.
|
5
|
+
#
|
6
|
+
# Eventception is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Eventception is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
1
19
|
require 'eventception'
|
2
20
|
require_relative 'test_event'
|
3
21
|
|
22
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
4
23
|
module Eventception
|
5
24
|
module Support
|
6
25
|
class Subscriber < Eventception::BaseSubscriber
|
data/spec/support/test_event.rb
CHANGED
@@ -1,7 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Eventception: A lightweight and simple Ruby Event System
|
4
|
+
# Copyright (C) 2017 Daniel Gomes <danielcesargomes@gmail.com>
|
5
|
+
#
|
6
|
+
# This file is part of Eventception.
|
7
|
+
#
|
8
|
+
# Eventception is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# Eventception is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU Lesser General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU Lesser General Public License
|
19
|
+
# along with Eventception. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
3
21
|
require 'eventception'
|
4
22
|
|
23
|
+
# @author Daniel Gomes <danielcesargomes@gmail.com>
|
5
24
|
module Eventception
|
6
25
|
module Support
|
7
26
|
class TestEvent < Eventception::Event
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventception
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Gomes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-07-
|
12
|
+
date: 2017-07-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -67,6 +67,48 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: simplecov
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: simplecov-json
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: simplecov-rcov
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
70
112
|
- !ruby/object:Gem::Dependency
|
71
113
|
name: pry
|
72
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,6 +149,7 @@ files:
|
|
107
149
|
- CHANGELOG.md
|
108
150
|
- Gemfile
|
109
151
|
- Gemfile.lock
|
152
|
+
- LICENSE
|
110
153
|
- README.md
|
111
154
|
- Rakefile
|
112
155
|
- eventception.gemspec
|
@@ -118,11 +161,13 @@ files:
|
|
118
161
|
- lib/eventception/base_subscriber.rb
|
119
162
|
- lib/eventception/dispatcher.rb
|
120
163
|
- lib/eventception/event.rb
|
164
|
+
- lib/eventception/immutable_dispatcher.rb
|
121
165
|
- lib/eventception/listener_handler.rb
|
122
166
|
- lib/eventception/priority_listeners.rb
|
123
167
|
- lib/eventception/version.rb
|
124
168
|
- pkg/eventception-0.0.1.gem
|
125
169
|
- spec/eventception/dispatcher_spec.rb
|
170
|
+
- spec/eventception/immutable_dispatcher_spec.rb
|
126
171
|
- spec/eventception/listener_handler_spec.rb
|
127
172
|
- spec/examples/todo_list_spec.rb
|
128
173
|
- spec/spec_helper.rb
|
@@ -131,7 +176,7 @@ files:
|
|
131
176
|
- spec/support/test_event.rb
|
132
177
|
homepage: https://github.com/dcsg/eventception
|
133
178
|
licenses:
|
134
|
-
-
|
179
|
+
- LGPL-3.0+
|
135
180
|
metadata: {}
|
136
181
|
post_install_message:
|
137
182
|
rdoc_options: []
|
@@ -155,6 +200,7 @@ specification_version: 4
|
|
155
200
|
summary: Eventception - a lightweight and simple Ruby Event System.
|
156
201
|
test_files:
|
157
202
|
- spec/eventception/dispatcher_spec.rb
|
203
|
+
- spec/eventception/immutable_dispatcher_spec.rb
|
158
204
|
- spec/eventception/listener_handler_spec.rb
|
159
205
|
- spec/examples/todo_list_spec.rb
|
160
206
|
- spec/spec_helper.rb
|