pusherable 1.0.2 → 1.0.3
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.
- data/.travis.yml +1 -2
- data/Gemfile +4 -0
- data/README.md +19 -6
- data/lib/pusherable/version.rb +1 -1
- data/lib/pusherable.rb +2 -0
- data/spec/pusherable_spec.rb +13 -11
- metadata +4 -4
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# Pusherable
|
2
2
|
|
3
|
+
[](https://travis-ci.org/tonycoco/pusherable)
|
4
|
+
|
3
5
|
Adds callback hooks for your ActiveRecord models for sending messages to a Pusher channel.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
|
-
|
9
|
+
Install and configure Pusher to work on your application by following the [pusher gem's instructions](https://github.com/pusher/pusher-gem).
|
10
|
+
|
11
|
+
Then, add this line to your application's Gemfile:
|
8
12
|
|
9
13
|
gem 'pusherable'
|
10
14
|
|
@@ -24,11 +28,6 @@ Add in the following lines to any ActiveRecord model class:
|
|
24
28
|
|
25
29
|
On your subscribed client(s), events will be triggered by Pusher reflecting your ActiveRecord create/update/destroy actions.
|
26
30
|
|
27
|
-
### Example
|
28
|
-
|
29
|
-
If you have a model called, __Story__, and you create a new record, Pusher will receive an event called, "story.create".
|
30
|
-
It will also carry a payload of data containing the __model_id__
|
31
|
-
|
32
31
|
Here is a list of the ActiveRecord callbacks that trigger Pusher events...
|
33
32
|
|
34
33
|
```
|
@@ -37,6 +36,19 @@ Here is a list of the ActiveRecord callbacks that trigger Pusher events...
|
|
37
36
|
"model.destroy" => before_destroy
|
38
37
|
```
|
39
38
|
|
39
|
+
### Example
|
40
|
+
|
41
|
+
If you have an ActiveRecord model called, __Post__, and you create a new record, Pusher will receive an event called, "post.create".
|
42
|
+
It will also carry a payload of data containing the __model_id__. Future implementations may carry a changeset in the data. For now, let's keep it simple.
|
43
|
+
|
44
|
+
The following callbacks that trigger Pusher events in this __Post__ example will then be...
|
45
|
+
|
46
|
+
```
|
47
|
+
"post.create" => after_create
|
48
|
+
"post.update" => after_update
|
49
|
+
"post.destroy" => before_destroy
|
50
|
+
```
|
51
|
+
|
40
52
|
## Contributing
|
41
53
|
|
42
54
|
1. Fork it
|
@@ -44,3 +56,4 @@ Here is a list of the ActiveRecord callbacks that trigger Pusher events...
|
|
44
56
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
57
|
4. Push to the branch (`git push origin my-new-feature`)
|
46
58
|
5. Create new Pull Request
|
59
|
+
st
|
data/lib/pusherable/version.rb
CHANGED
data/lib/pusherable.rb
CHANGED
@@ -6,6 +6,8 @@ module Pusherable
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def pusherable(pusherable_channel='test_channel')
|
9
|
+
raise "Please `gem install pusher` and configure it to run in your app!" if Pusher.app_id.blank? || Pusher.key.blank? || Pusher.secret.blank?
|
10
|
+
|
9
11
|
class_attribute :pusherable_channel
|
10
12
|
self.pusherable_channel = pusherable_channel
|
11
13
|
|
data/spec/pusherable_spec.rb
CHANGED
@@ -6,17 +6,6 @@ describe Pusherable do
|
|
6
6
|
NonPusherableModel.pusherable?.should == false
|
7
7
|
PusherableModel.pusherable?.should == true
|
8
8
|
end
|
9
|
-
|
10
|
-
it 'should set the channel to push to' do
|
11
|
-
DefaultedPusherableModel.pusherable_channel.should == 'test_channel'
|
12
|
-
PusherableModel.pusherable_channel.should == 'our_channel'
|
13
|
-
|
14
|
-
default_model = DefaultedPusherableModel.new
|
15
|
-
setup_model = PusherableModel.new
|
16
|
-
|
17
|
-
default_model.pusherable_channel.should == 'test_channel'
|
18
|
-
setup_model.pusherable_channel.should == 'our_channel'
|
19
|
-
end
|
20
9
|
end
|
21
10
|
|
22
11
|
describe 'callbacks' do
|
@@ -54,4 +43,17 @@ describe Pusherable do
|
|
54
43
|
@non_pusherable_model.destroy
|
55
44
|
end
|
56
45
|
end
|
46
|
+
|
47
|
+
describe 'channels' do
|
48
|
+
it 'should get and set the channel to push to' do
|
49
|
+
DefaultedPusherableModel.pusherable_channel.should == 'test_channel'
|
50
|
+
PusherableModel.pusherable_channel.should == 'our_channel'
|
51
|
+
|
52
|
+
default_model = DefaultedPusherableModel.new
|
53
|
+
setup_model = PusherableModel.new
|
54
|
+
|
55
|
+
default_model.pusherable_channel.should == 'test_channel'
|
56
|
+
setup_model.pusherable_channel.should == 'our_channel'
|
57
|
+
end
|
58
|
+
end
|
57
59
|
end
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: pusherable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tony Coconate
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -157,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
segments:
|
159
159
|
- 0
|
160
|
-
hash:
|
160
|
+
hash: 724947674044802988
|
161
161
|
version: '0'
|
162
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
163
|
none: false
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
segments:
|
168
168
|
- 0
|
169
|
-
hash:
|
169
|
+
hash: 724947674044802988
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project:
|