skinny 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/skinny.rb +12 -4
  2. metadata +31 -11
data/lib/skinny.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'base64'
1
2
  require 'eventmachine'
2
3
  require 'digest/md5'
3
4
  require 'thin'
@@ -180,7 +181,7 @@ module Skinny
180
181
  elsif hixie_76?
181
182
  Digest::MD5.digest(challenge)
182
183
  else
183
- ActiveSupport::Base64.encode64(Digest::SHA1.digest(challenge)).strip
184
+ Base64.encode64(Digest::SHA1.digest(challenge)).strip
184
185
  end
185
186
  end
186
187
 
@@ -420,13 +421,20 @@ module Skinny
420
421
  end
421
422
  end
422
423
 
424
+ CONNECTION = 'HTTP_CONNECTION'.freeze
425
+ UPGRADE = 'HTTP_UPGRADE'.freeze
426
+ SKINNY_WEBSOCKET = 'skinny.websocket'.freeze
427
+
428
+ UPGRADE_REGEXP = /\bupgrade\b/i.freeze
429
+ WEBSOCKET_REGEXP = /\bwebsocket\b/i.freeze
430
+
423
431
  module Helpers
424
432
  def websocket?
425
- env['HTTP_CONNECTION'].downcase == 'upgrade' && env['HTTP_UPGRADE'].downcase == 'websocket'
433
+ env[CONNECTION] =~ UPGRADE_REGEXP && env[UPGRADE] =~ WEBSOCKET_REGEXP
426
434
  end
427
435
 
428
436
  def websocket options={}, &block
429
- env['skinny.websocket'] ||= begin
437
+ env[SKINNY_WEBSOCKET] ||= begin
430
438
  raise RuntimerError, "Not a WebSocket request" unless websocket?
431
439
  options[:on_message] = block if block_given?
432
440
  Websocket.from_env(env, options)
@@ -437,4 +445,4 @@ module Skinny
437
445
  websocket(options, &block).start!
438
446
  end
439
447
  end
440
- end
448
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skinny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2010-11-01 00:00:00.000000000Z
12
+ date: 2010-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &70337454861360 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0.12'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70337454861360
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.12'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: thin
27
- requirement: &70337454860420 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '1.2'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70337454860420
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.2'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rake
38
- requirement: &70337454859940 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70337454859940
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rdoc
49
- requirement: &70337454859320 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70337454859320
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  description: Simple, upgradable WebSockets for Thin.
59
79
  email: sj26@sj26.com
60
80
  executables: []
@@ -86,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
106
  version: '0'
87
107
  requirements: []
88
108
  rubyforge_project:
89
- rubygems_version: 1.8.7
109
+ rubygems_version: 1.8.23
90
110
  signing_key:
91
111
  specification_version: 3
92
112
  summary: Thin WebSockets