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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b64af09f091d43ed13e921406e0108b6a90b0cd9
4
- data.tar.gz: 9fd33f0354fe6fd52e47802844c73b00ee6deee9
3
+ metadata.gz: 32c8fccc91671ec6b53af1f72c215d04507549af
4
+ data.tar.gz: 95456eb8133e6c1228196428c2f60ca49db3dcab
5
5
  SHA512:
6
- metadata.gz: efd9f7930352cc46a0cee275122cea94f3a283beeb44b8b9448b2908ec87963b83f1b6cf1dd2a13e2fa6dccf58c8ca81fb93d5b67ec88bc51bb677e842785297
7
- data.tar.gz: ce20cb134cf093a8c9a9f6bf47169e9cc3a26b65b7e697655deb62479f91092c68cd11bb888c60f56f1b056c59c443484b5c96e2cf90c59f7c390d45d57326cb
6
+ metadata.gz: b28ce47523b183090c7807f5fae7b9f8428a2bb54706991dc4291e8a38be0bcca3e17905d9d3771f40e397a5c9edb39a2b32c00fa9105b9f4648728f6e18162a
7
+ data.tar.gz: c9d5a22d38f543f77ee7d3b64d76abdfaeda4ab716a0ec686f8e40b6f9a2cf50f0ad5f91e7f22e041b54a17676506b5a406673f3627ea202e79157d5265952df
@@ -1,3 +1,9 @@
1
+ 0.15.2 / 2015-12-03
2
+ ==================
3
+
4
+ * Documented `Pusher.channel_info`, `Pusher.channels`
5
+ * Added `Pusher.channel_users`
6
+
1
7
  0.15.1 / 2015-11-03
2
8
  ==================
3
9
 
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
- ### Generic requests to the Pusher REST API
128
+ ### Using the Pusher REST API
118
129
 
119
- Aside from triggering events, the REST API also supports a number of operations for querying the state of the system. A reference of the available methods is available at <http://pusher.com/docs/rest_api>.
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
- All requests must be signed by using your secret key, which is handled automatically using these methods:
132
+ The following methods are provided by the gem.
122
133
 
123
- ``` ruby
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
- # using a client
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
- Note that you don't need to specify your app_id in the URL, as this is inferred from your credentials.
138
+ - `Pusher.channels` returns information about all the channels in your Pusher application.
132
139
 
133
140
  ### Asynchronous requests
134
141
 
@@ -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
@@ -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
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "pusher"
6
- s.version = "0.15.1"
6
+ s.version = "0.15.2"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Pusher"]
9
9
  s.email = ["support@pusher.com"]
@@ -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.1
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-03 00:00:00.000000000 Z
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json