pusher 0.18.0 → 1.0.0
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/.travis.yml +3 -7
- data/CHANGELOG.md +6 -0
- data/lib/pusher/channel.rb +8 -8
- data/lib/pusher/client.rb +6 -5
- data/pusher.gemspec +1 -1
- data/spec/channel_spec.rb +1 -1
- data/spec/client_spec.rb +13 -1
- 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: 41c533b3af72b8bbc59b837e057140c199df3dde
|
4
|
+
data.tar.gz: 72c2170cf91722d54cee192da0afda69f3304462
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7991ee28bfe11b60a97fae9deaec6896fd538c45747ece3804d6db77f4b01aaedc4a407a3f4d77c5b1a3d12c7eac2365c9262ce3da1f2cad3f70652f0ce459ae
|
7
|
+
data.tar.gz: 02eb45ed9d8b1ed4a899084a2eca8912facd311214b45f6131b83c721a12681246b28733d394c25cbff730c1e5005d9a81878687557855949ed832c8d81aec2e
|
data/.travis.yml
CHANGED
@@ -1,19 +1,15 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
rvm:
|
4
|
-
- 1.9.2
|
5
4
|
- 1.9.3
|
6
|
-
- 2.0
|
5
|
+
- 2.0
|
7
6
|
- 2.1
|
8
7
|
- 2.2
|
9
8
|
- 2.3.0
|
10
|
-
- jruby
|
11
|
-
- jruby-19mode
|
9
|
+
- jruby
|
12
10
|
- rbx-2
|
13
11
|
|
14
12
|
matrix:
|
15
13
|
allow_failures:
|
16
|
-
-
|
17
|
-
- rvm: jruby-18mode
|
18
|
-
- rvm: jruby-19mode
|
14
|
+
- rvm: jruby
|
19
15
|
- rvm: rbx-2
|
data/CHANGELOG.md
CHANGED
data/lib/pusher/channel.rb
CHANGED
@@ -2,18 +2,17 @@ require 'openssl'
|
|
2
2
|
require 'multi_json'
|
3
3
|
|
4
4
|
module Pusher
|
5
|
-
#
|
5
|
+
# Delegates operations for a specific channel from a client
|
6
6
|
class Channel
|
7
7
|
attr_reader :name
|
8
8
|
INVALID_CHANNEL_REGEX = /[^A-Za-z0-9_\-=@,.;]/
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
def initialize(_, name, client = Pusher)
|
11
11
|
if Pusher::Channel::INVALID_CHANNEL_REGEX.match(name)
|
12
12
|
raise Pusher::Error, "Illegal channel name '#{name}'"
|
13
|
-
elsif name.length >
|
13
|
+
elsif name.length > 200
|
14
14
|
raise Pusher::Error, "Channel name too long (limit 164 characters) '#{name}'"
|
15
15
|
end
|
16
|
-
@uri.path = @uri.path + "/channels/#{name}/"
|
17
16
|
@name = name
|
18
17
|
@client = client
|
19
18
|
end
|
@@ -93,7 +92,7 @@ module Pusher
|
|
93
92
|
# @raise [Pusher::HTTPError] on any error raised inside http client - the original error is available in the original_error attribute
|
94
93
|
#
|
95
94
|
def info(attributes = [])
|
96
|
-
@client.
|
95
|
+
@client.channel_info(name, :info => attributes.join(','))
|
97
96
|
end
|
98
97
|
|
99
98
|
# Request users for a presence channel
|
@@ -102,12 +101,13 @@ module Pusher
|
|
102
101
|
# @example Response
|
103
102
|
# [{"id"=>"4"}]
|
104
103
|
#
|
104
|
+
# @param params [Hash] Hash of parameters for the API - see REST API docs
|
105
105
|
# @return [Hash] Array of user hashes for this channel
|
106
106
|
# @raise [Pusher::Error] on invalid Pusher response - see the error message for more details
|
107
107
|
# @raise [Pusher::HTTPError] on any error raised inside Net::HTTP - the original error is available in the original_error attribute
|
108
108
|
#
|
109
|
-
def users
|
110
|
-
@client.
|
109
|
+
def users(params = {})
|
110
|
+
@client.channel_users(name, params)[:users]
|
111
111
|
end
|
112
112
|
|
113
113
|
# Compute authentication string required as part of the authentication
|
data/lib/pusher/client.rb
CHANGED
@@ -187,17 +187,18 @@ module Pusher
|
|
187
187
|
WebHook.new(request, self)
|
188
188
|
end
|
189
189
|
|
190
|
-
# Return a convenience channel object by name
|
190
|
+
# Return a convenience channel object by name that delegates operations
|
191
|
+
# on a channel. No API request is made.
|
191
192
|
#
|
192
193
|
# @example
|
193
194
|
# Pusher['my-channel']
|
194
195
|
# @return [Channel]
|
195
|
-
# @raise [
|
196
|
-
#
|
196
|
+
# @raise [Pusher::Error] if the channel name is invalid.
|
197
|
+
# Channel names should be less than 200 characters, and
|
197
198
|
# should not contain anything other than letters, numbers, or the
|
198
199
|
# characters "_\-=@,.;"
|
199
200
|
def channel(channel_name)
|
200
|
-
Channel.new(
|
201
|
+
Channel.new(nil, channel_name, self)
|
201
202
|
end
|
202
203
|
|
203
204
|
alias :[] :channel
|
@@ -233,7 +234,7 @@ module Pusher
|
|
233
234
|
get("/channels/#{channel_name}", params)
|
234
235
|
end
|
235
236
|
|
236
|
-
# Request info for users of a channel
|
237
|
+
# Request info for users of a presence channel
|
237
238
|
#
|
238
239
|
# GET /apps/[id]/channels/[channel_name]/users
|
239
240
|
#
|
data/pusher.gemspec
CHANGED
data/spec/channel_spec.rb
CHANGED
@@ -87,7 +87,7 @@ describe Pusher::Channel do
|
|
87
87
|
|
88
88
|
describe '#users' do
|
89
89
|
it "should call the Client#channel_users" do
|
90
|
-
expect(@client).to receive(:get).with("/channels/presence-mychannel/users").and_return({:users => {'id' => '4'}})
|
90
|
+
expect(@client).to receive(:get).with("/channels/presence-mychannel/users", {}).and_return({:users => {'id' => '4'}})
|
91
91
|
@channel = @client['presence-mychannel']
|
92
92
|
@channel.users
|
93
93
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -141,7 +141,7 @@ describe Pusher do
|
|
141
141
|
it "should raise exception if app_id is not configured" do
|
142
142
|
@client.app_id = nil
|
143
143
|
expect {
|
144
|
-
@
|
144
|
+
@channel.trigger!('foo', 'bar')
|
145
145
|
}.to raise_error(Pusher::ConfigurationError)
|
146
146
|
end
|
147
147
|
end
|
@@ -260,6 +260,18 @@ describe Pusher do
|
|
260
260
|
expect(MultiJson.decode(req.body)["channels"]).to eq(['mychannel'])
|
261
261
|
}
|
262
262
|
end
|
263
|
+
|
264
|
+
%w[app_id key secret].each do |key|
|
265
|
+
it "should fail in missing #{key}" do
|
266
|
+
@client.public_send("#{key}=", nil)
|
267
|
+
expect {
|
268
|
+
@client.trigger('mychannel', 'event', {'some' => 'data'})
|
269
|
+
}.to raise_error(Pusher::ConfigurationError)
|
270
|
+
expect(WebMock).not_to have_requested(:post, @api_path).with { |req|
|
271
|
+
expect(MultiJson.decode(req.body)["channels"]).to eq(['mychannel'])
|
272
|
+
}
|
273
|
+
end
|
274
|
+
end
|
263
275
|
end
|
264
276
|
|
265
277
|
describe '#trigger_async' do
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pusher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|