tubesock 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b47058bf07fdf65340f9ee65ee32cdc39a28b5b
4
- data.tar.gz: cb112f9c8bf14fab05f7b100b7b8cb8ff11cd003
3
+ metadata.gz: 4a96bee3c54c81518af3d9105a737f23f78f5b76
4
+ data.tar.gz: 1d96fd26516fd0244f2d9ef625466a96b08008f4
5
5
  SHA512:
6
- metadata.gz: 41b5e67e9984af275cd40f36277f866495fabd0da6fb1b4a7258ef493d1f3b9562e09e1c2e494877a99af36ad0ea7ef4c79e646a6f79279372e419abec06430c
7
- data.tar.gz: 0284696e54e55969f29e6e6ac4350bbda3b5fc0d42ad6f6af35804d6bb85706b593f37c3fe364b5ce55eda0ae654d2535a04f5573d6bc24089139783cfdfe40f
6
+ metadata.gz: 260ad5ab303a82b4aac2c9c4d66a27a5c4f33520d54a03f73368fb2bf2dfff2910fc281577d1b98c58522f5fb9da8fbf49576c15221fe7374fbf5d2bb7c04074
7
+ data.tar.gz: 163b2d57d72292578a13b6e38084390a5c1b1545fce0d45ea3856de790350281fa2c3efe4cd5b558c26776ae27d92bcd307d4b1c65448668618d5201cbfdadf5
@@ -1,3 +1,3 @@
1
1
  class Tubesock
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/tubesock.rb CHANGED
@@ -2,28 +2,35 @@ require "tubesock/version"
2
2
  require "tubesock/hijack" if defined?(Rails)
3
3
 
4
4
  class Tubesock
5
+ class HijackNotAvailable < RuntimeError
6
+ end
7
+
5
8
  def initialize(socket, version)
6
9
  @socket = socket
7
10
  @version = version
8
11
  end
9
12
 
10
13
  def self.hijack(env)
11
- env['rack.hijack'].call
12
- socket = env['rack.hijack_io']
14
+ if env['rack.hijack']
15
+ env['rack.hijack'].call
16
+ socket = env['rack.hijack_io']
13
17
 
14
- handshake = WebSocket::Handshake::Server.new
15
- handshake.headers["sec-websocket-version"] = env["HTTP_SEC_WEBSOCKET_VERSION"]
16
- handshake.headers["sec-websocket-draft"] = env["HTTP_SEC_WEBSOCKET_DRAFT"]
17
- handshake.headers["sec-websocket-key"] = env["HTTP_SEC_WEBSOCKET_KEY"]
18
- handshake.headers["sec-websocket-extensions"] = env["HTTP_SEC_WEBSOCKET_EXTENSIONS"]
19
- handshake.headers["host"] = env["HTTP_HOST"]
20
- handshake.path = env["REQUEST_PATH"]
21
- handshake.query = env["QUERY_STRING"]
22
- handshake.set_version
18
+ handshake = WebSocket::Handshake::Server.new
19
+ handshake.headers["sec-websocket-version"] = env["HTTP_SEC_WEBSOCKET_VERSION"]
20
+ handshake.headers["sec-websocket-draft"] = env["HTTP_SEC_WEBSOCKET_DRAFT"]
21
+ handshake.headers["sec-websocket-key"] = env["HTTP_SEC_WEBSOCKET_KEY"]
22
+ handshake.headers["sec-websocket-extensions"] = env["HTTP_SEC_WEBSOCKET_EXTENSIONS"]
23
+ handshake.headers["host"] = env["HTTP_HOST"]
24
+ handshake.path = env["REQUEST_PATH"]
25
+ handshake.query = env["QUERY_STRING"]
26
+ handshake.set_version
23
27
 
24
- socket.write handshake.to_s
28
+ socket.write handshake.to_s
25
29
 
26
- self.new socket, handshake.version
30
+ self.new socket, handshake.version
31
+ else
32
+ raise Tubesock::HijackNotAvailable
33
+ end
27
34
  end
28
35
 
29
36
  def self.websocket?(env)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tubesock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Gauthier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-12 00:00:00.000000000 Z
11
+ date: 2013-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack