volt-sockjs 0.3.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENCE +19 -0
- data/README.textile +118 -0
- data/lib/meta-state.rb +151 -0
- data/lib/rack/sockjs.rb +173 -0
- data/lib/sockjs.rb +59 -0
- data/lib/sockjs/callbacks.rb +19 -0
- data/lib/sockjs/connection.rb +45 -0
- data/lib/sockjs/delayed-response-body.rb +99 -0
- data/lib/sockjs/duck-punch-rack-mount.rb +12 -0
- data/lib/sockjs/duck-punch-thin-response.rb +15 -0
- data/lib/sockjs/examples/protocol_conformance_test.rb +73 -0
- data/lib/sockjs/faye.rb +18 -0
- data/lib/sockjs/protocol.rb +97 -0
- data/lib/sockjs/servers/request.rb +137 -0
- data/lib/sockjs/servers/response.rb +170 -0
- data/lib/sockjs/session.rb +492 -0
- data/lib/sockjs/transport.rb +357 -0
- data/lib/sockjs/transports/eventsource.rb +30 -0
- data/lib/sockjs/transports/htmlfile.rb +73 -0
- data/lib/sockjs/transports/iframe.rb +68 -0
- data/lib/sockjs/transports/info.rb +48 -0
- data/lib/sockjs/transports/jsonp.rb +84 -0
- data/lib/sockjs/transports/websocket.rb +198 -0
- data/lib/sockjs/transports/welcome_screen.rb +17 -0
- data/lib/sockjs/transports/xhr.rb +75 -0
- data/lib/sockjs/version.rb +13 -0
- data/spec/sockjs/protocol_spec.rb +49 -0
- data/spec/sockjs/session_spec.rb +51 -0
- data/spec/sockjs/transport_spec.rb +73 -0
- data/spec/sockjs/transports/eventsource_spec.rb +56 -0
- data/spec/sockjs/transports/htmlfile_spec.rb +72 -0
- data/spec/sockjs/transports/iframe_spec.rb +66 -0
- data/spec/sockjs/transports/jsonp_spec.rb +252 -0
- data/spec/sockjs/transports/websocket_spec.rb +101 -0
- data/spec/sockjs/transports/welcome_screen_spec.rb +36 -0
- data/spec/sockjs/transports/xhr_spec.rb +314 -0
- data/spec/sockjs/version_spec.rb +18 -0
- data/spec/sockjs_spec.rb +8 -0
- data/spec/spec_helper.rb +121 -0
- data/spec/support/async-test.rb +42 -0
- metadata +154 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env bundle exec rspec
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "spec_helper"
|
5
|
+
require "sockjs/version"
|
6
|
+
|
7
|
+
describe SockJS do
|
8
|
+
it "should define VERSION" do
|
9
|
+
constants = described_class.constants.map(&:to_sym)
|
10
|
+
constants.should include(:GEM_VERSION)
|
11
|
+
SockJS::GEM_VERSION.should be_an_instance_of(String)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should define PROTOCOL_VERSION" do
|
15
|
+
constants = described_class.constants.map(&:to_sym)
|
16
|
+
constants.should include(:PROTOCOL_VERSION)
|
17
|
+
end
|
18
|
+
end
|
data/spec/sockjs_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'support/async-test.rb'
|
4
|
+
require 'support/shared-contexts'
|
5
|
+
require 'stringio'
|
6
|
+
require 'thin'
|
7
|
+
require 'sockjs'
|
8
|
+
require 'sockjs/servers/request'
|
9
|
+
require 'sockjs/servers/response'
|
10
|
+
require 'sockjs/session'
|
11
|
+
|
12
|
+
require 'sockjs/examples/protocol_conformance_test'
|
13
|
+
require 'sockjs/version'
|
14
|
+
|
15
|
+
module TransportSpecMacros
|
16
|
+
def transport_handler_eql(path, method)
|
17
|
+
describe SockJS::Transport do
|
18
|
+
describe "transports[#{path}]" do
|
19
|
+
let :route_set do
|
20
|
+
mock("Route Set")
|
21
|
+
end
|
22
|
+
|
23
|
+
let :connection do
|
24
|
+
mock("Connection")
|
25
|
+
end
|
26
|
+
|
27
|
+
let :options do
|
28
|
+
{}
|
29
|
+
end
|
30
|
+
|
31
|
+
let :path_matcher do
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have a #{described_class} at #{method}" do
|
36
|
+
route_set.should_receive(:add_route).with(instance_of(described_class), hash_including(:path_info, :request_method => method), {})
|
37
|
+
described_class.add_route(route_set, connection, options)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class FakeRequest < SockJS::Request
|
45
|
+
attr_reader :chunks
|
46
|
+
attr_writer :data
|
47
|
+
attr_accessor :path_info, :query_string, :if_none_match, :content_type
|
48
|
+
|
49
|
+
def initialize(env = Hash.new)
|
50
|
+
self.env.merge!(env)
|
51
|
+
@query_string = {}
|
52
|
+
@chunks = []
|
53
|
+
end
|
54
|
+
|
55
|
+
def session_key=(value)
|
56
|
+
@env['rack.routing_args'] ||= {}
|
57
|
+
@env['rack.routing_args'][:session_key] = value
|
58
|
+
end
|
59
|
+
|
60
|
+
def env
|
61
|
+
@env ||= {
|
62
|
+
"async.callback" => Proc.new do |status, headers, body|
|
63
|
+
# This is so we can test it.
|
64
|
+
# Block passed to body.each will be used
|
65
|
+
# as the @body_callback in DelayedResponseBody.
|
66
|
+
body.each do |chunk|
|
67
|
+
next if chunk == "0\r\n\r\n"
|
68
|
+
@chunks << chunk.split("\r\n").last
|
69
|
+
end
|
70
|
+
end,
|
71
|
+
|
72
|
+
"async.close" => EventMachine::DefaultDeferrable.new
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
def session_id
|
77
|
+
"session-id"
|
78
|
+
end
|
79
|
+
|
80
|
+
def origin
|
81
|
+
"*"
|
82
|
+
end
|
83
|
+
|
84
|
+
def fresh?(etag)
|
85
|
+
@if_none_match == etag
|
86
|
+
end
|
87
|
+
|
88
|
+
def data
|
89
|
+
StringIO.new(@data || "")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class FakeSession < SockJS::Session
|
94
|
+
def set_timer
|
95
|
+
end
|
96
|
+
|
97
|
+
def reset_timer
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class SockJS::Response
|
102
|
+
def chunks
|
103
|
+
@request.chunks
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
RSpec.configure do |config|
|
108
|
+
config.backtrace_clean_patterns.delete(/gems/)
|
109
|
+
config.extend(TransportSpecMacros)
|
110
|
+
config.before do
|
111
|
+
class SockJS::Transport
|
112
|
+
def session_class
|
113
|
+
FakeSession
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
config.after do
|
119
|
+
SockJS::no_debug!
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'thin'
|
2
|
+
require 'eventmachine'
|
3
|
+
|
4
|
+
module Thin
|
5
|
+
module Async
|
6
|
+
class Test
|
7
|
+
VERSION = '1.0.0'
|
8
|
+
|
9
|
+
class Callback
|
10
|
+
attr_reader :status, :headers, :body
|
11
|
+
|
12
|
+
def call args
|
13
|
+
@status, @headers, deferred_body = args
|
14
|
+
@body = ""
|
15
|
+
deferred_body.each {|s| @body << s }
|
16
|
+
|
17
|
+
deferred_body.callback { EM.stop }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(app, options={})
|
22
|
+
@app = app
|
23
|
+
end
|
24
|
+
|
25
|
+
def call(env)
|
26
|
+
callback = Callback.new
|
27
|
+
env.merge! 'async.callback' => callback
|
28
|
+
|
29
|
+
result = @app.call(env)
|
30
|
+
|
31
|
+
unless result.first == -1
|
32
|
+
EM.next_tick do
|
33
|
+
EM.stop
|
34
|
+
return result
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
[callback.status, callback.headers, callback.body]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: volt-sockjs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.4.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Judson Lester
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thin
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
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'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faye-websocket
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.7.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.7.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-mount
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.8.3
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.8.3
|
83
|
+
description: |2
|
84
|
+
SockJS is a WebSocket emulation library. It means that you use the WebSocket API, only instead of WebSocket class you instantiate SockJS class. In absence of WebSocket, some of the fallback transports will be used. This code is compatible with SockJS protocol 0.3.4.
|
85
|
+
email: nyarly@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files:
|
89
|
+
- README.textile
|
90
|
+
files:
|
91
|
+
- LICENCE
|
92
|
+
- README.textile
|
93
|
+
- lib/meta-state.rb
|
94
|
+
- lib/rack/sockjs.rb
|
95
|
+
- lib/sockjs.rb
|
96
|
+
- lib/sockjs/callbacks.rb
|
97
|
+
- lib/sockjs/connection.rb
|
98
|
+
- lib/sockjs/delayed-response-body.rb
|
99
|
+
- lib/sockjs/duck-punch-rack-mount.rb
|
100
|
+
- lib/sockjs/duck-punch-thin-response.rb
|
101
|
+
- lib/sockjs/examples/protocol_conformance_test.rb
|
102
|
+
- lib/sockjs/faye.rb
|
103
|
+
- lib/sockjs/protocol.rb
|
104
|
+
- lib/sockjs/servers/request.rb
|
105
|
+
- lib/sockjs/servers/response.rb
|
106
|
+
- lib/sockjs/session.rb
|
107
|
+
- lib/sockjs/transport.rb
|
108
|
+
- lib/sockjs/transports/eventsource.rb
|
109
|
+
- lib/sockjs/transports/htmlfile.rb
|
110
|
+
- lib/sockjs/transports/iframe.rb
|
111
|
+
- lib/sockjs/transports/info.rb
|
112
|
+
- lib/sockjs/transports/jsonp.rb
|
113
|
+
- lib/sockjs/transports/websocket.rb
|
114
|
+
- lib/sockjs/transports/welcome_screen.rb
|
115
|
+
- lib/sockjs/transports/xhr.rb
|
116
|
+
- lib/sockjs/version.rb
|
117
|
+
- spec/sockjs/protocol_spec.rb
|
118
|
+
- spec/sockjs/session_spec.rb
|
119
|
+
- spec/sockjs/transport_spec.rb
|
120
|
+
- spec/sockjs/transports/eventsource_spec.rb
|
121
|
+
- spec/sockjs/transports/htmlfile_spec.rb
|
122
|
+
- spec/sockjs/transports/iframe_spec.rb
|
123
|
+
- spec/sockjs/transports/jsonp_spec.rb
|
124
|
+
- spec/sockjs/transports/websocket_spec.rb
|
125
|
+
- spec/sockjs/transports/welcome_screen_spec.rb
|
126
|
+
- spec/sockjs/transports/xhr_spec.rb
|
127
|
+
- spec/sockjs/version_spec.rb
|
128
|
+
- spec/sockjs_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
- spec/support/async-test.rb
|
131
|
+
homepage: https://github.com/voltrb/sockjs-ruby
|
132
|
+
licenses: []
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '1.9'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project: sockjs
|
150
|
+
rubygems_version: 2.2.2
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Ruby server for SockJS
|
154
|
+
test_files: []
|