sse-rails-engine 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -0
- data/config/initializers/headers.rb +2 -0
- data/config/initializers/sse_rails_engine.rb +2 -0
- data/config/routes.rb +2 -0
- data/lib/sse-rails-engine.rb +2 -0
- data/lib/sse_rails_engine/connection.rb +2 -0
- data/lib/sse_rails_engine/engine.rb +2 -0
- data/lib/sse_rails_engine/manager.rb +3 -1
- data/lib/sse_rails_engine/version.rb +3 -1
- data/lib/tasks/sse_rails_engine_tasks.rake +1 -0
- data/test/lib/sse-rails-engine_test.rb +2 -0
- data/test/lib/sse_rails_engine/manager_test.rb +12 -6
- data/test/test_helper.rb +4 -2
- metadata +11 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7793cd5c317e56e1d7ba0099d48b4ffbaf401166
|
4
|
+
data.tar.gz: bd04618ad62d2cf1645ad6dcb39832abde4ebb2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a88b9a69c47446be9b73ae4e1f8944a8a7ee487f92c899a5e2b3842beb7020407b3379e24f871b434f57bf51cc3fa1df51a03c478c7dfbb14395cfe55823eb5
|
7
|
+
data.tar.gz: aaf940645b4345b30c6ca584c937301101d4bba6caa55256a29919bb048e2a5fed1a0c88740558a34643f7e7f5881c7ab8d2a6ff63af06971cf6a627f0226358
|
data/Rakefile
CHANGED
data/config/routes.rb
CHANGED
data/lib/sse-rails-engine.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SseRailsEngine
|
2
4
|
# This class provides the ability to track SSE connections and broadcast events
|
3
5
|
# to all connected clients from anywhere in your Rails app.
|
@@ -32,7 +34,7 @@ module SseRailsEngine
|
|
32
34
|
# Perform full hijack of socket (http://old.blog.phusion.nl/2013/01/23/the-new-rack-socket-hijacking-api/)
|
33
35
|
open_connection(socket, env)
|
34
36
|
else
|
35
|
-
|
37
|
+
raise RackHijackUnsupported, 'This Rack server does not support hijacking, ensure you are using >= v1.5 of Rack'
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../test_helper'
|
2
4
|
|
3
5
|
describe SseRailsEngine::Manager do
|
4
6
|
let(:manager) { SseRailsEngine.manager }
|
5
|
-
let(:env1) {
|
6
|
-
let(:env2) {
|
7
|
+
let(:env1) { { 'rack.hijack?' => true, 'rack.hijack' => ->() {}, 'rack.hijack_io' => StringIO.new } }
|
8
|
+
let(:env2) { { 'rack.hijack?' => true, 'rack.hijack' => ->() {}, 'rack.hijack_io' => StringIO.new } }
|
7
9
|
|
8
10
|
before do
|
9
11
|
SseRailsEngine.instance_variable_set(:@manager, nil)
|
@@ -75,7 +77,8 @@ describe SseRailsEngine::Manager do
|
|
75
77
|
manager.register(env1)
|
76
78
|
manager.send_event('foo')
|
77
79
|
env1['rack.hijack_io'].string.must_equal(
|
78
|
-
SseRailsEngine::Connection.sse_header + "event: foo\ndata: \n\n", 'env1 should have received event'
|
80
|
+
SseRailsEngine::Connection.sse_header + "event: foo\ndata: \n\n", 'env1 should have received event'
|
81
|
+
)
|
79
82
|
end
|
80
83
|
|
81
84
|
it 'does not send events to clients that didnt register for them' do
|
@@ -83,7 +86,8 @@ describe SseRailsEngine::Manager do
|
|
83
86
|
manager.register(env1)
|
84
87
|
manager.send_event('test')
|
85
88
|
env1['rack.hijack_io'].string.must_equal(
|
86
|
-
SseRailsEngine::Connection.sse_header, 'env2 should not have received event'
|
89
|
+
SseRailsEngine::Connection.sse_header, 'env2 should not have received event'
|
90
|
+
)
|
87
91
|
end
|
88
92
|
|
89
93
|
it 'filters msgs depending on channels requested' do
|
@@ -92,8 +96,10 @@ describe SseRailsEngine::Manager do
|
|
92
96
|
manager.register(env2)
|
93
97
|
manager.send_event('test')
|
94
98
|
env1['rack.hijack_io'].string.must_equal(
|
95
|
-
SseRailsEngine::Connection.sse_header + "event: test\ndata: \n\n", 'env1 should have received event'
|
99
|
+
SseRailsEngine::Connection.sse_header + "event: test\ndata: \n\n", 'env1 should have received event'
|
100
|
+
)
|
96
101
|
env2['rack.hijack_io'].string.must_equal(
|
97
|
-
SseRailsEngine::Connection.sse_header, 'env2 should not have received event'
|
102
|
+
SseRailsEngine::Connection.sse_header, 'env2 should not have received event'
|
103
|
+
)
|
98
104
|
end
|
99
105
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Configure Rails Environment
|
2
4
|
ENV['RAILS_ENV'] = 'test'
|
3
5
|
|
6
|
+
require 'bundler/setup'
|
4
7
|
require 'codeclimate-test-reporter'
|
5
8
|
CodeClimate::TestReporter.start if ENV['CODECLIMATE_REPO_TOKEN']
|
6
9
|
|
7
|
-
require File.expand_path('../../test/dummy/config/environment.rb',
|
10
|
+
require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
|
8
11
|
require 'rails/test_help'
|
9
12
|
require 'minitest/rails'
|
10
13
|
require 'mocha/mini_test'
|
11
|
-
require 'hashie'
|
12
14
|
|
13
15
|
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
14
16
|
# to be shown.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sse-rails-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Hender
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,34 +16,34 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.2.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '5.
|
22
|
+
version: '5.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 4.2.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '5.
|
32
|
+
version: '5.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: minitest-rails
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '3.0'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '3.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: mocha
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,34 +72,20 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: hashie
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '3.0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '3.0'
|
89
75
|
- !ruby/object:Gem::Dependency
|
90
76
|
name: codeclimate-test-reporter
|
91
77
|
requirement: !ruby/object:Gem::Requirement
|
92
78
|
requirements:
|
93
79
|
- - "~>"
|
94
80
|
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
81
|
+
version: '0.0'
|
96
82
|
type: :development
|
97
83
|
prerelease: false
|
98
84
|
version_requirements: !ruby/object:Gem::Requirement
|
99
85
|
requirements:
|
100
86
|
- - "~>"
|
101
87
|
- !ruby/object:Gem::Version
|
102
|
-
version: '0'
|
88
|
+
version: '0.0'
|
103
89
|
- !ruby/object:Gem::Dependency
|
104
90
|
name: rubocop
|
105
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
173
|
version: '0'
|
188
174
|
requirements: []
|
189
175
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
176
|
+
rubygems_version: 2.5.2
|
191
177
|
signing_key:
|
192
178
|
specification_version: 4
|
193
179
|
summary: Provides SSE connection tracking and broadcasting of events from anywhere
|