pusher 0.18.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6445dc1dff7034c9fa013bb13c06d797a3d508d3
4
- data.tar.gz: cbadd3ea95efed035d3c8f87af33b76d7315b14c
3
+ metadata.gz: 41c533b3af72b8bbc59b837e057140c199df3dde
4
+ data.tar.gz: 72c2170cf91722d54cee192da0afda69f3304462
5
5
  SHA512:
6
- metadata.gz: 4f512577534b021e70ffe2d87838c7be5437139d6f0a38d90d4ef467d8e0d738192033fcdfd21aad3a9c88370908417bf03cb7450d887ccf9cfe05130d29c068
7
- data.tar.gz: 3ca887136f17144e1fa3ca1fa8c35a12ce82ee5d0f16711da327c0429f4042f041d2df6b2e6f02f0f3a2a3eaba0ed0f0db0ace46eecff914d330b264ebcf20dd
6
+ metadata.gz: 7991ee28bfe11b60a97fae9deaec6896fd538c45747ece3804d6db77f4b01aaedc4a407a3f4d77c5b1a3d12c7eac2365c9262ce3da1f2cad3f70652f0ce459ae
7
+ data.tar.gz: 02eb45ed9d8b1ed4a899084a2eca8912facd311214b45f6131b83c721a12681246b28733d394c25cbff730c1e5005d9a81878687557855949ed832c8d81aec2e
@@ -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.0
5
+ - 2.0
7
6
  - 2.1
8
7
  - 2.2
9
8
  - 2.3.0
10
- - jruby-18mode
11
- - jruby-19mode
9
+ - jruby
12
10
  - rbx-2
13
11
 
14
12
  matrix:
15
13
  allow_failures:
16
- - rmv: 1.9.2
17
- - rvm: jruby-18mode
18
- - rvm: jruby-19mode
14
+ - rvm: jruby
19
15
  - rvm: rbx-2
@@ -1,4 +1,10 @@
1
1
 
2
+ 1.0.0 / 2016-05-19
3
+ ==================
4
+
5
+ No breaking changes, this release is just to follow semver and show that we
6
+ are stable.
7
+
2
8
  0.18.0 / 2016-05-15
3
9
  ==================
4
10
 
@@ -2,18 +2,17 @@ require 'openssl'
2
2
  require 'multi_json'
3
3
 
4
4
  module Pusher
5
- # Trigger events on Channels
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
- def initialize(base_url, name, client = Pusher)
10
- @uri = base_url.dup
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 > 164
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.get("/channels/#{name}", :info => attributes.join(','))
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.get("/channels/#{name}/users")[:users]
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
@@ -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. No API request is made.
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 [ConfigurationError] unless key, secret and app_id have been
196
- # configured. Channel names should be less than 200 characters, and
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(url, channel_name, self)
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
  #
@@ -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.18.0"
6
+ s.version = "1.0.0"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Pusher"]
9
9
  s.email = ["support@pusher.com"]
@@ -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
@@ -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
- @client['test_channel']
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.18.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-15 00:00:00.000000000 Z
11
+ date: 2016-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json