kosmonaut 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/README +28 -28
- data/lib/kosmonaut/client.rb +2 -2
- data/lib/kosmonaut/version.rb +2 -2
- data/test/test_kosmonaut_client.rb +1 -1
- metadata +2 -2
data/ChangeLog
CHANGED
data/README
CHANGED
@@ -31,53 +31,53 @@ for example:
|
|
31
31
|
Worker is used to listen for incoming messages and handle
|
32
32
|
it in user's desired way, example:
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
34
|
+
class MyWorker < Kosmonaut::Worker
|
35
|
+
def on_message(event, data)
|
36
|
+
if event == "hello"
|
37
|
+
puts "Hello #{data[:who]}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def on_error(err)
|
42
|
+
puts "Error encountered (code #{err.to_s})"
|
43
|
+
end
|
44
|
+
|
45
|
+
def on_exception(err)
|
46
|
+
puts "Ouch! something went wrong! Error: #{err.to_s}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
w = MyWorker.new("wr://token@127.0.0.1:8081/vhost")
|
51
|
+
w.listen
|
52
52
|
|
53
53
|
Hacking
|
54
54
|
-------
|
55
55
|
If you want to run kosmonaut.rb in development mode, first clone
|
56
56
|
the repo and install dependencies:
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
$ git clone https://github.com/webrocket/kosmonaut.rb.git
|
59
|
+
$ cd kosmonaut.rb
|
60
|
+
$ bundle
|
61
61
|
|
62
62
|
To run the tests you should have a `webrocket-server` instance
|
63
63
|
running with a `/test` vhost created. To create it use the
|
64
64
|
`webrocket-admin` tool:
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
$ webrocket-admin add_vhost /test
|
67
|
+
Reading cookie... done
|
68
|
+
Adding a vhost... done
|
69
|
+
---
|
70
|
+
Access token for this vhost: a70d7d2c0bc5761620948b3420d18df9072ca0d1
|
71
71
|
|
72
72
|
Now get the access token and run kosmonaut's tests using
|
73
73
|
rake task:
|
74
74
|
|
75
|
-
|
75
|
+
$ VHOST_TOKEN=a70d7d2c0bc5761620948b3420d18df9072ca0d1 rake test
|
76
76
|
|
77
77
|
If you want to get debug output add a `DEBUG` environment variable
|
78
78
|
while running tests:
|
79
79
|
|
80
|
-
|
80
|
+
$ VHOST_TOKEN=... DEBUG=1 rake test
|
81
81
|
|
82
82
|
With any quirks and doubts don't hesitate to start a github issue
|
83
83
|
or email one of the maintainers.
|
data/lib/kosmonaut/client.rb
CHANGED
@@ -53,8 +53,8 @@ module Kosmonaut
|
|
53
53
|
perform_request(payload)
|
54
54
|
end
|
55
55
|
|
56
|
-
def request_single_access_token(permission)
|
57
|
-
payload = ["AT", permission]
|
56
|
+
def request_single_access_token(uid, permission)
|
57
|
+
payload = ["AT", uid, permission]
|
58
58
|
perform_request(payload)
|
59
59
|
end
|
60
60
|
|
data/lib/kosmonaut/version.rb
CHANGED
@@ -48,7 +48,7 @@ class TestKosmonautClient < MiniTest::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def _test_request_single_access_token
|
51
|
-
token = @client.request_single_access_token(".*")
|
51
|
+
token = @client.request_single_access_token("joe", ".*")
|
52
52
|
assert token
|
53
53
|
assert_equal 128, token.size
|
54
54
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: kosmonaut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Krzysztof Kowalik
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2012-01-
|
14
|
+
date: 2012-01-24 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json
|