wisper 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +4 -5
- data/CHANGELOG.md +26 -3
- data/CONTRIBUTING.md +2 -6
- data/Gemfile +2 -2
- data/README.md +14 -9
- data/bin/console +8 -0
- data/bin/setup +6 -0
- data/gem-public_cert.pem +18 -19
- data/lib/wisper/temporary_listeners.rb +8 -7
- data/lib/wisper/version.rb +1 -1
- data/spec/lib/temporary_global_listeners_spec.rb +36 -0
- data/wisper.gemspec +1 -1
- metadata +30 -6
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2890739bfde16edeb614504b6a6ac9f1babe148c3ed3255af7b11d2b68275dc8
|
4
|
+
data.tar.gz: f64460470b4778927d19bbab51f5cd190ec2d16df4909340ee09aaa89b8e9636
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82292503201b5402aebb60c3ad433c4f1bfb22858fbd1221ba86225dbb9e597f2ffb97c8b075847a12c5a801fb92d7e84a9485fb8919c39548f80e54c2fdf318
|
7
|
+
data.tar.gz: b40625e6e3cf17df8a457f6547ecf5f0d921ff7dc771910462d0a5219d2aba9ab0afcc91787cdb5ccd49d18f48845eda3b95f20ef9bdd4914d1afca5c2f45f4c
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/.travis.yml
CHANGED
@@ -6,11 +6,10 @@ bundler_args: --without=extras
|
|
6
6
|
script: rspec spec
|
7
7
|
sudo: false
|
8
8
|
rvm:
|
9
|
-
-
|
10
|
-
-
|
11
|
-
-
|
12
|
-
-
|
13
|
-
- jruby-9.1.6.0
|
9
|
+
- 2.6.3
|
10
|
+
- 2.5.5
|
11
|
+
- 2.4.6
|
12
|
+
- jruby-9.2
|
14
13
|
# - rbx-2
|
15
14
|
### ALLOWED FAILURES ###
|
16
15
|
# see how compatible we are with dev versions, but do not fail the build
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,33 @@
|
|
1
1
|
## HEAD (unreleased)
|
2
2
|
|
3
|
-
## 2.0.
|
3
|
+
## 2.0.1 (29th Aug 2019)
|
4
|
+
|
5
|
+
Authors: David Wilkie, hosseintoussi, Maxim Polunin, Tristan
|
6
|
+
Harmer, Bartosz Żurkowski, Kris Leech
|
4
7
|
|
5
|
-
|
8
|
+
* fix: support nested temporary global listeners
|
9
|
+
* docs: add threadsafe notes to README for global and temporary listeners
|
10
|
+
* docs: fix spelling mistakes in README
|
11
|
+
* fix: safely get signing key in gemspec when HOME is not set
|
12
|
+
* adds: add console to aid experiments and REPL driven development
|
13
|
+
* adds: Latest Ruby to CI
|
14
|
+
|
15
|
+
## 2.0.0 (7th Mar 2017)
|
6
16
|
|
7
|
-
|
17
|
+
Authors: Sergey Mostovoy, Andrew Kozin, Kyle Tolle, Martin, Rob Miller, Mike
|
18
|
+
Dalto, orthographic-pedant, Drew Ulmer, Mikey Hogarth, Attila Domokos, Josh
|
19
|
+
Miltz, Pascal Betz, Vasily Kolesnikov, Julien Letessier, Kris Leech
|
20
|
+
|
21
|
+
* Fix: logger raises exception if hash is passed as an argument to a listener #133, #136
|
22
|
+
* Fix: deprecation warnings #120
|
23
|
+
* Doc improvements: #106, #111, #116, #122, #128, #130, #147, #149, #150, #151
|
24
|
+
* Adds: Allow configuration of default prefix when using `prefix: true`. #105
|
25
|
+
* Adds: Allow unsubscribing of global listeners #118
|
26
|
+
* Adds: Helpful error message when passing a block to `#subscribe` of `#on` #125
|
27
|
+
* Adds: raise an error message when `#on` is not passed a block #146
|
28
|
+
* Adds: Support for JRuby 9.x #148
|
29
|
+
* Adds: Support for MRI 2.4.0 #155
|
30
|
+
* Refactor specs #126, #131
|
8
31
|
|
9
32
|
## 2.0.0.rc1 (17 Dec 2014)
|
10
33
|
|
data/CONTRIBUTING.md
CHANGED
@@ -28,10 +28,6 @@ appropriate as an extension to Wisper.
|
|
28
28
|
|
29
29
|
We also have a [Gitter channel](https://gitter.im/krisleech/wisper) if you wish to discuss your ideas.
|
30
30
|
|
31
|
-
## Backlog / Roadmap
|
32
|
-
|
33
|
-
The backlog for Wisper and related gems is on [Waffle](https://waffle.io/krisleech/wisper).
|
34
|
-
|
35
31
|
## Questions
|
36
32
|
|
37
33
|
Try the [Wiki](https://github.com/krisleech/wisper/wiki) first, the examples
|
@@ -43,7 +39,7 @@ Feel free to ping me the URL on [Twitter](https://twitter.com/krisleech).
|
|
43
39
|
|
44
40
|
## Pull requests
|
45
41
|
|
46
|
-
* Fork the project, create a new branch
|
42
|
+
* Fork the project, create a new branch `master`.
|
47
43
|
* Squash commits which are related.
|
48
44
|
* Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
49
45
|
* Documentation only changes should have `[skip ci]` in the commit message
|
@@ -58,4 +54,4 @@ not backwards compatible.
|
|
58
54
|
The `v1` branch is a long lived branch and you should
|
59
55
|
branch from this if you wish to fix an issue in version `~> 1.0`.
|
60
56
|
|
61
|
-
|
57
|
+
Otherwise branch from `master` branch.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -10,10 +10,12 @@
|
|
10
10
|
* Decouple core business logic from external concerns in Hexagonal style architectures
|
11
11
|
* Use as an alternative to ActiveRecord callbacks and Observers in Rails apps
|
12
12
|
* Connect objects based on context without permanence
|
13
|
-
*
|
13
|
+
* Publish events synchronously or asynchronously
|
14
14
|
|
15
15
|
Note: Wisper was originally extracted from a Rails codebase but is not dependant on Rails.
|
16
16
|
|
17
|
+
Please also see the [Wiki](https://github.com/krisleech/wisper/wiki) for more additional information and articles.
|
18
|
+
|
17
19
|
## Installation
|
18
20
|
|
19
21
|
Add this line to your application's Gemfile:
|
@@ -74,7 +76,7 @@ class OrderNotifier
|
|
74
76
|
def cancel_order_successful(order_id)
|
75
77
|
order = Order.find_by_id(order_id)
|
76
78
|
|
77
|
-
# notify someone ...
|
79
|
+
# notify someone ...
|
78
80
|
end
|
79
81
|
end
|
80
82
|
```
|
@@ -118,8 +120,9 @@ cancel_order.subscribe(OrderNotifier.new, async: true)
|
|
118
120
|
Wisper has various adapters for asynchronous event handling, please refer to
|
119
121
|
[wisper-celluloid](https://github.com/krisleech/wisper-celluloid),
|
120
122
|
[wisper-sidekiq](https://github.com/krisleech/wisper-sidekiq),
|
121
|
-
[wisper-activejob](https://github.com/krisleech/wisper-activejob),
|
122
|
-
[wisper-que](https://github.com/joevandyk/wisper-que)
|
123
|
+
[wisper-activejob](https://github.com/krisleech/wisper-activejob),
|
124
|
+
[wisper-que](https://github.com/joevandyk/wisper-que) or
|
125
|
+
[wisper-resque](https://github.com/bzurkowski/wisper-resque).
|
123
126
|
|
124
127
|
Depending on the adapter used the listener may need to be a class instead of an object. In this situation, every method corresponding to events should be declared as a class method, too. For example:
|
125
128
|
|
@@ -131,7 +134,7 @@ class OrderNotifier
|
|
131
134
|
def self.cancel_order_successful(order_id)
|
132
135
|
order = Order.find_by_id(order_id)
|
133
136
|
|
134
|
-
# notify someone ...
|
137
|
+
# notify someone ...
|
135
138
|
end
|
136
139
|
end
|
137
140
|
```
|
@@ -191,9 +194,10 @@ This is useful for cross cutting concerns such as recording statistics, indexing
|
|
191
194
|
Wisper.subscribe(MyListener.new)
|
192
195
|
```
|
193
196
|
|
194
|
-
In a Rails app you might want to add your global listeners in an
|
197
|
+
In a Rails app you might want to add your global listeners in an initializer.
|
198
|
+
|
199
|
+
Global listeners are threadsafe. Subscribers will receive events published on all threads.
|
195
200
|
|
196
|
-
Global listeners are threadsafe.
|
197
201
|
|
198
202
|
### Scoping by publisher class
|
199
203
|
|
@@ -231,7 +235,7 @@ listeners.
|
|
231
235
|
|
232
236
|
This is useful for capturing events published by objects to which you do not have access in a given context.
|
233
237
|
|
234
|
-
Temporary Global Listeners are threadsafe.
|
238
|
+
Temporary Global Listeners are threadsafe. Subscribers will receive events published on the same thread.
|
235
239
|
|
236
240
|
## Subscribing to selected events
|
237
241
|
|
@@ -291,7 +295,7 @@ You could also alias the method within your listener, as such
|
|
291
295
|
|
292
296
|
## Testing
|
293
297
|
|
294
|
-
Testing matchers and stubs are in
|
298
|
+
Testing matchers and stubs are in separate gems.
|
295
299
|
|
296
300
|
* [wisper-rspec](https://github.com/krisleech/wisper-rspec)
|
297
301
|
* [wisper-minitest](https://github.com/digitalcuisine/wisper-minitest)
|
@@ -339,6 +343,7 @@ Please read the [Contributing Guidelines](https://github.com/krisleech/wisper/bl
|
|
339
343
|
|
340
344
|
* gem releases are [signed](http://guides.rubygems.org/security/) ([public key](https://github.com/krisleech/wisper/blob/master/gem-public_cert.pem))
|
341
345
|
* commits are GPG signed ([public key](https://pgp.mit.edu/pks/lookup?op=get&search=0x3ABC74851F7CCC88))
|
346
|
+
* My [Keybase.io profile](https://keybase.io/krisleech)
|
342
347
|
|
343
348
|
## License
|
344
349
|
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/gem-public_cert.pem
CHANGED
@@ -1,21 +1,20 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
pEfFMW42smiNTOXpzG6JoIpA11szEHFT5ZS+UQ==
|
2
|
+
MIIDQDCCAiigAwIBAgIBATANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBprcmlz
|
3
|
+
LmxlZWNoL0RDPWdtYWlsL0RDPWNvbTAeFw0xOTEwMTYxNDEzNDVaFw0yMDEwMTUx
|
4
|
+
NDEzNDVaMCUxIzAhBgNVBAMMGmtyaXMubGVlY2gvREM9Z21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A+Lc39kD+AcGIrQ=
|
21
20
|
-----END CERTIFICATE-----
|
@@ -4,7 +4,6 @@
|
|
4
4
|
|
5
5
|
module Wisper
|
6
6
|
class TemporaryListeners
|
7
|
-
|
8
7
|
def self.subscribe(*listeners, &block)
|
9
8
|
new.subscribe(*listeners, &block)
|
10
9
|
end
|
@@ -13,13 +12,14 @@ module Wisper
|
|
13
12
|
new.registrations
|
14
13
|
end
|
15
14
|
|
16
|
-
def subscribe(*listeners, &
|
17
|
-
|
15
|
+
def subscribe(*listeners, &_block)
|
16
|
+
new_registrations = build_registrations(listeners)
|
17
|
+
|
18
18
|
begin
|
19
|
-
|
19
|
+
registrations.merge new_registrations
|
20
20
|
yield
|
21
21
|
ensure
|
22
|
-
|
22
|
+
registrations.subtract new_registrations
|
23
23
|
end
|
24
24
|
self
|
25
25
|
end
|
@@ -30,8 +30,9 @@ module Wisper
|
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
|
-
def
|
34
|
-
|
33
|
+
def build_registrations(listeners)
|
34
|
+
options = listeners.last.is_a?(Hash) ? listeners.pop : {}
|
35
|
+
listeners.map { |listener| ObjectRegistration.new(listener, options) }
|
35
36
|
end
|
36
37
|
|
37
38
|
def key
|
data/lib/wisper/version.rb
CHANGED
@@ -32,6 +32,42 @@ describe Wisper::TemporaryListeners do
|
|
32
32
|
publisher.instance_eval { broadcast(:failure) }
|
33
33
|
end
|
34
34
|
|
35
|
+
it 'globally subscribes listeners for duration of nested block' do
|
36
|
+
|
37
|
+
expect(listener_1).to receive(:success)
|
38
|
+
expect(listener_1).to receive(:failure)
|
39
|
+
|
40
|
+
expect(listener_2).to receive(:success)
|
41
|
+
expect(listener_2).to_not receive(:failure)
|
42
|
+
|
43
|
+
Wisper::TemporaryListeners.subscribe(listener_1) do
|
44
|
+
Wisper::TemporaryListeners.subscribe(listener_2) do
|
45
|
+
publisher.instance_eval { broadcast(:success) }
|
46
|
+
end
|
47
|
+
publisher.instance_eval { broadcast(:failure) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'clears registrations for the block which exits' do
|
52
|
+
|
53
|
+
# listener_1 is subscribed twice hence it's supposed to get the message twice
|
54
|
+
expect(listener_1).to receive(:success).twice
|
55
|
+
expect(listener_1).to receive(:failure)
|
56
|
+
expect(listener_1).to_not receive(:ignored)
|
57
|
+
|
58
|
+
expect(listener_2).to receive(:success)
|
59
|
+
expect(listener_2).to_not receive(:failure)
|
60
|
+
expect(listener_2).to_not receive(:ignored)
|
61
|
+
|
62
|
+
Wisper::TemporaryListeners.subscribe(listener_1) do
|
63
|
+
Wisper::TemporaryListeners.subscribe(listener_1, listener_2) do
|
64
|
+
publisher.instance_eval { broadcast(:success) }
|
65
|
+
end
|
66
|
+
publisher.instance_eval { broadcast(:failure) }
|
67
|
+
end
|
68
|
+
publisher.instance_eval { broadcast(:ignored) }
|
69
|
+
end
|
70
|
+
|
35
71
|
it 'is thread safe' do
|
36
72
|
num_threads = 20
|
37
73
|
(1..num_threads).to_a.map do
|
data/wisper.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.homepage = "https://github.com/krisleech/wisper"
|
18
18
|
gem.license = "MIT"
|
19
19
|
|
20
|
-
signing_key = File.expand_path('
|
20
|
+
signing_key = File.expand_path(ENV['HOME'].to_s + '/.ssh/gem-private_key.pem')
|
21
21
|
|
22
22
|
if File.exist?(signing_key)
|
23
23
|
gem.signing_key = signing_key
|
metadata
CHANGED
@@ -1,14 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wisper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Leech
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----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62WLnrL50gMs3u2ILmLP5gkO3EoLyezJvIj33CLO
|
28
|
+
HX0Plp0VwiSp8+gEELX5wtdrnJ/UjmrY1lg7szukE+jgOJ++1e7Rzr+woBewIWvF
|
29
|
+
xn3z1ObkNQCnLZMRmzEcSa40T10/AuuuEv32emAgb50u9vz+s4y2lnE9i4mWW7+X
|
30
|
+
5vdRgX7VnzYPA+Lc39kD+AcGIrQ=
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
date: 2019-10-16 00:00:00.000000000 Z
|
12
33
|
dependencies: []
|
13
34
|
description: |2
|
14
35
|
A micro library providing objects with Publish-Subscribe capabilities.
|
@@ -16,7 +37,9 @@ description: |2
|
|
16
37
|
Check out the Wiki for articles, guides and examples: https://github.com/krisleech/wisper/wiki
|
17
38
|
email:
|
18
39
|
- kris.leech@gmail.com
|
19
|
-
executables:
|
40
|
+
executables:
|
41
|
+
- console
|
42
|
+
- setup
|
20
43
|
extensions: []
|
21
44
|
extra_rdoc_files: []
|
22
45
|
files:
|
@@ -28,6 +51,8 @@ files:
|
|
28
51
|
- Gemfile
|
29
52
|
- README.md
|
30
53
|
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
31
56
|
- gem-public_cert.pem
|
32
57
|
- lib/wisper.rb
|
33
58
|
- lib/wisper/broadcasters/logger_broadcaster.rb
|
@@ -76,8 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
101
|
- !ruby/object:Gem::Version
|
77
102
|
version: '0'
|
78
103
|
requirements: []
|
79
|
-
|
80
|
-
rubygems_version: 2.5.1
|
104
|
+
rubygems_version: 3.0.6
|
81
105
|
signing_key:
|
82
106
|
specification_version: 4
|
83
107
|
summary: A micro library providing objects with Publish-Subscribe capabilities
|
metadata.gz.sig
ADDED
Binary file
|