pusher-fake 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  require "em-websocket"
2
- require "hmac-sha2"
2
+ require "multi_json"
3
+ require "openssl"
3
4
  require "thin"
4
- require "yajl"
5
5
 
6
6
  require "pusher-fake/channel"
7
7
  require "pusher-fake/channel/public"
@@ -14,7 +14,7 @@ require "pusher-fake/server/application"
14
14
 
15
15
  module PusherFake
16
16
  # The current version string.
17
- VERSION = "0.1.5"
17
+ VERSION = "0.2.0"
18
18
 
19
19
  # Call this method to modify the defaults.
20
20
  #
@@ -43,7 +43,7 @@ module PusherFake
43
43
  # @param [Connection] connection The connection a subscription succeeded for.
44
44
  # @param [Hash] options The options for the channel.
45
45
  def subscription_succeeded(connection, options = {})
46
- members[connection] = Yajl::Parser.parse(options[:channel_data], symbolize_keys: true)
46
+ members[connection] = MultiJson.load(options[:channel_data], symbolize_keys: true)
47
47
 
48
48
  emit("pusher_internal:member_added", members[connection])
49
49
 
@@ -35,7 +35,8 @@ module PusherFake
35
35
  def authentication_for(id, data = nil)
36
36
  configuration = PusherFake.configuration
37
37
  string = [id, name, data].compact.map(&:to_s).join(":")
38
- signature = HMAC::SHA256.hexdigest(configuration.secret, string)
38
+ digest = OpenSSL::Digest::SHA256.new
39
+ signature = OpenSSL::HMAC.hexdigest(digest, configuration.secret, string)
39
40
 
40
41
  "#{configuration.key}:#{signature}"
41
42
  end
@@ -18,7 +18,7 @@ module PusherFake
18
18
  def emit(event, data = {}, channel = nil)
19
19
  message = { event: event, data: data }
20
20
  message[:channel] = channel if channel
21
- message = Yajl::Encoder.encode(message)
21
+ message = MultiJson.dump(message)
22
22
 
23
23
  socket.send(message)
24
24
  end
@@ -32,7 +32,7 @@ module PusherFake
32
32
  #
33
33
  # @param [String] data The event data as JSON.
34
34
  def process(data)
35
- message = Yajl::Parser.parse(data, symbolize_keys: true)
35
+ message = MultiJson.load(data, symbolize_keys: true)
36
36
  data = message[:data]
37
37
  event = message[:event]
38
38
  channel_name = message[:channel] || data.delete(:channel)
@@ -8,7 +8,7 @@ module PusherFake
8
8
  # @return [Rack::Response] A successful response.
9
9
  def self.call(environment)
10
10
  request = Rack::Request.new(environment)
11
- event = Yajl::Parser.parse(request.body.read)
11
+ event = MultiJson.load(request.body.read)
12
12
 
13
13
  event["channels"].each do |channel|
14
14
  Channel.factory(channel).emit(event["name"], event["data"])
@@ -26,7 +26,7 @@ describe PusherFake::Channel::Presence, "#add" do
26
26
  subject { PusherFake::Channel::Presence.new("name") }
27
27
 
28
28
  before do
29
- Yajl::Parser.stubs(:parse).returns(channel_data)
29
+ MultiJson.stubs(:load).returns(channel_data)
30
30
  subject.stubs(connections: connections, emit: nil, subscription_data: subscription_data)
31
31
  end
32
32
 
@@ -39,7 +39,7 @@ describe PusherFake::Channel::Presence, "#add" do
39
39
  it "parses the channel_data when authorized" do
40
40
  subject.stubs(authorized?: true)
41
41
  subject.add(connection, data)
42
- Yajl::Parser.should have_received(:parse).with(data[:channel_data], symbolize_keys: true)
42
+ MultiJson.should have_received(:load).with(data[:channel_data], symbolize_keys: true)
43
43
  end
44
44
 
45
45
  it "assigns the parsed channel_data to the members hash for the current connection" do
@@ -56,12 +56,12 @@ describe PusherFake::Channel::Private, "#authentication_for" do
56
56
 
57
57
  before do
58
58
  PusherFake.stubs(configuration: configuration)
59
- HMAC::SHA256.stubs(hexdigest: signature)
59
+ OpenSSL::HMAC.stubs(hexdigest: signature)
60
60
  end
61
61
 
62
62
  it "generates a signature" do
63
63
  subject.authentication_for(id)
64
- HMAC::SHA256.should have_received(:hexdigest).with(configuration.secret, string)
64
+ OpenSSL::HMAC.should have_received(:hexdigest).with(kind_of(OpenSSL::Digest::SHA256), configuration.secret, string)
65
65
  end
66
66
 
67
67
  it "returns the authentication string" do
@@ -81,12 +81,12 @@ describe PusherFake::Channel::Private, "#authentication_for, with channel data"
81
81
 
82
82
  before do
83
83
  PusherFake.stubs(configuration: configuration)
84
- HMAC::SHA256.stubs(hexdigest: signature)
84
+ OpenSSL::HMAC.stubs(hexdigest: signature)
85
85
  end
86
86
 
87
87
  it "generates a signature" do
88
88
  subject.authentication_for(id, channel_data)
89
- HMAC::SHA256.should have_received(:hexdigest).with(configuration.secret, string)
89
+ OpenSSL::HMAC.should have_received(:hexdigest).with(kind_of(OpenSSL::Digest::SHA256), configuration.secret, string)
90
90
  end
91
91
 
92
92
  it "returns the authentication string" do
@@ -13,12 +13,12 @@ end
13
13
 
14
14
  describe PusherFake::Connection, "#emit" do
15
15
  let(:data) { { some: "data", good: true } }
16
- let(:json) { Yajl::Encoder.encode(message) }
16
+ let(:json) { MultiJson.dump(message) }
17
17
  let(:event) { "name" }
18
18
  let(:socket) { stub(:send) }
19
19
  let(:channel) { "channel" }
20
20
  let(:message) { { event: event, data: data } }
21
- let(:channel_json) { Yajl::Encoder.encode(message.merge(channel: channel)) }
21
+ let(:channel_json) { MultiJson.dump(message.merge(channel: channel)) }
22
22
 
23
23
  subject { PusherFake::Connection.new(socket) }
24
24
 
@@ -58,13 +58,13 @@ describe PusherFake::Connection, "#process, with a subscribe event" do
58
58
  subject { PusherFake::Connection.new(stub) }
59
59
 
60
60
  before do
61
- Yajl::Parser.stubs(parse: message)
61
+ MultiJson.stubs(load: message)
62
62
  PusherFake::Channel.stubs(factory: channel)
63
63
  end
64
64
 
65
65
  it "parses the JSON data" do
66
66
  subject.process(json)
67
- Yajl::Parser.should have_received(:parse).with(json, symbolize_keys: true)
67
+ MultiJson.should have_received(:load).with(json, symbolize_keys: true)
68
68
  end
69
69
 
70
70
  it "creates a channel from the event data" do
@@ -87,13 +87,13 @@ describe PusherFake::Connection, "#process, with an unsubscribe event" do
87
87
  subject { PusherFake::Connection.new(stub) }
88
88
 
89
89
  before do
90
- Yajl::Parser.stubs(parse: message)
90
+ MultiJson.stubs(load: message)
91
91
  PusherFake::Channel.stubs(factory: channel)
92
92
  end
93
93
 
94
94
  it "parses the JSON data" do
95
95
  subject.process(json)
96
- Yajl::Parser.should have_received(:parse).with(json, symbolize_keys: true)
96
+ MultiJson.should have_received(:load).with(json, symbolize_keys: true)
97
97
  end
98
98
 
99
99
  it "creates a channel from the event data" do
@@ -118,13 +118,13 @@ describe PusherFake::Connection, "#process, with a client event" do
118
118
  subject { PusherFake::Connection.new(stub) }
119
119
 
120
120
  before do
121
- Yajl::Parser.stubs(parse: message)
121
+ MultiJson.stubs(load: message)
122
122
  PusherFake::Channel.stubs(factory: channel)
123
123
  end
124
124
 
125
125
  it "parses the JSON data" do
126
126
  subject.process(json)
127
- Yajl::Parser.should have_received(:parse).with(json, symbolize_keys: true)
127
+ MultiJson.should have_received(:load).with(json, symbolize_keys: true)
128
128
  end
129
129
 
130
130
  it "creates a channel from the event data" do
@@ -172,13 +172,13 @@ describe PusherFake::Connection, "#process, with an unknown event" do
172
172
  subject { PusherFake::Connection.new(stub) }
173
173
 
174
174
  before do
175
- Yajl::Parser.stubs(parse: message)
175
+ MultiJson.stubs(load: message)
176
176
  PusherFake::Channel.stubs(factory: channel)
177
177
  end
178
178
 
179
179
  it "parses the JSON data" do
180
180
  subject.process(json)
181
- Yajl::Parser.should have_received(:parse).with(json, symbolize_keys: true)
181
+ MultiJson.should have_received(:load).with(json, symbolize_keys: true)
182
182
  end
183
183
 
184
184
  it "creates a channel from the event data" do
@@ -18,7 +18,7 @@ describe PusherFake::Server::Application, ".call" do
18
18
  before do
19
19
  response.stubs(finish: response)
20
20
 
21
- Yajl::Parser.stubs(parse: event)
21
+ MultiJson.stubs(load: event)
22
22
  Rack::Request.stubs(new: request)
23
23
  Rack::Response.stubs(new: response)
24
24
  PusherFake::Channel.stubs(:factory).with(channels[0]).returns(channel_1)
@@ -32,7 +32,7 @@ describe PusherFake::Server::Application, ".call" do
32
32
 
33
33
  it "parses the request body as JSON" do
34
34
  subject.call(environment)
35
- Yajl::Parser.should have_received(:parse).with(json)
35
+ MultiJson.should have_received(:load).with(json)
36
36
  end
37
37
 
38
38
  it "creates channels by name" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher-fake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-13 00:00:00.000000000 Z
12
+ date: 2012-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: em-websocket
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.3.8
30
- - !ruby/object:Gem::Dependency
31
- name: ruby-hmac
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - '='
36
- - !ruby/object:Gem::Version
37
- version: 0.4.0
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - '='
44
- - !ruby/object:Gem::Version
45
- version: 0.4.0
46
30
  - !ruby/object:Gem::Dependency
47
31
  name: thin
48
32
  requirement: !ruby/object:Gem::Requirement
@@ -60,13 +44,13 @@ dependencies:
60
44
  - !ruby/object:Gem::Version
61
45
  version: 1.5.0
62
46
  - !ruby/object:Gem::Dependency
63
- name: yajl-ruby
47
+ name: multi_json
64
48
  requirement: !ruby/object:Gem::Requirement
65
49
  none: false
66
50
  requirements:
67
51
  - - '='
68
52
  - !ruby/object:Gem::Version
69
- version: 1.1.0
53
+ version: 1.3.7
70
54
  type: :runtime
71
55
  prerelease: false
72
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +58,7 @@ dependencies:
74
58
  requirements:
75
59
  - - '='
76
60
  - !ruby/object:Gem::Version
77
- version: 1.1.0
61
+ version: 1.3.7
78
62
  - !ruby/object:Gem::Dependency
79
63
  name: bourne
80
64
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +66,7 @@ dependencies:
82
66
  requirements:
83
67
  - - '='
84
68
  - !ruby/object:Gem::Version
85
- version: 1.2.0
69
+ version: 1.2.1
86
70
  type: :development
87
71
  prerelease: false
88
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +74,7 @@ dependencies:
90
74
  requirements:
91
75
  - - '='
92
76
  - !ruby/object:Gem::Version
93
- version: 1.2.0
77
+ version: 1.2.1
94
78
  - !ruby/object:Gem::Dependency
95
79
  name: bundler
96
80
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +146,7 @@ dependencies:
162
146
  requirements:
163
147
  - - '='
164
148
  - !ruby/object:Gem::Version
165
- version: 0.10.0
149
+ version: 0.11.1
166
150
  type: :development
167
151
  prerelease: false
168
152
  version_requirements: !ruby/object:Gem::Requirement
@@ -170,7 +154,7 @@ dependencies:
170
154
  requirements:
171
155
  - - '='
172
156
  - !ruby/object:Gem::Version
173
- version: 0.10.0
157
+ version: 0.11.1
174
158
  - !ruby/object:Gem::Dependency
175
159
  name: rake
176
160
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +162,7 @@ dependencies:
178
162
  requirements:
179
163
  - - '='
180
164
  - !ruby/object:Gem::Version
181
- version: 10.0.0
165
+ version: 10.0.2
182
166
  type: :development
183
167
  prerelease: false
184
168
  version_requirements: !ruby/object:Gem::Requirement
@@ -186,7 +170,7 @@ dependencies:
186
170
  requirements:
187
171
  - - '='
188
172
  - !ruby/object:Gem::Version
189
- version: 10.0.0
173
+ version: 10.0.2
190
174
  - !ruby/object:Gem::Dependency
191
175
  name: redcarpet
192
176
  requirement: !ruby/object:Gem::Requirement
@@ -210,7 +194,7 @@ dependencies:
210
194
  requirements:
211
195
  - - '='
212
196
  - !ruby/object:Gem::Version
213
- version: 2.11.0
197
+ version: 2.12.0
214
198
  type: :development
215
199
  prerelease: false
216
200
  version_requirements: !ruby/object:Gem::Requirement
@@ -218,7 +202,7 @@ dependencies:
218
202
  requirements:
219
203
  - - '='
220
204
  - !ruby/object:Gem::Version
221
- version: 2.11.0
205
+ version: 2.12.0
222
206
  - !ruby/object:Gem::Dependency
223
207
  name: sinatra
224
208
  requirement: !ruby/object:Gem::Requirement
@@ -306,7 +290,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
306
290
  version: '0'
307
291
  segments:
308
292
  - 0
309
- hash: 2596033998219902442
293
+ hash: 680940724053515135
310
294
  required_rubygems_version: !ruby/object:Gem::Requirement
311
295
  none: false
312
296
  requirements:
@@ -315,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
299
  version: '0'
316
300
  segments:
317
301
  - 0
318
- hash: 2596033998219902442
302
+ hash: 680940724053515135
319
303
  requirements: []
320
304
  rubyforge_project:
321
305
  rubygems_version: 1.8.23