shove 1.0.7 → 1.0.8
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.
- data/Gemfile +1 -2
- data/README.markdown +57 -91
- data/Rakefile +0 -23
- data/lib/shove.rb +3 -70
- data/lib/shove/app.rb +40 -33
- data/lib/shove/client/channel.rb +4 -0
- data/lib/shove/client/connection.rb +32 -14
- data/lib/shove/http/request.rb +2 -2
- data/lib/shove/protocol.rb +3 -1
- data/shove.gemspec +1 -3
- data/spec/cassettes/should_be_able_to_authorize_with_the_server.yml +10 -6
- data/spec/cassettes/should_deny_a_connection.yml +10 -6
- data/spec/cassettes/should_deny_a_control_to_a_client.yml +10 -6
- data/spec/cassettes/should_deny_a_publishing_to_a_client.yml +10 -6
- data/spec/cassettes/should_deny_a_subscriptions_to_a_client.yml +10 -6
- data/spec/cassettes/should_deny_publishing_on_a_channel_context.yml +10 -6
- data/spec/cassettes/should_deny_subscriptions_on_a_channel_context.yml +10 -6
- data/spec/cassettes/should_get_a_set_of_nodes_for_the_network.yml +11 -7
- data/spec/cassettes/should_grant_a_connection.yml +10 -6
- data/spec/cassettes/should_grant_a_control_to_a_client.yml +11 -7
- data/spec/cassettes/should_grant_a_publishing_to_a_client.yml +10 -6
- data/spec/cassettes/should_grant_a_subscriptions_to_a_client.yml +10 -6
- data/spec/cassettes/should_grant_publishing_on_a_channel_context.yml +10 -6
- data/spec/cassettes/should_grant_subscriptions_on_a_channel_context.yml +10 -6
- data/spec/cassettes/should_publish_on_a_channel_context.yml +10 -6
- data/spec/cassettes/should_publish_to_a_client.yml +10 -6
- data/spec/helper.rb +0 -2
- data/spec/shove_client_spec.rb +39 -30
- data/spec/shove_http_spec.rb +27 -31
- metadata +20 -40
- data/bin/shove +0 -169
- data/lib/shove/app_directory.rb +0 -103
- data/spec/app_directory_spec.rb +0 -66
- data/spec/cassettes/should_authorize_on_a_channel.yml +0 -26
- data/spec/cassettes/should_authorize_oneself.yml +0 -24
- data/spec/cassettes/should_cancel_a_binding.yml +0 -24
- data/spec/cassettes/should_configure_the_default.yml +0 -24
- data/spec/cassettes/should_configure_the_from_the_previous_test.yml +0 -24
- data/spec/cassettes/should_create_a_channel_context.yml +0 -24
- data/spec/cassettes/should_get_a_subscribe_granted_event.yml +0 -24
- data/spec/cassettes/should_publish.yml +0 -24
- data/spec/cassettes/should_receive_an_unsubscribe_event.yml +0 -24
- data/spec/cassettes/should_receive_messages_on_a_channel.yml +0 -24
- data/spec/cassettes/should_send_a_connect_op.yml +0 -24
- data/spec/cassettes/should_send_a_connect_op_with_an_id.yml +0 -24
- data/spec/cassettes/should_spawn_a_client.yml +0 -24
- data/spec/cassettes/should_subscribe_to_a_channel.yml +0 -24
- data/spec/cassettes/should_trigger_a_connect_denied_event.yml +0 -24
- data/spec/cassettes/should_trigger_a_connect_event.yml +0 -24
- data/spec/cassettes/should_trigger_a_disconnect_event.yml +0 -24
- data/spec/cassettes/should_trigger_an_error_event.yml +0 -24
- data/spec/cassettes/should_unsubscribe_from_a_channel.yml +0 -24
- data/spec/cassettes/should_update_the_default_app.yml +0 -24
@@ -2,8 +2,10 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: http://:test@api.shove.dev:
|
6
|
-
body:
|
5
|
+
uri: http://:test@api.shove.dev:8000/apps/test/grant_subscribe?channel=channel&client=dan
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
7
9
|
headers:
|
8
10
|
Accept:
|
9
11
|
- ! '*/*'
|
@@ -18,7 +20,9 @@ http_interactions:
|
|
18
20
|
- application/json; charset=UTF-8
|
19
21
|
Content-Length:
|
20
22
|
- '32'
|
21
|
-
body:
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
body:
|
24
|
+
encoding: US-ASCII
|
25
|
+
string: ! '{"code":"200 Ok","details":"Ok"}'
|
26
|
+
http_version:
|
27
|
+
recorded_at: Wed, 23 May 2012 02:35:38 GMT
|
28
|
+
recorded_with: VCR 2.0.1
|
@@ -2,8 +2,10 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: http://:test@api.shove.dev:
|
6
|
-
body:
|
5
|
+
uri: http://:test@api.shove.dev:8000/apps/test/grant_publish?channel=test&client=dan
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
7
9
|
headers:
|
8
10
|
Accept:
|
9
11
|
- ! '*/*'
|
@@ -18,7 +20,9 @@ http_interactions:
|
|
18
20
|
- application/json; charset=UTF-8
|
19
21
|
Content-Length:
|
20
22
|
- '32'
|
21
|
-
body:
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
body:
|
24
|
+
encoding: US-ASCII
|
25
|
+
string: ! '{"code":"200 Ok","details":"Ok"}'
|
26
|
+
http_version:
|
27
|
+
recorded_at: Wed, 23 May 2012 02:35:38 GMT
|
28
|
+
recorded_with: VCR 2.0.1
|
@@ -2,8 +2,10 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: http://:test@api.shove.dev:
|
6
|
-
body:
|
5
|
+
uri: http://:test@api.shove.dev:8000/apps/test/grant_subscribe?channel=test&client=dan
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
7
9
|
headers:
|
8
10
|
Accept:
|
9
11
|
- ! '*/*'
|
@@ -18,7 +20,9 @@ http_interactions:
|
|
18
20
|
- application/json; charset=UTF-8
|
19
21
|
Content-Length:
|
20
22
|
- '32'
|
21
|
-
body:
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
body:
|
24
|
+
encoding: US-ASCII
|
25
|
+
string: ! '{"code":"200 Ok","details":"Ok"}'
|
26
|
+
http_version:
|
27
|
+
recorded_at: Wed, 23 May 2012 02:35:38 GMT
|
28
|
+
recorded_with: VCR 2.0.1
|
@@ -2,8 +2,10 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: http://:test@api.shove.dev:
|
6
|
-
body:
|
5
|
+
uri: http://:test@api.shove.dev:8000/apps/test/publish?channel=test
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: hi
|
7
9
|
headers:
|
8
10
|
Accept:
|
9
11
|
- ! '*/*'
|
@@ -18,7 +20,9 @@ http_interactions:
|
|
18
20
|
- application/json; charset=UTF-8
|
19
21
|
Content-Length:
|
20
22
|
- '32'
|
21
|
-
body:
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
body:
|
24
|
+
encoding: US-ASCII
|
25
|
+
string: ! '{"code":"200 Ok","details":"Ok"}'
|
26
|
+
http_version:
|
27
|
+
recorded_at: Wed, 23 May 2012 02:35:38 GMT
|
28
|
+
recorded_with: VCR 2.0.1
|
@@ -2,8 +2,10 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: http://:test@api.shove.dev:
|
6
|
-
body:
|
5
|
+
uri: http://:test@api.shove.dev:8000/apps/test/publish?channel=direct:dan
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: hi
|
7
9
|
headers:
|
8
10
|
Accept:
|
9
11
|
- ! '*/*'
|
@@ -18,7 +20,9 @@ http_interactions:
|
|
18
20
|
- application/json; charset=UTF-8
|
19
21
|
Content-Length:
|
20
22
|
- '32'
|
21
|
-
body:
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
body:
|
24
|
+
encoding: US-ASCII
|
25
|
+
string: ! '{"code":"200 Ok","details":"Ok"}'
|
26
|
+
http_version:
|
27
|
+
recorded_at: Wed, 23 May 2012 02:35:38 GMT
|
28
|
+
recorded_with: VCR 2.0.1
|
data/spec/helper.rb
CHANGED
data/spec/shove_client_spec.rb
CHANGED
@@ -3,12 +3,12 @@ require File.dirname(__FILE__) + "/helper"
|
|
3
3
|
describe Shove::Client do
|
4
4
|
|
5
5
|
before(:all) do
|
6
|
-
Shove.
|
7
|
-
app_id "test"
|
8
|
-
app_key "test"
|
9
|
-
api_url "http://api.shove.dev:
|
10
|
-
ws_url "ws://shove.dev:9000"
|
11
|
-
|
6
|
+
@app = Shove::App.new(
|
7
|
+
app_id: "test",
|
8
|
+
app_key: "test",
|
9
|
+
api_url: "http://api.shove.dev:8000",
|
10
|
+
ws_url: "ws://shove.dev:9000"
|
11
|
+
)
|
12
12
|
end
|
13
13
|
|
14
14
|
before do |context|
|
@@ -21,26 +21,25 @@ describe Shove::Client do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should spawn a client" do
|
24
|
-
@client =
|
24
|
+
@client = @app.connect
|
25
25
|
@client.should_not == nil
|
26
|
-
@client.url.should == "#{
|
26
|
+
@client.url.should == "#{@app.ws_url}/test"
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should send a connect op" do
|
30
|
-
@client =
|
31
|
-
message = $queue.
|
30
|
+
@client = @app.connect
|
31
|
+
message = $queue.shift
|
32
32
|
message["opcode"].should == Shove::Protocol::CONNECT
|
33
33
|
end
|
34
34
|
|
35
|
-
it "should
|
36
|
-
@client =
|
35
|
+
it "should self authorize if key is set" do
|
36
|
+
@client = @app.connect
|
37
37
|
message = $queue.pop
|
38
|
-
message["opcode"].should == Shove::Protocol::
|
39
|
-
message["data"].should == "monkey"
|
38
|
+
message["opcode"].should == Shove::Protocol::AUTHORIZE
|
40
39
|
end
|
41
40
|
|
42
41
|
it "should trigger a connect event" do
|
43
|
-
@client =
|
42
|
+
@client = @app.connect
|
44
43
|
@client.on("connect") do |client_id|
|
45
44
|
@triggered = true
|
46
45
|
@id = client_id
|
@@ -53,7 +52,7 @@ describe Shove::Client do
|
|
53
52
|
end
|
54
53
|
|
55
54
|
it "should trigger a connect_denied event" do
|
56
|
-
@client =
|
55
|
+
@client = @app.connect
|
57
56
|
@client.on("connect_denied") do |client_id|
|
58
57
|
@triggered = true
|
59
58
|
@id = client_id
|
@@ -67,7 +66,7 @@ describe Shove::Client do
|
|
67
66
|
|
68
67
|
|
69
68
|
it "should trigger a disconnect event" do
|
70
|
-
@client =
|
69
|
+
@client = @app.connect
|
71
70
|
@client.on("disconnect") do
|
72
71
|
@triggered = true
|
73
72
|
end
|
@@ -78,7 +77,7 @@ describe Shove::Client do
|
|
78
77
|
end
|
79
78
|
|
80
79
|
it "should trigger an error event" do
|
81
|
-
@client =
|
80
|
+
@client = @app.connect
|
82
81
|
@client.on("error") do |error|
|
83
82
|
@error = error
|
84
83
|
end
|
@@ -89,13 +88,13 @@ describe Shove::Client do
|
|
89
88
|
end
|
90
89
|
|
91
90
|
it "should authorize oneself" do
|
92
|
-
@client =
|
93
|
-
@client.
|
91
|
+
@client = @app.connect
|
92
|
+
@client.auth!
|
94
93
|
$queue.last()["opcode"].should == Shove::Protocol::AUTHORIZE
|
95
94
|
end
|
96
95
|
|
97
96
|
it "should create a channel context" do
|
98
|
-
@client =
|
97
|
+
@client = @app.connect
|
99
98
|
@channel = @client.channel("channel")
|
100
99
|
|
101
100
|
@channel.should_not == nil
|
@@ -103,7 +102,7 @@ describe Shove::Client do
|
|
103
102
|
end
|
104
103
|
|
105
104
|
it "should subscribe to a channel" do
|
106
|
-
@client =
|
105
|
+
@client = @app.connect
|
107
106
|
@channel = @client.channel("channel")
|
108
107
|
$queue.last["opcode"].should_not == Shove::Protocol::SUBSCRIBE
|
109
108
|
@channel.on("message") do
|
@@ -112,7 +111,7 @@ describe Shove::Client do
|
|
112
111
|
end
|
113
112
|
|
114
113
|
it "should get a subscribe granted event" do
|
115
|
-
@client =
|
114
|
+
@client = @app.connect
|
116
115
|
@channel = @client.channel("channel")
|
117
116
|
@channel.on("subscribe") do
|
118
117
|
@triggered = true
|
@@ -127,7 +126,7 @@ describe Shove::Client do
|
|
127
126
|
@messages = 0
|
128
127
|
@message = nil
|
129
128
|
|
130
|
-
@client =
|
129
|
+
@client = @app.connect
|
131
130
|
@channel = @client.channel("channel")
|
132
131
|
@channel.on("message") do |msg|
|
133
132
|
@messages += 1
|
@@ -143,7 +142,7 @@ describe Shove::Client do
|
|
143
142
|
it "should cancel a binding" do
|
144
143
|
@messages = 0
|
145
144
|
|
146
|
-
@client =
|
145
|
+
@client = @app.connect
|
147
146
|
@channel = @client.channel("channel")
|
148
147
|
binding = @channel.on("message") do |msg|
|
149
148
|
@messages += 1
|
@@ -164,7 +163,7 @@ describe Shove::Client do
|
|
164
163
|
end
|
165
164
|
|
166
165
|
it "should unsubscribe from a channel" do
|
167
|
-
@client =
|
166
|
+
@client = @app.connect
|
168
167
|
@channel = @client.channel("channel")
|
169
168
|
@channel.unsubscribe
|
170
169
|
@message = $queue.last
|
@@ -172,7 +171,7 @@ describe Shove::Client do
|
|
172
171
|
end
|
173
172
|
|
174
173
|
it "should receive an unsubscribe event" do
|
175
|
-
@client =
|
174
|
+
@client = @app.connect
|
176
175
|
@channel = @client.channel("channel")
|
177
176
|
@channel.unsubscribe
|
178
177
|
@channel.on("unsubscribe") do
|
@@ -186,7 +185,7 @@ describe Shove::Client do
|
|
186
185
|
|
187
186
|
|
188
187
|
it "should publish" do
|
189
|
-
@client =
|
188
|
+
@client = @app.connect
|
190
189
|
@channel = @client.channel("channel")
|
191
190
|
@channel.publish "test"
|
192
191
|
|
@@ -194,12 +193,22 @@ describe Shove::Client do
|
|
194
193
|
end
|
195
194
|
|
196
195
|
it "should generate a channel key" do
|
197
|
-
key =
|
196
|
+
key = @app.channel_key "money"
|
197
|
+
key.should == "5cf0a03b439091a07eb544832fc11c62f0b1af17"
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should generate a subscribe key" do
|
201
|
+
key = @app.subscribe_key "money"
|
198
202
|
key.should == "6f78f2ba414a482fc5c45eb080d8877ddf1fc6ba"
|
199
203
|
end
|
200
204
|
|
205
|
+
it "should generate a publish key" do
|
206
|
+
key = @app.publish_key "money"
|
207
|
+
key.should == "5cf0a03b439091a07eb544832fc11c62f0b1af17"
|
208
|
+
end
|
209
|
+
|
201
210
|
it "should authorize on a channel" do
|
202
|
-
@client =
|
211
|
+
@client = @app.connect
|
203
212
|
@channel = @client.channel("channel")
|
204
213
|
@channel.authorize "key"
|
205
214
|
|
data/spec/shove_http_spec.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/helper"
|
2
2
|
|
3
|
-
describe Shove
|
3
|
+
describe Shove::Http do
|
4
4
|
|
5
5
|
before(:all) do
|
6
|
-
Shove.
|
7
|
-
app_id "test"
|
8
|
-
app_key "test"
|
9
|
-
api_url "http://api.shove.dev:
|
10
|
-
ws_url "ws://shove.dev:9000"
|
11
|
-
|
6
|
+
@app = Shove::App.new(
|
7
|
+
app_id: "test",
|
8
|
+
app_key: "test",
|
9
|
+
api_url: "http://api.shove.dev:8000",
|
10
|
+
ws_url: "ws://shove.dev:9000"
|
11
|
+
)
|
12
12
|
end
|
13
13
|
|
14
14
|
before do |context|
|
@@ -23,55 +23,51 @@ describe Shove:Http do
|
|
23
23
|
Shove.const_defined?("Version").should == true
|
24
24
|
end
|
25
25
|
|
26
|
-
it "should have config" do
|
27
|
-
Shove.config.app_id.should == "test"
|
28
|
-
Shove.config.app_key.should == "test"
|
29
|
-
end
|
30
26
|
|
31
27
|
it "should be able to authorize with the server" do
|
32
|
-
valid =
|
28
|
+
valid = @app.valid?
|
33
29
|
valid.should == true
|
34
30
|
end
|
35
31
|
|
36
32
|
it "should get a set of nodes for the network" do
|
37
|
-
hosts =
|
33
|
+
hosts = @app.hosts
|
38
34
|
hosts.size.should > 0
|
39
35
|
end
|
40
36
|
|
41
37
|
# Channel context tests, basic plumbing
|
42
38
|
|
43
39
|
it "should spawn a channel context" do
|
44
|
-
chan =
|
40
|
+
chan = @app.channel("test")
|
45
41
|
chan.channel.should == "test"
|
46
|
-
chan.app.should ==
|
42
|
+
chan.app.should == @app
|
47
43
|
end
|
48
44
|
|
49
45
|
it "should publish on a channel context" do
|
50
|
-
|
46
|
+
@app.channel("test").publish("hi") do |response|
|
51
47
|
response.error?.should == false
|
52
48
|
end
|
53
49
|
end
|
54
50
|
|
55
51
|
it "should grant subscriptions on a channel context" do
|
56
|
-
|
52
|
+
@app.channel("test").grant_subscribe("dan") do |response|
|
57
53
|
response.error?.should == false
|
58
54
|
end
|
59
55
|
end
|
60
56
|
|
61
57
|
it "should grant publishing on a channel context" do
|
62
|
-
|
58
|
+
@app.channel("test").grant_publish("dan") do |response|
|
63
59
|
response.error?.should == false
|
64
60
|
end
|
65
61
|
end
|
66
62
|
|
67
63
|
it "should deny subscriptions on a channel context" do
|
68
|
-
|
64
|
+
@app.channel("test").deny_subscribe("dan") do |response|
|
69
65
|
response.error?.should == false
|
70
66
|
end
|
71
67
|
end
|
72
68
|
|
73
69
|
it "should deny publishing on a channel context" do
|
74
|
-
|
70
|
+
@app.channel("test").deny_publish("dan") do |response|
|
75
71
|
response.error?.should == false
|
76
72
|
end
|
77
73
|
end
|
@@ -79,61 +75,61 @@ describe Shove:Http do
|
|
79
75
|
# Client context tests, basic plumbing
|
80
76
|
|
81
77
|
it "should spawn a client context" do
|
82
|
-
chan =
|
78
|
+
chan = @app.client("dan")
|
83
79
|
chan.id.should == "dan"
|
84
|
-
chan.app.should ==
|
80
|
+
chan.app.should == @app
|
85
81
|
end
|
86
82
|
|
87
83
|
it "should grant a connection" do
|
88
|
-
|
84
|
+
@app.client("dan").grant_connect do |response|
|
89
85
|
response.error?.should == false
|
90
86
|
end
|
91
87
|
end
|
92
88
|
|
93
89
|
it "should deny a connection" do
|
94
|
-
|
90
|
+
@app.client("dan").deny_connect do |response|
|
95
91
|
response.error?.should == false
|
96
92
|
end
|
97
93
|
end
|
98
94
|
|
99
95
|
it "should publish to a client" do
|
100
|
-
|
96
|
+
@app.client("dan").publish("hi") do |response|
|
101
97
|
response.error?.should == false
|
102
98
|
end
|
103
99
|
end
|
104
100
|
|
105
101
|
it "should grant a subscriptions to a client" do
|
106
|
-
|
102
|
+
@app.client("dan").grant_subscribe("channel") do |response|
|
107
103
|
response.error?.should == false
|
108
104
|
end
|
109
105
|
end
|
110
106
|
|
111
107
|
it "should grant a publishing to a client" do
|
112
|
-
|
108
|
+
@app.client("dan").grant_publish("channel") do |response|
|
113
109
|
response.error?.should == false
|
114
110
|
end
|
115
111
|
end
|
116
112
|
|
117
113
|
it "should grant a control to a client" do
|
118
|
-
|
114
|
+
@app.client("dan").grant_control do |response|
|
119
115
|
response.error?.should == false
|
120
116
|
end
|
121
117
|
end
|
122
118
|
|
123
119
|
it "should deny a subscriptions to a client" do
|
124
|
-
|
120
|
+
@app.client("dan").deny_subscribe("channel") do |response|
|
125
121
|
response.error?.should == false
|
126
122
|
end
|
127
123
|
end
|
128
124
|
|
129
125
|
it "should deny a publishing to a client" do
|
130
|
-
|
126
|
+
@app.client("dan").deny_publish("channel") do |response|
|
131
127
|
response.error?.should == false
|
132
128
|
end
|
133
129
|
end
|
134
130
|
|
135
131
|
it "should deny a control to a client" do
|
136
|
-
|
132
|
+
@app.client("dan").deny_control do |response|
|
137
133
|
response.error?.should == false
|
138
134
|
end
|
139
135
|
end
|