colossus 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/colossus.rb +3 -0
- data/lib/colossus/simple_presence_getter.rb +25 -0
- data/lib/colossus/version.rb +1 -1
- data/lib/colossus/writer_client.rb +17 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29e892f552f7b1e7006ab8b54b9ee2506bc76140
|
4
|
+
data.tar.gz: 4301a17519aae2422829ddb64989ba66f0f8fb79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1758d63196f43d769709e0fa7cabe69c2a48bcc2417dddeef83a4c8cf4a5b1dbe62722cae5110aff92426ba554cce8b2df879ee6b8a2a125ec0e6a26c5efc38e
|
7
|
+
data.tar.gz: 6794006a3ec61295e54ad3c3252005b5aa11a75386147da9c327000aac5c2c72153d580431515808104323070806b81460f3f9f96b5871f0b80ed91973787e3c
|
data/lib/colossus.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'faye'
|
2
|
+
require 'json'
|
2
3
|
require 'openssl'
|
4
|
+
require 'faraday'
|
3
5
|
require 'observer'
|
4
6
|
require 'em-synchrony'
|
5
7
|
require 'securerandom'
|
@@ -7,6 +9,7 @@ require 'securerandom'
|
|
7
9
|
require 'colossus/configuration'
|
8
10
|
require 'colossus/verifier'
|
9
11
|
require 'colossus/writer_client'
|
12
|
+
require 'colossus/simple_presence_getter'
|
10
13
|
|
11
14
|
require 'colossus/engines/memory/memory'
|
12
15
|
require 'colossus/engines/memory/client_session'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Colossus
|
2
|
+
class SimplePresenceGetter
|
3
|
+
attr_reader :colossus
|
4
|
+
|
5
|
+
def initialize(colossus)
|
6
|
+
@colossus = colossus
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_presences(writer_token, optional_user_ids = nil)
|
10
|
+
raise 'Invalid token' unless valid?(writer_token)
|
11
|
+
user_ids = Array(optional_user_ids) if optional_user_ids
|
12
|
+
if user_ids && user_ids.is_a?(Array)
|
13
|
+
Hash[user_ids.zip(colossus.get_multi(user_ids))]
|
14
|
+
elsif user_ids == nil
|
15
|
+
colossus.get_all
|
16
|
+
else
|
17
|
+
raise 'Invalid user_ids data'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid?(writer_token)
|
22
|
+
colossus.verifier.verify_writer_token(writer_token)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/colossus/version.rb
CHANGED
@@ -18,6 +18,23 @@ class Colossus
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def get_presences_by_http(optional_user_ids = nil)
|
22
|
+
user_ids = Array(optional_user_ids) if optional_user_ids
|
23
|
+
# Custom Content-Type to indicate to the server
|
24
|
+
# this is a simple http request
|
25
|
+
conn = Faraday.new(url, headers: {'Content-Type' => 'application/vnd.http.json'}) do |conf|
|
26
|
+
conf.adapter Faraday.default_adapter
|
27
|
+
conf.response :raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
body = conn.post do |req|
|
31
|
+
req.body = JSON.dump({ user_ids: user_ids, writer_token: writer_token})
|
32
|
+
end.body
|
33
|
+
|
34
|
+
response = JSON.parse(body)
|
35
|
+
response['statuses']
|
36
|
+
end
|
37
|
+
|
21
38
|
def push_message(user_ids, message)
|
22
39
|
user_ids = Array(user_ids)
|
23
40
|
EM.synchrony do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colossus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- antoinelyset
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faye
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Colossus is a Push and Presence pure Ruby server. It uses Faye internally.
|
42
56
|
email:
|
43
57
|
- antoinelyset+github@gmail.com
|
@@ -51,6 +65,7 @@ files:
|
|
51
65
|
- lib/colossus/engines/memory/client_session_store.rb
|
52
66
|
- lib/colossus/engines/memory/memory.rb
|
53
67
|
- lib/colossus/faye/extension.rb
|
68
|
+
- lib/colossus/simple_presence_getter.rb
|
54
69
|
- lib/colossus/verifier.rb
|
55
70
|
- lib/colossus/version.rb
|
56
71
|
- lib/colossus/writer_client.rb
|