pusher 0.15.1 → 0.15.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +17 -10
- data/lib/pusher.rb +1 -1
- data/lib/pusher/client.rb +16 -0
- data/pusher.gemspec +1 -1
- data/spec/client_spec.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32c8fccc91671ec6b53af1f72c215d04507549af
|
4
|
+
data.tar.gz: 95456eb8133e6c1228196428c2f60ca49db3dcab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b28ce47523b183090c7807f5fae7b9f8428a2bb54706991dc4291e8a38be0bcca3e17905d9d3771f40e397a5c9edb39a2b32c00fa9105b9f4648728f6e18162a
|
7
|
+
data.tar.gz: c9d5a22d38f543f77ee7d3b64d76abdfaeda4ab716a0ec686f8e40b6f9a2cf50f0ad5f91e7f22e041b54a17676506b5a406673f3627ea202e79157d5265952df
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -63,7 +63,18 @@ pusher_client = Pusher::Client.new({
|
|
63
63
|
|
64
64
|
This `client` will have all the functionality listed on the main Pusher class (which proxies to a client internally).
|
65
65
|
|
66
|
+
If you want to set the `host` value for your client then you can do so when instantiating a Pusher client like so:
|
66
67
|
|
68
|
+
``` ruby
|
69
|
+
pusher_client = Pusher::Client.new({
|
70
|
+
app_id: 'your-pusher-app-id',
|
71
|
+
key: 'your-pusher-key',
|
72
|
+
secret: 'your-pusher-secret',
|
73
|
+
host: 'your-pusher-host'
|
74
|
+
})
|
75
|
+
```
|
76
|
+
|
77
|
+
This is useful if, for example, you've created an app on the EU cluster and wish to set the host to be `api-eu.pusher.com`.
|
67
78
|
|
68
79
|
## Interacting with the Pusher service
|
69
80
|
|
@@ -114,21 +125,17 @@ Pusher['a_channel'].trigger('an_event', {:some => 'data'})
|
|
114
125
|
|
115
126
|
This will continue to work, but has been replaced by `Pusher.trigger` which supports one or multiple channels.
|
116
127
|
|
117
|
-
###
|
128
|
+
### Using the Pusher REST API
|
118
129
|
|
119
|
-
|
130
|
+
This gem provides methods for accessing information from the [Pusher REST API](https://pusher.com/docs/rest_api). The documentation also shows an example of the responses from each of the API endpionts.
|
120
131
|
|
121
|
-
|
132
|
+
The following methods are provided by the gem.
|
122
133
|
|
123
|
-
|
124
|
-
# using the Pusher class
|
125
|
-
Pusher.get('url_without_app_id', params)
|
134
|
+
- `Pusher.channel_info('channel_name')` returns information about that channel.
|
126
135
|
|
127
|
-
|
128
|
-
pusher_client.post('url_without_app_id', params)
|
129
|
-
```
|
136
|
+
- `Pusher.channel_users('channel_name')` returns a list of all the users subscribed to the channel.
|
130
137
|
|
131
|
-
|
138
|
+
- `Pusher.channels` returns information about all the channels in your Pusher application.
|
132
139
|
|
133
140
|
### Asynchronous requests
|
134
141
|
|
data/lib/pusher.rb
CHANGED
@@ -31,7 +31,7 @@ module Pusher
|
|
31
31
|
def_delegators :default_client, :timeout=, :connect_timeout=, :send_timeout=, :receive_timeout=, :keep_alive_timeout=
|
32
32
|
|
33
33
|
def_delegators :default_client, :get, :get_async, :post, :post_async
|
34
|
-
def_delegators :default_client, :channels, :channel_info, :trigger, :trigger_async
|
34
|
+
def_delegators :default_client, :channels, :channel_info, :channel_users, :trigger, :trigger_async
|
35
35
|
def_delegators :default_client, :authenticate, :webhook, :channel, :[]
|
36
36
|
|
37
37
|
attr_writer :logger
|
data/lib/pusher/client.rb
CHANGED
@@ -209,6 +209,22 @@ module Pusher
|
|
209
209
|
get("/channels/#{channel_name}", params)
|
210
210
|
end
|
211
211
|
|
212
|
+
# Request info for users of a channel
|
213
|
+
#
|
214
|
+
# GET /apps/[id]/channels/[channel_name]/users
|
215
|
+
#
|
216
|
+
# @param channel_name [String] Channel name (max 200 characters)
|
217
|
+
# @param params [Hash] Hash of parameters for the API - see REST API docs
|
218
|
+
#
|
219
|
+
# @return [Hash] See Pusher API docs
|
220
|
+
#
|
221
|
+
# @raise [Pusher::Error] Unsuccessful response - see the error message
|
222
|
+
# @raise [Pusher::HTTPError] Error raised inside http client. The original error is wrapped in error.original_error
|
223
|
+
#
|
224
|
+
def channel_users(channel_name, params = {})
|
225
|
+
get("/channels/#{channel_name}/users", params)
|
226
|
+
end
|
227
|
+
|
212
228
|
# Trigger an event on one or more channels
|
213
229
|
#
|
214
230
|
# POST /apps/[app_id]/events
|
data/pusher.gemspec
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -128,6 +128,21 @@ describe Pusher do
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
describe '#channel_users' do
|
132
|
+
it "should call correct URL and symbolise response" do
|
133
|
+
api_path = %r{/apps/20/channels/mychannel/users}
|
134
|
+
stub_request(:get, api_path).to_return({
|
135
|
+
:status => 200,
|
136
|
+
:body => MultiJson.encode({
|
137
|
+
'users' => [{ 'id' => 1 }]
|
138
|
+
})
|
139
|
+
})
|
140
|
+
expect(@client.channel_users('mychannel')).to eq({
|
141
|
+
:users => [{ 'id' => 1}]
|
142
|
+
})
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
131
146
|
describe '#authenticate' do
|
132
147
|
before :each do
|
133
148
|
@custom_data = {:uid => 123, :info => {:name => 'Foo'}}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pusher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|