pusherable 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +34 -22
- data/lib/pusherable/version.rb +1 -1
- data/lib/pusherable.rb +9 -3
- metadata +37 -61
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4d09f4ddac191240056671ee74cbd3fe0e3c0073
|
4
|
+
data.tar.gz: 7eccf49e2569a0bb3b4d385121097ac5a2bd087a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 39247b971b02fc048fe5f0c20ddc69e24ffd0d382adc18f57f418f8230df37241dea592f2d42dd73b7f61a3d2722b57be00101d1cc57f032afb518affe8e1c90
|
7
|
+
data.tar.gz: e4a17efcadace9ae6559a1d345e1d5986e5e184d76b7f911dd364b56fbfadda5af0bf3a4135a0a958f0bc4ae20aa9b45dab4f3da66a33032360cb24c8adc4949
|
data/README.md
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/tonycoco/pusherable.png)](https://travis-ci.org/tonycoco/pusherable)
|
4
4
|
|
5
|
-
Adds callback hooks for your
|
5
|
+
Adds callback hooks for your `ActiveModel` models for sending messages to a `Pusher` channel.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
Install and configure
|
9
|
+
Install and configure `Pusher` to work on your application by following the [pusher gem's instructions](https://github.com/pusher/pusher-gem).
|
10
10
|
|
11
|
-
Then, add this line to your application's
|
11
|
+
Then, add this line to your application's `Gemfile`:
|
12
12
|
|
13
13
|
gem "pusherable"
|
14
14
|
|
@@ -22,40 +22,52 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
Add in the following lines to any
|
25
|
+
Add in the following lines to any `ActiveModel` model class:
|
26
26
|
|
27
27
|
pusherable("some_channel")
|
28
28
|
|
29
|
-
|
29
|
+
A `pusherable` model triggers events on a default channel of `test_channel`, just like the `Pusher` example docs, that it will publish to.
|
30
30
|
|
31
|
-
On your subscribed client(s), events will be triggered by
|
31
|
+
On your subscribed client(s), events will be triggered by `Pusher` reflecting your `ActiveModel` create, update and destroy actions.
|
32
32
|
|
33
|
-
Here is a list of the
|
33
|
+
Here is a list of the `ActiveModel` callbacks that trigger `Pusher` events...
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
after_create
|
38
|
-
after_update
|
39
|
-
before_destroy
|
35
|
+
`ActiveModel` callbacks (Non-Transactional):
|
36
|
+
|
37
|
+
after_create will trigger "model.create"
|
38
|
+
after_update will trigger "model.update"
|
39
|
+
before_destroy will trigger "model.destroy"
|
40
|
+
|
41
|
+
`ActiveModel` callbacks (Transactional):
|
42
|
+
|
43
|
+
after_commit on :create will trigger "model.create"
|
44
|
+
after_commit on :update will trigger "model.update"
|
45
|
+
after_commit on :destroy will trigger "model.destroy"
|
40
46
|
|
41
47
|
### Example
|
42
48
|
|
43
|
-
If you have an
|
44
|
-
It will also carry a payload of data containing a
|
49
|
+
If you have an `ActiveModel` model called, `Post`, and you create a new record, `Pusher` will receive an event called, `"post.create"`.
|
50
|
+
It will also carry a payload of data containing a JSON representation of the record (literally calling `#to_json` on the record).
|
51
|
+
|
52
|
+
The following callbacks that trigger `Pusher` events in this `Post` example will then be...
|
53
|
+
|
54
|
+
`ActiveModel` callbacks (Non-Transactional):
|
55
|
+
|
56
|
+
after_create will trigger "post.create"
|
57
|
+
after_update will trigger "post.update"
|
58
|
+
before_destroy will trigger "post.destroy"
|
45
59
|
|
46
|
-
|
60
|
+
`ActiveModel` callbacks (Transactional):
|
47
61
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
after_update => "post.update"
|
52
|
-
before_destroy => "post.destroy"
|
62
|
+
after_commit on :create will trigger "post.create"
|
63
|
+
after_commit on :update will trigger "post.update"
|
64
|
+
after_commit on :destroy will trigger "post.destroy"
|
53
65
|
|
54
|
-
Currently this gem extends `ActiveRecord::Base` and `Mongoid::Document` if defined.
|
66
|
+
Currently this gem extends `ActiveRecord::Base` and `Mongoid::Document` (if defined).
|
55
67
|
|
56
68
|
`ActiveRecord::Base.extend Pusherable`
|
57
69
|
|
58
|
-
For any other `ActiveModel` compliant
|
70
|
+
For any other `ActiveModel` compliant data store, simply mirror this statement.
|
59
71
|
|
60
72
|
## Contributing
|
61
73
|
|
data/lib/pusherable/version.rb
CHANGED
data/lib/pusherable.rb
CHANGED
@@ -15,9 +15,15 @@ module Pusherable
|
|
15
15
|
self.pusherable_channel = pusherable_channel
|
16
16
|
|
17
17
|
class_eval do
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
if defined?(Mongoid) && defined?(Mongoid::Document) && include?(Mongoid::Document)
|
19
|
+
after_create :pusherable_trigger_create
|
20
|
+
after_update :pusherable_trigger_update
|
21
|
+
before_destroy :pusherable_trigger_destroy
|
22
|
+
else
|
23
|
+
after_commit :pusherable_trigger_create, on: :create
|
24
|
+
after_commit :pusherable_trigger_update, on: :update
|
25
|
+
after_commit :pusherable_trigger_destroy, on: :destroy
|
26
|
+
end
|
21
27
|
|
22
28
|
def self.pusherable?
|
23
29
|
true
|
metadata
CHANGED
@@ -1,144 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusherable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 1.1.0
|
4
|
+
version: 1.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tony Coconate
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activerecord
|
16
|
-
type: :development
|
17
15
|
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.2.0
|
22
|
-
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
|
-
- -
|
24
|
+
- - '>='
|
26
25
|
- !ruby/object:Gem::Version
|
27
26
|
version: 3.2.0
|
28
|
-
none: false
|
29
|
-
prerelease: false
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: activesupport
|
32
|
-
type: :development
|
33
29
|
requirement: !ruby/object:Gem::Requirement
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 3.2.0
|
38
|
-
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- -
|
38
|
+
- - '>='
|
42
39
|
- !ruby/object:Gem::Version
|
43
40
|
version: 3.2.0
|
44
|
-
none: false
|
45
|
-
prerelease: false
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: mongoid
|
48
|
-
type: :development
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '3'
|
54
|
-
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
55
50
|
version_requirements: !ruby/object:Gem::Requirement
|
56
51
|
requirements:
|
57
|
-
- -
|
52
|
+
- - '>='
|
58
53
|
- !ruby/object:Gem::Version
|
59
54
|
version: '3'
|
60
|
-
none: false
|
61
|
-
prerelease: false
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: mongoid-rspec
|
64
|
-
type: :development
|
65
57
|
requirement: !ruby/object:Gem::Requirement
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '1.6'
|
70
|
-
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
71
64
|
version_requirements: !ruby/object:Gem::Requirement
|
72
65
|
requirements:
|
73
|
-
- -
|
66
|
+
- - '>='
|
74
67
|
- !ruby/object:Gem::Version
|
75
68
|
version: '1.6'
|
76
|
-
none: false
|
77
|
-
prerelease: false
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: pusher
|
80
|
-
type: :development
|
81
71
|
requirement: !ruby/object:Gem::Requirement
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: 0.11.0
|
86
|
-
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
87
78
|
version_requirements: !ruby/object:Gem::Requirement
|
88
79
|
requirements:
|
89
80
|
- - ~>
|
90
81
|
- !ruby/object:Gem::Version
|
91
82
|
version: 0.11.0
|
92
|
-
none: false
|
93
|
-
prerelease: false
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rake
|
96
|
-
type: :development
|
97
85
|
requirement: !ruby/object:Gem::Requirement
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
|
-
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
103
92
|
version_requirements: !ruby/object:Gem::Requirement
|
104
93
|
requirements:
|
105
|
-
- -
|
94
|
+
- - '>='
|
106
95
|
- !ruby/object:Gem::Version
|
107
96
|
version: '0'
|
108
|
-
none: false
|
109
|
-
prerelease: false
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: rspec
|
112
|
-
type: :development
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: 2.12.0
|
118
|
-
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
119
106
|
version_requirements: !ruby/object:Gem::Requirement
|
120
107
|
requirements:
|
121
|
-
- -
|
108
|
+
- - '>='
|
122
109
|
- !ruby/object:Gem::Version
|
123
110
|
version: 2.12.0
|
124
|
-
none: false
|
125
|
-
prerelease: false
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: sqlite3
|
128
|
-
type: :development
|
129
113
|
requirement: !ruby/object:Gem::Requirement
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - '>='
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
|
-
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
135
120
|
version_requirements: !ruby/object:Gem::Requirement
|
136
121
|
requirements:
|
137
|
-
- -
|
122
|
+
- - '>='
|
138
123
|
- !ruby/object:Gem::Version
|
139
124
|
version: '0'
|
140
|
-
none: false
|
141
|
-
prerelease: false
|
142
125
|
description: Adds callback hooks for your ActiveModel models for sending messages
|
143
126
|
to a Pusher channel.
|
144
127
|
email:
|
@@ -164,33 +147,26 @@ files:
|
|
164
147
|
- spec/support/schema.rb
|
165
148
|
homepage: https://github.com/tonycoco/pusherable
|
166
149
|
licenses: []
|
150
|
+
metadata: {}
|
167
151
|
post_install_message:
|
168
152
|
rdoc_options: []
|
169
153
|
require_paths:
|
170
154
|
- lib
|
171
155
|
required_ruby_version: !ruby/object:Gem::Requirement
|
172
156
|
requirements:
|
173
|
-
- -
|
157
|
+
- - '>='
|
174
158
|
- !ruby/object:Gem::Version
|
175
|
-
segments:
|
176
|
-
- 0
|
177
|
-
hash: 3897461447202856770
|
178
159
|
version: '0'
|
179
|
-
none: false
|
180
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
161
|
requirements:
|
182
|
-
- -
|
162
|
+
- - '>='
|
183
163
|
- !ruby/object:Gem::Version
|
184
|
-
segments:
|
185
|
-
- 0
|
186
|
-
hash: 3897461447202856770
|
187
164
|
version: '0'
|
188
|
-
none: false
|
189
165
|
requirements: []
|
190
166
|
rubyforge_project:
|
191
|
-
rubygems_version:
|
167
|
+
rubygems_version: 2.0.2
|
192
168
|
signing_key:
|
193
|
-
specification_version:
|
169
|
+
specification_version: 4
|
194
170
|
summary: Adds callback hooks to your models for sending messages to a Pusher channel.
|
195
171
|
test_files:
|
196
172
|
- spec/mongoid_pusherable_spec.rb
|