websocket 1.0.7 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/CHANGELOG.md +8 -0
  2. data/Gemfile +1 -0
  3. data/README.md +1 -0
  4. data/lib/websocket.rb +15 -4
  5. data/lib/websocket/error.rb +85 -0
  6. data/lib/websocket/exception_handler.rb +36 -0
  7. data/lib/websocket/frame/base.rb +13 -16
  8. data/lib/websocket/frame/data.rb +1 -1
  9. data/lib/websocket/frame/handler/base.rb +6 -2
  10. data/lib/websocket/frame/handler/handler03.rb +49 -55
  11. data/lib/websocket/frame/handler/handler04.rb +1 -3
  12. data/lib/websocket/frame/handler/handler05.rb +2 -6
  13. data/lib/websocket/frame/handler/handler07.rb +5 -7
  14. data/lib/websocket/frame/handler/handler75.rb +15 -19
  15. data/lib/websocket/frame/incoming.rb +2 -1
  16. data/lib/websocket/frame/incoming/client.rb +1 -3
  17. data/lib/websocket/frame/incoming/server.rb +1 -3
  18. data/lib/websocket/frame/outgoing.rb +3 -2
  19. data/lib/websocket/frame/outgoing/client.rb +1 -3
  20. data/lib/websocket/frame/outgoing/server.rb +1 -3
  21. data/lib/websocket/handshake/base.rb +9 -5
  22. data/lib/websocket/handshake/client.rb +13 -12
  23. data/lib/websocket/handshake/handler/base.rb +10 -2
  24. data/lib/websocket/handshake/handler/client.rb +3 -5
  25. data/lib/websocket/handshake/handler/client01.rb +2 -4
  26. data/lib/websocket/handshake/handler/client04.rb +6 -8
  27. data/lib/websocket/handshake/handler/client75.rb +4 -6
  28. data/lib/websocket/handshake/handler/client76.rb +3 -5
  29. data/lib/websocket/handshake/handler/server.rb +1 -3
  30. data/lib/websocket/handshake/handler/server04.rb +7 -5
  31. data/lib/websocket/handshake/handler/server75.rb +3 -5
  32. data/lib/websocket/handshake/handler/server76.rb +9 -11
  33. data/lib/websocket/handshake/server.rb +49 -10
  34. data/lib/websocket/version.rb +1 -1
  35. data/spec/frame/incoming_03_spec.rb +3 -3
  36. data/spec/frame/incoming_04_spec.rb +3 -3
  37. data/spec/frame/incoming_05_spec.rb +3 -3
  38. data/spec/frame/incoming_07_spec.rb +3 -3
  39. data/spec/frame/incoming_75_spec.rb +2 -2
  40. data/spec/handshake/client_04_spec.rb +3 -3
  41. data/spec/handshake/client_76_spec.rb +3 -3
  42. data/spec/spec_helper.rb +1 -0
  43. data/spec/support/all_server_drafts.rb +33 -0
  44. data/spec/support/frames_base.rb +1 -3
  45. data/spec/support/incoming_frames.rb +26 -1
  46. data/spec/support/overwrites.rb +9 -0
  47. data/websocket.gemspec +0 -2
  48. metadata +29 -53
@@ -2,10 +2,8 @@ module WebSocket
2
2
  module Frame
3
3
  class Base
4
4
 
5
- private
6
-
7
5
  def incoming_masking?
8
- masking?
6
+ @handler.masking?
9
7
  end
10
8
 
11
9
  def outgoing_masking?
@@ -16,7 +16,11 @@ shared_examples_for 'valid_incoming_frame' do
16
16
  n.class.should eql(WebSocket::Frame::Incoming), "Should be WebSocket::Frame::Incoming, #{n} received instead"
17
17
  end
18
18
  subject.next.should be_nil
19
- subject.error.should eql(error)
19
+ if error.is_a?(Class)
20
+ subject.error.should eql(error.new.message)
21
+ else
22
+ subject.error.should eql(error)
23
+ end
20
24
  end
21
25
 
22
26
  it "should return valid decoded frame for each specified decoded texts" do
@@ -27,4 +31,25 @@ shared_examples_for 'valid_incoming_frame' do
27
31
  f.to_s.should eql(da)
28
32
  end
29
33
  end
34
+
35
+ context "with raising" do
36
+ before { WebSocket.should_raise = true }
37
+ after { WebSocket.should_raise = false }
38
+
39
+ it "should have specified number of returned frames" do
40
+ expect do
41
+ decoded_text_array.each_with_index do |da, index|
42
+ n = subject.next
43
+ n.should_not be_nil, "Should return frame for #{da}, #{frame_type_array[index]}"
44
+ n.class.should eql(WebSocket::Frame::Incoming), "Should be WebSocket::Frame::Incoming, #{n} received instead"
45
+ end
46
+ subject.next.should be_nil
47
+ if error.is_a?(Class)
48
+ subject.error.should eql(error.new.message)
49
+ else
50
+ subject.error.should eql(error)
51
+ end
52
+ end.to raise_error(error) if error
53
+ end
54
+ end
30
55
  end
@@ -0,0 +1,9 @@
1
+ module WebSocket
2
+
3
+ module Handshake
4
+ class Base
5
+ attr_reader :handler
6
+ end
7
+ end
8
+
9
+ end
data/websocket.gemspec CHANGED
@@ -12,8 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{Universal Ruby library to handle WebSocket protocol}
13
13
  s.description = %q{Universal Ruby library to handle WebSocket protocol}
14
14
 
15
- s.add_development_dependency 'rspec', '~> 2.11'
16
-
17
15
  s.files = `git ls-files`.split("\n")
18
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,47 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: websocket
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 7
10
- version: 1.0.7
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Bernard Potocki
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-01-27 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 21
29
- segments:
30
- - 2
31
- - 11
32
- version: "2.11"
33
- type: :development
34
- version_requirements: *id001
12
+ date: 2013-06-17 00:00:00.000000000 Z
13
+ dependencies: []
35
14
  description: Universal Ruby library to handle WebSocket protocol
36
- email:
15
+ email:
37
16
  - bernard.potocki@imanel.org
38
17
  executables: []
39
-
40
18
  extensions: []
41
-
42
19
  extra_rdoc_files: []
43
-
44
- files:
20
+ files:
45
21
  - .gitignore
46
22
  - .travis.yml
47
23
  - CHANGELOG.md
@@ -49,6 +25,8 @@ files:
49
25
  - README.md
50
26
  - Rakefile
51
27
  - lib/websocket.rb
28
+ - lib/websocket/error.rb
29
+ - lib/websocket/exception_handler.rb
52
30
  - lib/websocket/frame.rb
53
31
  - lib/websocket/frame/base.rb
54
32
  - lib/websocket/frame/data.rb
@@ -107,41 +85,39 @@ files:
107
85
  - spec/support/handshake_requests.rb
108
86
  - spec/support/incoming_frames.rb
109
87
  - spec/support/outgoing_frames.rb
88
+ - spec/support/overwrites.rb
110
89
  - websocket.gemspec
111
90
  homepage: http://github.com/imanel/websocket-ruby
112
91
  licenses: []
113
-
114
92
  post_install_message:
115
93
  rdoc_options: []
116
-
117
- require_paths:
94
+ require_paths:
118
95
  - lib
119
- required_ruby_version: !ruby/object:Gem::Requirement
96
+ required_ruby_version: !ruby/object:Gem::Requirement
120
97
  none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- hash: 3
125
- segments:
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ segments:
126
103
  - 0
127
- version: "0"
128
- required_rubygems_version: !ruby/object:Gem::Requirement
104
+ hash: 2598655559376715147
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
106
  none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- hash: 3
134
- segments:
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ segments:
135
112
  - 0
136
- version: "0"
113
+ hash: 2598655559376715147
137
114
  requirements: []
138
-
139
115
  rubyforge_project:
140
- rubygems_version: 1.8.24
116
+ rubygems_version: 1.8.25
141
117
  signing_key:
142
118
  specification_version: 3
143
119
  summary: Universal Ruby library to handle WebSocket protocol
144
- test_files:
120
+ test_files:
145
121
  - spec/frame/incoming_03_spec.rb
146
122
  - spec/frame/incoming_04_spec.rb
147
123
  - spec/frame/incoming_05_spec.rb
@@ -168,4 +144,4 @@ test_files:
168
144
  - spec/support/handshake_requests.rb
169
145
  - spec/support/incoming_frames.rb
170
146
  - spec/support/outgoing_frames.rb
171
- has_rdoc:
147
+ - spec/support/overwrites.rb