event_bg_bus 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +22 -13
- data/lib/event_bg_bus.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzY1OWZiMGZiNGRkMjkyY2YzZTdiMTE4NjZhODcyNTZhNTM4ZmVmNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjcwZGQwZGM4Y2Y4MzRmNzMwOTEzZTgwYjA5MjZjMDQ5YjExNDM2Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDkzZTY1ZDNjNmQ4MmZkNWIxYmZhYzEwMmY4ZmFlYWI4N2FkYTVjMGQ1MTRi
|
10
|
+
OTMwYzZhNzM3MTA2NTcwYTNmMGE4YmQzYTViOTI4YmIxMDllZTczNTkwNmYz
|
11
|
+
YTkwMTJlY2I3MmI4MDU5ZGFiYmM1ZmQxMTBhOWI4YmMxMGE4OTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDk0Y2Q1OWE2NjJlYmIzZWE2YWNlMzFjMDg3MDA5YTY2NzY1ODEzNzBhYTkz
|
14
|
+
ODZmZjE2ZGEyY2VhMDdkNGE4MDg4NzdmNDFiOWFiYmQ1YzZiNGM1YmM0Njlm
|
15
|
+
NGMzMTM4MDg4NWM2YWVkMzNiMWVkNzUxMzU2MWUyOTcwMzM4ODA=
|
data/README.md
CHANGED
@@ -3,8 +3,11 @@
|
|
3
3
|
A simple pubsub event bus for Ruby applications.
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/artmees/event_bus.svg?branch=master)](https://travis-ci.org/artmees/event_bus)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/artmees/event_bus.png)](https://codeclimate.com/github/artmees/event_bus)
|
6
7
|
|
7
|
-
*
|
8
|
+
* Gem: <https://rubygems.org/gems/event_bg_bus>
|
9
|
+
* Docs: <http://rubydoc.info/github/artmees/event_bg_bus/master/frames>
|
10
|
+
* Source code: <https://github.com/artmees/event_bg_bus>
|
8
11
|
|
9
12
|
## Features
|
10
13
|
|
@@ -18,10 +21,17 @@ A simple pubsub event bus for Ruby applications.
|
|
18
21
|
|
19
22
|
## Installation
|
20
23
|
|
24
|
+
Install the gem
|
25
|
+
```
|
26
|
+
gem install 'event_bg_bus'
|
27
|
+
```
|
28
|
+
|
21
29
|
Add it to your Gemfile and run `bundle`.
|
22
30
|
|
23
31
|
``` ruby
|
24
32
|
gem 'event_bus', github: 'artmees/event_bus'
|
33
|
+
# or
|
34
|
+
gem 'event_bg_bus'
|
25
35
|
```
|
26
36
|
|
27
37
|
## Usage
|
@@ -121,21 +131,20 @@ There are three ways to subscribe to events.
|
|
121
131
|
|
122
132
|
#### Subscribe to background published events
|
123
133
|
|
124
|
-
due to
|
125
|
-
you can not subscribe to events published
|
134
|
+
due to some [Sidekiq](https://github.com/mperham/sidekiq) limitations with background jobs.
|
135
|
+
you can not subscribe to events published by `EventBGBus` using Symbols in either `event_name` or `payload`.
|
126
136
|
you can via Reqexp, Strings or listener objects.
|
127
137
|
|
138
|
+
```ruby
|
139
|
+
EventBus.subscribe('order_placed', StatsRecorder.new, :print_order)
|
140
|
+
```
|
128
141
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
order = payload['order']
|
136
|
-
//...
|
137
|
-
end
|
138
|
-
```
|
142
|
+
```ruby
|
143
|
+
EventBus.subscribe('order_placed') do |payload|
|
144
|
+
order = payload['order']
|
145
|
+
//...
|
146
|
+
end
|
147
|
+
```
|
139
148
|
|
140
149
|
See the specs for more detailed usage scenarios.
|
141
150
|
|
data/lib/event_bg_bus.rb
CHANGED
@@ -10,9 +10,13 @@ class EventBGBus
|
|
10
10
|
# The +event_name+ is added to the +payload+ hash (with the key +"event_name"+)
|
11
11
|
# before being passed on to listeners.
|
12
12
|
#
|
13
|
+
# note that the +payload+ hash won't be accessed using the symbol syntax
|
14
|
+
# so instead of using +payload[:param]+ you can only use +payload['param']
|
15
|
+
# this is due to sidekiq limitation with background jobs
|
16
|
+
#
|
13
17
|
# @param event_name [String, Symbol] the name of your event
|
14
18
|
# @param payload [Hash] the information you want to pass to the listeners
|
15
|
-
# @return [
|
19
|
+
# @return [EventBGBus] the EventBGBus, ready to be called again.
|
16
20
|
#
|
17
21
|
def publish(event_name, payload = {})
|
18
22
|
case event_name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_bg_bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Rutherford
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -89,7 +89,7 @@ files:
|
|
89
89
|
- spec/lib/event_bg_bus_spec.rb
|
90
90
|
- spec/lib/event_bus_spec.rb
|
91
91
|
- spec/spec_helper.rb
|
92
|
-
homepage: http://github.com/artmees/
|
92
|
+
homepage: http://github.com/artmees/event_bg_bus
|
93
93
|
licenses: []
|
94
94
|
metadata: {}
|
95
95
|
post_install_message:
|