garufa 0.0.1.beta.1 → 0.0.1.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/garufa.gemspec +10 -9
- data/lib/garufa/subscriptions.rb +1 -1
- data/lib/garufa/version.rb +1 -1
- data/test/connection.rb +31 -0
- data/test/message.rb +4 -4
- data/test/subscriptions.rb +56 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bbc4d733e7b71f96bdb8b0d0929daffd9042615
|
4
|
+
data.tar.gz: 2c3d7c91f49298af24a5f1e6f05ea9a3c4345354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a44c756812053df6672f5a123635785ad017dfa92ce5d6cf86fd6937f956f91eb9ffa451783afadea861ce41dd3ac9a5dcf9ea18d02c11c42bdc977754e21ec
|
7
|
+
data.tar.gz: 3e41c06d811cdb818a0282566d0817ff3ffcacbd936b1d8ef78785f6d97299ba91715d2dfedb6feb9fe5c09bd2adf767c733e0aafb0c0bbab98286bdbdbd280e
|
data/garufa.gemspec
CHANGED
@@ -4,15 +4,15 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
4
4
|
require 'garufa/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
s.summary
|
10
|
-
s.description
|
11
|
-
s.authors
|
12
|
-
s.email
|
13
|
-
s.homepage
|
14
|
-
s.bindir
|
15
|
-
s.executables
|
7
|
+
s.name = "garufa"
|
8
|
+
s.version = Garufa::VERSION
|
9
|
+
s.summary = "Websocket server compatible with Pusher."
|
10
|
+
s.description = "Garufa is a websocket server compatible with the Pusher protocol."
|
11
|
+
s.authors = ["Juan Manuel Cuello"]
|
12
|
+
s.email = ["juanmacuello@gmail.com"]
|
13
|
+
s.homepage = "http://github.com/Juanmcuello/garufa"
|
14
|
+
s.bindir = 'bin'
|
15
|
+
s.executables << 'garufa'
|
16
16
|
|
17
17
|
s.files = Dir[
|
18
18
|
"LICENSE",
|
@@ -29,4 +29,5 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_dependency "cuba"
|
30
30
|
s.add_dependency "signature"
|
31
31
|
s.add_development_dependency "rake"
|
32
|
+
s.add_development_dependency "minitest", '~> 5.3.1'
|
32
33
|
end
|
data/lib/garufa/subscriptions.rb
CHANGED
data/lib/garufa/version.rb
CHANGED
data/test/connection.rb
CHANGED
@@ -11,6 +11,18 @@ module Garufa
|
|
11
11
|
|
12
12
|
describe '.handle_incomming_data' do
|
13
13
|
|
14
|
+
describe 'pusher:ping' do
|
15
|
+
|
16
|
+
let(:data) { { event: 'pusher:ping', data: { channel: 'ch1' } } }
|
17
|
+
|
18
|
+
it 'should response with pong' do
|
19
|
+
message = Message.pong
|
20
|
+
@socket.expect :send, true, [message.to_json]
|
21
|
+
@connection.handle_incomming_data data.to_json
|
22
|
+
@socket.verify
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
14
26
|
describe 'pusher:subscribe' do
|
15
27
|
|
16
28
|
let(:data) { { event: 'pusher:subscribe', data: { channel: 'ch1' } } }
|
@@ -70,6 +82,25 @@ module Garufa
|
|
70
82
|
end
|
71
83
|
end
|
72
84
|
end
|
85
|
+
|
86
|
+
describe 'pusher:unsubscribe' do
|
87
|
+
|
88
|
+
let(:channel) { 'ch1' }
|
89
|
+
let(:data_subscribe) { { event: 'pusher:subscribe', data: { channel: channel } } }
|
90
|
+
let(:data_unsubscribe) { { event: 'pusher:unsubscribe', data: { channel: channel } } }
|
91
|
+
|
92
|
+
before do
|
93
|
+
@socket.expect :send, true, [String]
|
94
|
+
@connection.handle_incomming_data data_subscribe.to_json
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should remove Subscription from Subscriptions' do
|
98
|
+
count = Subscriptions.all[channel].count
|
99
|
+
@connection.handle_incomming_data data_unsubscribe.to_json
|
100
|
+
Subscriptions.all[channel].count.must_equal count - 1
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
73
104
|
end
|
74
105
|
end
|
75
106
|
end
|
data/test/message.rb
CHANGED
@@ -27,11 +27,11 @@ module Garufa
|
|
27
27
|
|
28
28
|
describe '.channel_event' do
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
let(:channel) { 'channel-123' }
|
31
|
+
let(:event) { 'my-event' }
|
32
|
+
let(:data) { { itemId: 1, value: 'Sample Item' } }
|
33
33
|
|
34
|
-
|
34
|
+
before do
|
35
35
|
@message = Message.channel_event channel, event, data
|
36
36
|
end
|
37
37
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path("helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module Garufa
|
4
|
+
describe Subscriptions do
|
5
|
+
|
6
|
+
let(:channel) { 'channel1' }
|
7
|
+
let(:data) { { 'channel' => channel } }
|
8
|
+
|
9
|
+
describe '.remove' do
|
10
|
+
|
11
|
+
before do
|
12
|
+
@subscription = Subscription.new(data, nil)
|
13
|
+
Subscriptions.add @subscription
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should remove subscription to channel' do
|
17
|
+
count = Subscriptions.all[channel].count
|
18
|
+
Subscriptions.remove @subscription
|
19
|
+
Subscriptions.all[channel].count.must_equal count - 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.add' do
|
24
|
+
|
25
|
+
before do
|
26
|
+
@connection = MiniTest::Mock.new
|
27
|
+
@connection.expect :socket_id, true
|
28
|
+
@connection.expect :send_message, true, [Message]
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should add a new subscription to channel' do
|
32
|
+
count = Subscriptions.all[channel].count
|
33
|
+
Subscriptions.add Subscription.new(data, @connection)
|
34
|
+
Subscriptions.all[channel].count.must_equal count + 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '.notify' do
|
39
|
+
|
40
|
+
let(:event) { 'my-event' }
|
41
|
+
|
42
|
+
it 'should notify to subscribed subscriptions' do
|
43
|
+
|
44
|
+
@connection = MiniTest::Mock.new
|
45
|
+
@connection.expect :socket_id, true
|
46
|
+
@connection.expect(:send_message, true) do |m|
|
47
|
+
Message.channel_event(channel, event, nil).to_json == m.to_json
|
48
|
+
end
|
49
|
+
|
50
|
+
Subscriptions.add Subscription.new(data, @connection)
|
51
|
+
Subscriptions.notify([channel], event)
|
52
|
+
@connection.verify
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: garufa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.beta.
|
4
|
+
version: 0.0.1.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Manuel Cuello
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: goliath
|
@@ -80,7 +80,21 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 5.3.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 5.3.1
|
97
|
+
description: Garufa is a websocket server compatible with the Pusher protocol.
|
84
98
|
email:
|
85
99
|
- juanmacuello@gmail.com
|
86
100
|
executables:
|
@@ -107,6 +121,7 @@ files:
|
|
107
121
|
- garufa.gemspec
|
108
122
|
- test/helper.rb
|
109
123
|
- test/message.rb
|
124
|
+
- test/subscriptions.rb
|
110
125
|
- test/connection.rb
|
111
126
|
homepage: http://github.com/Juanmcuello/garufa
|
112
127
|
licenses: []
|