pusher-client 0.6.0 → 0.6.1

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: bf04dc511a185b1a37118fb7aa892d5f7582ae51
4
- data.tar.gz: 39c0e1be1d0b4452804727e9f33237ea398bbd67
3
+ metadata.gz: ca0b6841ec8088d1414317b0c1c632480120de91
4
+ data.tar.gz: 1ea3ba5948397e263dd3a941a4093638933abf24
5
5
  SHA512:
6
- metadata.gz: d28001be9d6969ed7a86bcfbed7507e3f292cd518a5230acf3203cc8573e140af69315b53ba20adcf686c008bf48e133e73e8350bbabb75044d1787edc5dfaaf
7
- data.tar.gz: f96d506e8b24e69b922233ed3a85f660bbbfcf2b5e962ca5e633f088339dc712e528a5ba6ba05512d687fc743520a7674b8c68962061d74c7b33a5941b2a329e
6
+ metadata.gz: 351e96ba78075a7ca23cad3d561b0246344775c2d53d009ac39ce5dc098bbd3b88a595e632789bf794de659f37770c66e8b5b29e08f86c37e5df0c6d55b42ead
7
+ data.tar.gz: 6096c73347065726af44d9242fb945a055646f3225ccb98dfe84d80646cc9544dc8271c37c5f456442337572abc09edef39587c749de1c9bdd57ac1e5384a74b
@@ -1,6 +1,6 @@
1
1
  = pusher-client (Ruby)
2
2
 
3
- {<img src="https://travis-ci.org/pusher/pusher-ruby-client.png" />}[https://travis-ci.org/pusher/pusher-ruby-client]
3
+ {<img src="https://travis-ci.org/pusher/pusher-websocket-ruby.png" />}[https://travis-ci.org/pusher/pusher-websocket-ruby]
4
4
 
5
5
  pusher-client is a ruby gem for consuming WebSockets from the Pusher[http://pusherapp.com] web service.
6
6
 
@@ -13,12 +13,12 @@ may be sent on. You can't just bind a global event without subscribing to any ch
13
13
 
14
14
  == Installation
15
15
  gem install pusher-client
16
-
16
+
17
17
  == Single-Threaded Usage
18
18
  The application will pause at socket.connect and handle events from Pusher as they happen.
19
19
 
20
20
  require 'pusher-client'
21
- options = {:secret => 'YOUR_APPLICATION_SECRET'}
21
+ options = { secure: true }
22
22
  socket = PusherClient::Socket.new(YOUR_APPLICATION_KEY, options)
23
23
 
24
24
  # Subscribe to two channels
@@ -84,7 +84,7 @@ increase by including the websocket-native[https://github.com/imanel/websocket-r
84
84
  gem in your Gemfile.
85
85
 
86
86
  == Contributing to pusher-client
87
-
87
+
88
88
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
89
89
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
90
90
  * Fork the project
@@ -21,7 +21,7 @@ module PusherClient
21
21
  @global_channel = Channel.new('pusher_global_channel')
22
22
  @global_channel.global = true
23
23
  @connected = false
24
- @encrypted = options[:encrypted] || false
24
+ @encrypted = options[:encrypted] || options[:secure] || false
25
25
  @logger = options[:logger] || PusherClient.logger
26
26
  # :private_auth_method is deprecated
27
27
  @auth_method = options[:auth_method] || options[:private_auth_method]
@@ -203,12 +203,14 @@ module PusherClient
203
203
  logger.debug("Websocket connected")
204
204
 
205
205
  loop do
206
- msg = @connection.receive.first
207
- next if msg.nil?
208
- params = parser(msg)
209
- next if params['socket_id'] && params['socket_id'] == self.socket_id
206
+ @connection.receive.each do |msg|
207
+ params = parser(msg)
210
208
 
211
- send_local_event(params['event'], params['data'], params['channel'])
209
+ # why ?
210
+ next if params['socket_id'] && params['socket_id'] == self.socket_id
211
+
212
+ send_local_event(params['event'], params['data'], params['channel'])
213
+ end
212
214
  end
213
215
  end
214
216
 
@@ -1,3 +1,3 @@
1
1
  module PusherClient
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
@@ -84,9 +84,6 @@ module PusherClient
84
84
  messages << message.to_s
85
85
  end
86
86
  messages
87
- rescue IOError, Errno::EBADF => error
88
- logger.debug error.message
89
- []
90
87
  end
91
88
 
92
89
  def close
@@ -37,11 +37,11 @@ describe "A PusherClient::Channel" do
37
37
  end
38
38
 
39
39
  it 'should not be subscribed by default' do
40
- expect(@channel.subscribed).to be_false
40
+ expect(@channel.subscribed).to be_falsey
41
41
  end
42
42
 
43
43
  it 'should not be global by default' do
44
- expect(@channel.global).to be_false
44
+ expect(@channel.global).to be_falsey
45
45
  end
46
46
 
47
47
  it 'can have procs bound to an event' do
@@ -67,7 +67,7 @@ describe "A PusherClient::Socket" do
67
67
  end
68
68
 
69
69
  it 'should not connect when instantiated' do
70
- expect(@socket.connected).to be_false
70
+ expect(@socket.connected).to be_falsey
71
71
  end
72
72
 
73
73
  it 'should raise ArgumentError if TEST_APP_KEY is an empty string' do
@@ -85,7 +85,7 @@ describe "A PusherClient::Socket" do
85
85
  end
86
86
 
87
87
  it 'should know its connected' do
88
- expect(@socket.connected).to be_true
88
+ expect(@socket.connected).to be_truthy
89
89
  end
90
90
 
91
91
  it 'should know its socket_id' do
@@ -93,13 +93,13 @@ describe "A PusherClient::Socket" do
93
93
  end
94
94
 
95
95
  it 'should not be subscribed to its global channel' do
96
- expect(@socket.global_channel.subscribed).to be_false
96
+ expect(@socket.global_channel.subscribed).to be_falsey
97
97
  end
98
98
 
99
99
  it 'should subscribe to a channel' do
100
100
  @channel = @socket.subscribe('testchannel')
101
101
  expect(@socket.channels['testchannel']).to eq(@channel)
102
- expect(@channel.subscribed).to be_true
102
+ expect(@channel.subscribed).to be_truthy
103
103
  end
104
104
 
105
105
  it 'should unsubscribe from a channel' do
@@ -112,31 +112,31 @@ describe "A PusherClient::Socket" do
112
112
  it 'should subscribe to a private channel' do
113
113
  @channel = @socket.subscribe('private-testchannel')
114
114
  expect(@socket.channels['private-testchannel']).to eq(@channel)
115
- expect(@channel.subscribed).to be_true
115
+ expect(@channel.subscribed).to be_truthy
116
116
  end
117
117
 
118
118
  it 'should subscribe to a presence channel with user_id' do
119
119
  @channel = @socket.subscribe('presence-testchannel', '123')
120
120
  expect(@socket.channels['presence-testchannel']).to eq(@channel)
121
121
  expect(@channel.user_data).to eq('{"user_id":"123"}')
122
- expect(@channel.subscribed).to be_true
122
+ expect(@channel.subscribed).to be_truthy
123
123
  end
124
124
 
125
125
  it 'should subscribe to a presence channel with custom channel_data' do
126
126
  @channel = @socket.subscribe('presence-testchannel', :user_id => '123', :user_name => 'john')
127
127
  expect(@socket.channels['presence-testchannel']).to eq(@channel)
128
128
  expect(@channel.user_data).to eq('{"user_id":"123","user_name":"john"}')
129
- expect(@channel.subscribed).to be_true
129
+ expect(@channel.subscribed).to be_truthy
130
130
  end
131
131
 
132
132
  it 'should allow binding of global events' do
133
133
  @socket.bind('testevent') { |data| PusherClient.logger.test("testchannel received #{data}") }
134
- expect(@socket.global_channel.callbacks.has_key?('testevent')).to be_true
134
+ expect(@socket.global_channel.callbacks.has_key?('testevent')).to be_truthy
135
135
  end
136
136
 
137
137
  it 'should trigger callbacks for global events' do
138
138
  @socket.bind('globalevent') { |data| PusherClient.logger.test("Global event!") }
139
- expect(@socket.global_channel.callbacks.has_key?('globalevent')).to be_true
139
+ expect(@socket.global_channel.callbacks.has_key?('globalevent')).to be_truthy
140
140
 
141
141
  @socket.simulate_received('globalevent', 'some data', '')
142
142
  expect(PusherClient.logger.test_messages.last).to include('Global event!')
@@ -149,7 +149,7 @@ describe "A PusherClient::Socket" do
149
149
 
150
150
  it 'should not be connected after disconnecting' do
151
151
  @socket.disconnect
152
- expect(@socket.connected).to be_false
152
+ expect(@socket.connected).to be_falsey
153
153
  end
154
154
 
155
155
  describe "when subscribed to a channel" do
@@ -159,7 +159,7 @@ describe "A PusherClient::Socket" do
159
159
 
160
160
  it 'should allow binding of callbacks for the subscribed channel' do
161
161
  @socket['testchannel'].bind('testevent') { |data| PusherClient.logger.test(data) }
162
- expect(@socket['testchannel'].callbacks.has_key?('testevent')).to be_true
162
+ expect(@socket['testchannel'].callbacks.has_key?('testevent')).to be_truthy
163
163
  end
164
164
 
165
165
  it "should trigger channel callbacks when a message is received" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pusher
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-23 00:00:00.000000000 Z
12
+ date: 2015-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: websocket
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  requirements: []
134
134
  rubyforge_project:
135
- rubygems_version: 2.0.14
135
+ rubygems_version: 2.4.6
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: Client for consuming WebSockets from http://pusher.com