simultaneous 0.4.2 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/simultaneous.rb +1 -1
- data/lib/simultaneous/broadcast_message.rb +15 -6
- data/simultaneous.gemspec +2 -2
- data/test/test_message.rb +16 -0
- metadata +20 -29
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3df07a9e30710532aec1af60a2c792407bcf03ac
|
4
|
+
data.tar.gz: 6f64a25c5ec8582f986a3f8f6593c2a569304d1d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1251007c89c3cf7f6be01fae01e498f5b9d495998a7f778476a4d08e71656f5ad4720e96417d0afe0a1ca6fa1396113e5e1366e062626bf3ba958adeecfb2cec
|
7
|
+
data.tar.gz: 4dd6e2c19b5ca770458ee5a3e47d99e2747f81ea870c2d0fabde35ec723cf5f103c1d25b87ac33f34da6f2a67b28061d2411a9804379a10d269cfea1389d4c77
|
data/lib/simultaneous.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Simultaneous
|
4
4
|
class BroadcastMessage
|
5
|
-
attr_accessor :domain
|
5
|
+
attr_accessor :domain, :id
|
6
6
|
attr_reader :event
|
7
7
|
|
8
8
|
def initialize(values = {})
|
@@ -12,6 +12,11 @@ module Simultaneous
|
|
12
12
|
self.event = event
|
13
13
|
end
|
14
14
|
self.data = (values[:data] || values["data"] || "")
|
15
|
+
self.id = (values[:id] || next_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def next_id
|
19
|
+
SecureRandom.uuid
|
15
20
|
end
|
16
21
|
|
17
22
|
def event=(event)
|
@@ -33,6 +38,8 @@ module Simultaneous
|
|
33
38
|
self.domain = $1
|
34
39
|
when /^event: *(.+)/
|
35
40
|
self.event = $1
|
41
|
+
when /^id: *(.+)/
|
42
|
+
@id = $1
|
36
43
|
when /^data: *(.*)/
|
37
44
|
@data << $1
|
38
45
|
when /^:/
|
@@ -47,17 +54,19 @@ module Simultaneous
|
|
47
54
|
end
|
48
55
|
|
49
56
|
def to_event
|
50
|
-
lines = ["domain: #{domain}"
|
51
|
-
lines.concat(
|
52
|
-
lines.push("\n")
|
57
|
+
lines = ["domain: #{domain}"]
|
58
|
+
lines.concat(event_content)
|
53
59
|
lines.join("\n")
|
54
60
|
end
|
55
61
|
|
56
62
|
def to_sse
|
57
|
-
|
63
|
+
event_content.join("\n")
|
64
|
+
end
|
65
|
+
|
66
|
+
def event_content
|
67
|
+
lines = ["event: #{event}", "id: #{id}"]
|
58
68
|
lines.concat(@data.map { |l| "data: #{l}" })
|
59
69
|
lines.push("\n")
|
60
|
-
lines.join("\n")
|
61
70
|
end
|
62
71
|
end
|
63
72
|
end
|
data/simultaneous.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'simultaneous'
|
16
|
-
s.version = '0.
|
17
|
-
s.date = '
|
16
|
+
s.version = '0.5.2'
|
17
|
+
s.date = '2016-05-17'
|
18
18
|
s.rubyforge_project = 'simultaneous'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/test/test_message.rb
CHANGED
@@ -2,6 +2,12 @@ require File.expand_path('../helper', __FILE__)
|
|
2
2
|
|
3
3
|
describe Simultaneous::BroadcastMessage do
|
4
4
|
|
5
|
+
it "should assign a unique id to each message" do
|
6
|
+
message1 = Simultaneous::BroadcastMessage.new
|
7
|
+
message2 = Simultaneous::BroadcastMessage.new
|
8
|
+
message1.id.wont_equal message2.id
|
9
|
+
end
|
10
|
+
|
5
11
|
describe "when parsing input" do
|
6
12
|
before do
|
7
13
|
@message = Simultaneous::BroadcastMessage.new
|
@@ -16,6 +22,12 @@ describe Simultaneous::BroadcastMessage do
|
|
16
22
|
@message.valid?.wont_be :==, true
|
17
23
|
end
|
18
24
|
|
25
|
+
it "should recognise the id: header" do
|
26
|
+
@message << "id: 12345"
|
27
|
+
@message.id.must_equal "12345"
|
28
|
+
@message.valid?.wont_be :==, true
|
29
|
+
end
|
30
|
+
|
19
31
|
it "should recognise the event: header" do
|
20
32
|
@message << "event: name"
|
21
33
|
@message.event.must_equal "name"
|
@@ -46,6 +58,7 @@ describe Simultaneous::BroadcastMessage do
|
|
46
58
|
describe "when data has been parsed" do
|
47
59
|
before do
|
48
60
|
@message = Simultaneous::BroadcastMessage.new
|
61
|
+
@message.id = "62936e70-1815-439b-bf89-8492855a7e6b"
|
49
62
|
@message.event = "event"
|
50
63
|
@message.domain = "domain"
|
51
64
|
@message.data = "line 1\nline 2"
|
@@ -59,6 +72,7 @@ describe Simultaneous::BroadcastMessage do
|
|
59
72
|
@message.to_event.must_equal((<<-SRC).gsub(/^ */, ''))
|
60
73
|
domain: domain
|
61
74
|
event: event
|
75
|
+
id: 62936e70-1815-439b-bf89-8492855a7e6b
|
62
76
|
data: line 1
|
63
77
|
data: line 2
|
64
78
|
|
@@ -71,11 +85,13 @@ describe Simultaneous::BroadcastMessage do
|
|
71
85
|
message = Simultaneous::BroadcastMessage.new({
|
72
86
|
:domain => "domain",
|
73
87
|
:event => "event",
|
88
|
+
:id => "62936e70-1815-439b-bf89-8492855a7e6b",
|
74
89
|
:data => "line 1\nline 2"
|
75
90
|
})
|
76
91
|
message.domain.must_equal "domain"
|
77
92
|
message.event.must_equal "event"
|
78
93
|
message.data.must_equal "line 1\nline 2"
|
94
|
+
message.id.must_equal "62936e70-1815-439b-bf89-8492855a7e6b"
|
79
95
|
end
|
80
96
|
end
|
81
97
|
end
|
metadata
CHANGED
@@ -1,90 +1,81 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simultaneous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Garry Hill
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-05-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: eventmachine
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.0.0.rc.1
|
22
|
-
- - <
|
20
|
+
- - "<"
|
23
21
|
- !ruby/object:Gem::Version
|
24
22
|
version: '2.0'
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
|
-
- -
|
27
|
+
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 1.0.0.rc.1
|
33
|
-
- - <
|
30
|
+
- - "<"
|
34
31
|
- !ruby/object:Gem::Version
|
35
32
|
version: '2.0'
|
36
33
|
- !ruby/object:Gem::Dependency
|
37
34
|
name: rack
|
38
35
|
requirement: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
36
|
requirements:
|
41
|
-
- -
|
37
|
+
- - ">="
|
42
38
|
- !ruby/object:Gem::Version
|
43
39
|
version: '1.0'
|
44
|
-
- - <
|
40
|
+
- - "<"
|
45
41
|
- !ruby/object:Gem::Version
|
46
42
|
version: '2.0'
|
47
43
|
type: :runtime
|
48
44
|
prerelease: false
|
49
45
|
version_requirements: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
46
|
requirements:
|
52
|
-
- -
|
47
|
+
- - ">="
|
53
48
|
- !ruby/object:Gem::Version
|
54
49
|
version: '1.0'
|
55
|
-
- - <
|
50
|
+
- - "<"
|
56
51
|
- !ruby/object:Gem::Version
|
57
52
|
version: '2.0'
|
58
53
|
- !ruby/object:Gem::Dependency
|
59
54
|
name: async-rack
|
60
55
|
requirement: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
56
|
requirements:
|
63
|
-
- - ~>
|
57
|
+
- - "~>"
|
64
58
|
- !ruby/object:Gem::Version
|
65
59
|
version: 0.5.0
|
66
60
|
type: :runtime
|
67
61
|
prerelease: false
|
68
62
|
version_requirements: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
63
|
requirements:
|
71
|
-
- - ~>
|
64
|
+
- - "~>"
|
72
65
|
- !ruby/object:Gem::Version
|
73
66
|
version: 0.5.0
|
74
67
|
- !ruby/object:Gem::Dependency
|
75
68
|
name: rr
|
76
69
|
requirement: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
70
|
requirements:
|
79
|
-
- - ~>
|
71
|
+
- - "~>"
|
80
72
|
- !ruby/object:Gem::Version
|
81
73
|
version: 1.0.4
|
82
74
|
type: :development
|
83
75
|
prerelease: false
|
84
76
|
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
77
|
requirements:
|
87
|
-
- - ~>
|
78
|
+
- - "~>"
|
88
79
|
- !ruby/object:Gem::Version
|
89
80
|
version: 1.0.4
|
90
81
|
description: Simultaneous is designed for the very specific use case of a small set
|
@@ -135,26 +126,25 @@ files:
|
|
135
126
|
- test/test_task.rb
|
136
127
|
homepage: http://spontaneouscms.org
|
137
128
|
licenses: []
|
129
|
+
metadata: {}
|
138
130
|
post_install_message:
|
139
131
|
rdoc_options:
|
140
|
-
- --charset=UTF-8
|
132
|
+
- "--charset=UTF-8"
|
141
133
|
require_paths:
|
142
134
|
- lib
|
143
135
|
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
-
none: false
|
145
136
|
requirements:
|
146
|
-
- -
|
137
|
+
- - ">="
|
147
138
|
- !ruby/object:Gem::Version
|
148
139
|
version: '0'
|
149
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
-
none: false
|
151
141
|
requirements:
|
152
|
-
- -
|
142
|
+
- - ">="
|
153
143
|
- !ruby/object:Gem::Version
|
154
144
|
version: '0'
|
155
145
|
requirements: []
|
156
146
|
rubyforge_project: simultaneous
|
157
|
-
rubygems_version:
|
147
|
+
rubygems_version: 2.4.5
|
158
148
|
signing_key:
|
159
149
|
specification_version: 2
|
160
150
|
summary: Simultaneous is the background task launcher used by Spontaneous CMS
|
@@ -166,3 +156,4 @@ test_files:
|
|
166
156
|
- test/test_message.rb
|
167
157
|
- test/test_server.rb
|
168
158
|
- test/test_task.rb
|
159
|
+
has_rdoc:
|