tilia-event 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ebd104e4bd4fad29c5d9b324e24c1947e488411d
4
+ data.tar.gz: 30025c76c470a73c763b392a9b773079ccbd3cc2
5
+ SHA512:
6
+ metadata.gz: 4fb4120ef5c5c4c9fd815254811821f0923dd49256068cae465b331f6b36f9a5795a231203a1ddc841a19f149d8882fa287cb346db58211fc651e5a8d3dfc9c5
7
+ data.tar.gz: 71dc762483506d3320b0c88a7c1d42657ab8410ff492ed0da39b4e15a6f1a5a073f39e379381a26f1aaa5e50719e656ef33951012c48075354537822108f3a8a
@@ -0,0 +1,19 @@
1
+ # Gem files
2
+ /*.gem
3
+
4
+ # backup files
5
+ *~
6
+
7
+ # swap files
8
+ *.swp
9
+ *.kate-swp
10
+
11
+ # file manager files
12
+ *.directory
13
+
14
+ # coverage
15
+ /coverage
16
+
17
+ # documentation
18
+ /doc
19
+ /.yardoc
@@ -0,0 +1,32 @@
1
+ # Disable metrics - we stick to the sabre coding
2
+ Metrics/AbcSize:
3
+ Enabled: false
4
+
5
+ Metrics/BlockNesting:
6
+ Enabled: false
7
+
8
+ Metrics/ClassLength:
9
+ Enabled: false
10
+
11
+ Metrics/ModuleLength:
12
+ Enabled: false
13
+
14
+ Metrics/CyclomaticComplexity:
15
+ Enabled: false
16
+
17
+ Metrics/LineLength:
18
+ Enabled: false
19
+
20
+ Metrics/MethodLength:
21
+ Enabled: false
22
+
23
+ Metrics/ParameterLists:
24
+ Enabled: false
25
+
26
+ Metrics/PerceivedComplexity:
27
+ Enabled: false
28
+
29
+ # ['word', 'array'] looks better when aligned with other arrays that can't use
30
+ # %w() syntax
31
+ Style/WordArray:
32
+ Enabled: false
@@ -0,0 +1,4 @@
1
+ SimpleCov.start do
2
+ add_filter "/spec/"
3
+ end
4
+
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
@@ -0,0 +1,51 @@
1
+ ChangeLog
2
+ =========
3
+
4
+ 2.0.2 (2015-05-19)
5
+ ------------------
6
+
7
+ * This release has no functional changes. It's just been brought up to date
8
+ with the latest coding standards.
9
+
10
+
11
+ 2.0.1 (2014-10-06)
12
+ ------------------
13
+
14
+ * Fixed: `$priority` was ignored in `EventEmitter::once` method.
15
+ * Fixed: Breaking the event chain was not possible in `EventEmitter::once`.
16
+
17
+
18
+ 2.0.0 (2014-06-21)
19
+ ------------------
20
+
21
+ * Added: When calling emit, it's now possible to specify a callback that will be
22
+ triggered after each method handled. This is dubbed the 'continueCallback' and
23
+ can be used to implement strategy patterns.
24
+ * Added: Promise object!
25
+ * Changed: EventEmitter::listeners now returns just the callbacks for an event,
26
+ and no longer returns the list by reference. The list is now automatically
27
+ sorted by priority.
28
+ * Update: Speed improvements.
29
+ * Updated: It's now possible to remove all listeners for every event.
30
+ * Changed: Now uses psr-4 autoloading.
31
+
32
+
33
+ 1.0.1 (2014-06-12)
34
+ ------------------
35
+
36
+ * hhvm compatible!
37
+ * Fixed: Issue #4. Compatiblitiy for PHP < 5.4.14.
38
+
39
+
40
+ 1.0.0 (2013-07-19)
41
+ ------------------
42
+
43
+ * Added: removeListener, removeAllListeners
44
+ * Added: once, to only listen to an event emitting once.
45
+ * Added README.md.
46
+
47
+
48
+ 0.0.1-alpha (2013-06-29)
49
+ ------------------------
50
+
51
+ * First version!
@@ -0,0 +1,25 @@
1
+ # Contributing
2
+
3
+ This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code.
4
+ [code-of-conduct]: http://todogroup.org/opencodeofconduct/#tilia-event/tilia@jakobsack.de
5
+
6
+ This library is a port of [sabre/uri](http://github.com/fruux/sabre-event). The ruby code should match the php code as good as possible. For more information refer to the [coding guidelines](https://tilia.github.io/coding_guidelines).
7
+
8
+ If you are having an issue [search the open issues](https://github.com/tilia/tilia-event/issues) or create an issue and we'll help point you in the right direction.
9
+
10
+ ## Submitting a Pull Request
11
+
12
+ * Fork the project on Github
13
+ * Install development dependencies (`bundle install`)
14
+ * Create a topic branch for your changes
15
+ * Ensure that you provide *documentation* and *test coverage* for your changes (patches won't be accepted without)
16
+ * Ensure that all tests pass (`bundle exec rake`)
17
+ * Create a [pull request](https://github.com/tilia/tilia-event/pulls) on Github (these are also a great place to start a conversation around a patch as early as possible)
18
+
19
+ ## Testing
20
+
21
+ To run the tests:
22
+
23
+ $ rake
24
+
25
+ If nothing complains, congratulations!
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # External dependencies
4
+ gem 'activesupport', '~> 4.2'
5
+
6
+ # Testing
7
+ gem 'rake'
8
+ gem 'minitest', '~> 5.8'
9
+ gem 'simplecov', '~> 0.10'
10
+ gem 'rubocop', '~> 0.34'
11
+ gem 'yard', '~> 0.8'
@@ -0,0 +1,51 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activesupport (4.2.4)
5
+ i18n (~> 0.7)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
+ thread_safe (~> 0.3, >= 0.3.4)
9
+ tzinfo (~> 1.1)
10
+ ast (2.1.0)
11
+ astrolabe (1.3.1)
12
+ parser (~> 2.2)
13
+ docile (1.1.5)
14
+ i18n (0.7.0)
15
+ json (1.8.3)
16
+ minitest (5.8.1)
17
+ parser (2.2.3.0)
18
+ ast (>= 1.1, < 3.0)
19
+ powerpack (0.1.1)
20
+ rainbow (2.0.0)
21
+ rake (10.4.2)
22
+ rubocop (0.34.2)
23
+ astrolabe (~> 1.3)
24
+ parser (>= 2.2.2.5, < 3.0)
25
+ powerpack (~> 0.1)
26
+ rainbow (>= 1.99.1, < 3.0)
27
+ ruby-progressbar (~> 1.4)
28
+ ruby-progressbar (1.7.5)
29
+ simplecov (0.10.0)
30
+ docile (~> 1.1.0)
31
+ json (~> 1.8)
32
+ simplecov-html (~> 0.10.0)
33
+ simplecov-html (0.10.0)
34
+ thread_safe (0.3.5)
35
+ tzinfo (1.2.2)
36
+ thread_safe (~> 0.1)
37
+ yard (0.8.7.6)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ activesupport (~> 4.2)
44
+ minitest (~> 5.8)
45
+ rake
46
+ rubocop (~> 0.34)
47
+ simplecov (~> 0.10)
48
+ yard (~> 0.8)
49
+
50
+ BUNDLED WITH
51
+ 1.10.6
data/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (C) 2015 Jakob Sack (tilia@jakobsack.de)
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification,
6
+ are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice,
9
+ this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+ * Neither the name Tilia nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software
15
+ without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
+ POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,27 @@
1
+ Copyright (C) 2013-2015 fruux GmbH (https://fruux.com/)
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification,
6
+ are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice,
9
+ this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+ * Neither the name Sabre nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software
15
+ without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
+ POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,37 @@
1
+ tilia/event
2
+ ===========
3
+
4
+ [![Build Status](https://travis-ci.org/tilia/tilia-event.svg?branch=master)](https://travis-ci.org/tilia/tilia-event)
5
+
6
+ **tilia/event is a port of [sabre/event](https://github.com/fruux/sabre-event)**
7
+
8
+ sabre/event is a lightweight library for event-based development in PHP.
9
+
10
+ This library provides two patterns:
11
+
12
+ 1. EventEmitter
13
+ 2. Promises
14
+
15
+ Full documentation can be found on [the website][1].
16
+
17
+
18
+ Installation
19
+ ------------
20
+
21
+ Simply add tilia-event to your Gemfile and bundle it up:
22
+
23
+ ```ruby
24
+ gem 'tilia-event', '~> 2.0'
25
+ ```
26
+
27
+
28
+ Contributing
29
+ ------------
30
+
31
+ See [Contributing](CONTRIBUTING.md)
32
+
33
+
34
+ License
35
+ -------
36
+
37
+ tilia-event is licensed under the terms of the [three-clause BSD-license](LICENSE).
@@ -0,0 +1,18 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rubocop/rake_task'
4
+ require 'yard'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.test_files = Dir.glob('test/**/*_test.rb')
8
+ t.libs << 'test'
9
+ end
10
+ RuboCop::RakeTask.new do |t|
11
+ t.options = ['--format', 'html', '--out', 'coverage/rubocop.html']
12
+ end
13
+ YARD::Rake::YardocTask.new do |t|
14
+ t.files = ['lib/**/*.rb', '-', 'README.md']
15
+ t.options = ['--private', '--protected']
16
+ end
17
+
18
+ task(default: :test)
@@ -0,0 +1,16 @@
1
+ # Namespace for tilia project
2
+ module Tilia
3
+ # Load active support core extensions
4
+ require 'active_support'
5
+ require 'active_support/core_ext'
6
+
7
+ # Namespace of tilia-event library
8
+ module Event
9
+ require 'tilia/event/event_emitter_interface'
10
+ require 'tilia/event/event_emitter_trait'
11
+ require 'tilia/event/event_emitter'
12
+ require 'tilia/event/promise'
13
+ require 'tilia/event/promise_already_resolved_exception'
14
+ require 'tilia/event/version'
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Tilia
2
+ module Event
3
+ # EventEmitter object.
4
+ #
5
+ # Instantiate this class, or subclass it for easily creating event emitters.
6
+ class EventEmitter
7
+ include EventEmitterInterface
8
+ include EventEmitterTrait
9
+
10
+ # TODO: document
11
+ def initialize
12
+ initialize_event_emitter_trait
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,86 @@
1
+ module Tilia
2
+ module Event
3
+ # Event Emitter Interface
4
+ #
5
+ # Anything that accepts listeners and emits events should implement this
6
+ # interface.
7
+ module EventEmitterInterface
8
+ # Subscribe to an event.
9
+ #
10
+ # @param [String] _event_name
11
+ # @param [Proc, Method] _call_back
12
+ # @param [Fixnum] _priority
13
+ # @return [void]
14
+ def on(_event_name, _call_back, _priority = 100)
15
+ end
16
+
17
+ # Subscribe to an event exactly once.
18
+ #
19
+ # @param [String] _event_name
20
+ # @param [Proc, Method] _call_back
21
+ # @param [Fixnum] _priority
22
+ # @return [void]
23
+ def once(_event_name, _call_back, _priority = 100)
24
+ end
25
+
26
+ # Emits an event.
27
+ #
28
+ # This method will return true if 0 or more listeners were succesfully
29
+ # handled. false is returned if one of the events broke the event chain.
30
+ #
31
+ # If the continueCallBack is specified, this callback will be called every
32
+ # time before the next event handler is called.
33
+ #
34
+ # If the continueCallback returns false, event propagation stops. This
35
+ # allows you to use the eventEmitter as a means for listeners to implement
36
+ # functionality in your application, and break the event loop as soon as
37
+ # some condition is fulfilled.
38
+ #
39
+ # Note that returning false from an event subscriber breaks propagation
40
+ # and returns false, but if the continue-callback stops propagation, this
41
+ # is still considered a 'successful' operation and returns true.
42
+ #
43
+ # Lastly, if there are 5 event handlers for an event. The continueCallback
44
+ # will be called at most 4 times.
45
+ #
46
+ # @param [String] _event_name
47
+ # @param [Array] _arguments
48
+ # @param [Proc, Method] _continue_call_back
49
+ # @return [Boolean]
50
+ def emit(_event_name, _arguments = [], _continue_call_back = nil)
51
+ end
52
+
53
+ # Returns the list of listeners for an event.
54
+ #
55
+ # The list is returned as an array, and the list of events are sorted by
56
+ # their priority.
57
+ #
58
+ # @param [String] _event_name
59
+ # @return [Array<Proc, Method>]
60
+ def listeners(_event_name)
61
+ end
62
+
63
+ # Removes a specific listener from an event.
64
+ #
65
+ # If the listener could not be found, this method will return false. If it
66
+ # was removed it will return true.
67
+ #
68
+ # @param [String] _event_name
69
+ # @param [Proc, Method] _listener
70
+ # @return [Boolean]
71
+ def remove_listener(_event_name, _listener)
72
+ end
73
+
74
+ # Removes all listeners.
75
+ #
76
+ # If the eventName argument is specified, all listeners for that event are
77
+ # removed. If it is not specified, every listener for every event is
78
+ # removed.
79
+ #
80
+ # @param [String] _event_name
81
+ # @return [void]
82
+ def remove_all_listeners(_event_name = nil)
83
+ end
84
+ end
85
+ end
86
+ end