blather 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v0.5.9
2
+ Bugfix(benlangfeld): Failed connections now raise a Blather::Stream::ConnectionFailed exception
3
+ Bugfix(crohr): Blather now supports EventMachine 1.0
4
+
1
5
  v0.5.8
2
6
  Bugfix(benlangfeld): JIDs now maintain case, but still compare case insensitively
3
7
  Bugfix(jmazzi): Development dependencies now resolve correctly on JRuby and Rubinius
data/blather.gemspec CHANGED
@@ -33,9 +33,9 @@ Gem::Specification.new do |s|
33
33
  s.rdoc_options = %w{--charset=UTF-8}
34
34
  s.extra_rdoc_files = %w{LICENSE README.md}
35
35
 
36
- s.add_dependency "eventmachine", ["~> 0.12.6"]
36
+ s.add_dependency "eventmachine", [">= 0.12.6"]
37
37
  s.add_dependency "nokogiri", ["~> 1.4.0"]
38
- s.add_dependency "niceogiri", [">= 0.0.4"]
38
+ s.add_dependency "niceogiri", [">= 0.1.0"]
39
39
  s.add_dependency "activesupport", [">= 3.0.7"]
40
40
 
41
41
  s.add_development_dependency "minitest", ["~> 1.7.1"]
@@ -50,6 +50,7 @@ module Blather
50
50
  class Stream < EventMachine::Connection
51
51
  # Connection not found
52
52
  class NoConnection < RuntimeError; end
53
+ class ConnectionFailed < RuntimeError; end
53
54
 
54
55
  # @private
55
56
  STREAM_NS = 'http://etherx.jabber.org/streams'
@@ -143,6 +144,7 @@ module Blather
143
144
  # this kicks off the starttls/authorize/bind process
144
145
  # @private
145
146
  def connection_completed
147
+ @connected = true
146
148
  # @keepalive = EM::PeriodicTimer.new(60) { send_data ' ' }
147
149
  start
148
150
  end
@@ -178,13 +180,14 @@ module Blather
178
180
  # Called by EM after the connection has started
179
181
  # @private
180
182
  def post_init
181
- @connected = true
183
+ @inited = true
182
184
  end
183
185
 
184
186
  # Called by EM when the connection is closed
185
187
  # @private
186
188
  def unbind
187
- raise NoConnection unless @connected
189
+ raise NoConnection unless @inited
190
+ raise ConnectionFailed unless @connected
188
191
 
189
192
  # @keepalive.cancel
190
193
  @state = :stopped
@@ -1,4 +1,4 @@
1
1
  module Blather
2
2
  # Blather version number
3
- VERSION = '0.5.8'
3
+ VERSION = '0.5.9'
4
4
  end
@@ -16,15 +16,17 @@ describe Blather::Stream::Client do
16
16
  @client.stubs(:post_init) unless @client.respond_to?(:post_init)
17
17
  @client.stubs(:jid=) unless @client.respond_to?(:jid=)
18
18
 
19
+ port = 50000 - rand(1000)
20
+
19
21
  MockServer.any_instance.expects(:receive_data).send(*(times ? [:times, times] : [:at_least, 1])).with &block
20
22
  EventMachine::run {
21
23
  EM.add_timer(0.5) { EM.stop if EM.reactor_running? }
22
24
 
23
25
  # Mocked server
24
- EventMachine::start_server '127.0.0.1', 12345, ServerMock
26
+ EventMachine::start_server '127.0.0.1', port, ServerMock
25
27
 
26
28
  # Blather::Stream connection
27
- EM.connect('127.0.0.1', 12345, Blather::Stream::Client, @client, @jid || Blather::JID.new('n@d/r'), 'pass') { |c| @stream = c }
29
+ EM.connect('127.0.0.1', port, Blather::Stream::Client, @client, @jid || Blather::JID.new('n@d/r'), 'pass') { |c| @stream = c }
28
30
  }
29
31
  end
30
32
 
@@ -111,6 +113,16 @@ describe Blather::Stream::Client do
111
113
  Blather::Stream::Client.start client, 'n@d/r', 'pass'
112
114
  end
113
115
 
116
+ it 'raises a NoConnection exception if the connection is unbound before it can be completed' do
117
+ proc do
118
+ EventMachine::run {
119
+ EM.add_timer(0.5) { EM.stop if EM.reactor_running? }
120
+
121
+ Blather::Stream::Client.start @client, @jid || Blather::JID.new('n@d/r'), 'pass', '127.0.0.1', 50000 - rand(1000)
122
+ }
123
+ end.must_raise Blather::Stream::ConnectionFailed
124
+ end
125
+
114
126
  it 'starts the stream once the connection is complete' do
115
127
  mocked_server(1) { |val, _| EM.stop; val.must_match(/stream:stream/) }
116
128
  end
@@ -14,13 +14,15 @@ describe Blather::Stream::Component do
14
14
  @client.stubs(:unbind) unless @client.respond_to?(:unbind)
15
15
  @client.stubs(:jid=) unless @client.respond_to?(:jid=)
16
16
 
17
+ port = 50000 - rand(1000)
18
+
17
19
  MockServer.any_instance.expects(:receive_data).send(*(times ? [:times, times] : [:at_least, 1])).with &block
18
20
  EventMachine::run {
19
21
  # Mocked server
20
- EventMachine::start_server '127.0.0.1', 12345, ServerMock
22
+ EventMachine::start_server '127.0.0.1', port, ServerMock
21
23
 
22
24
  # Blather::Stream connection
23
- EM.connect('127.0.0.1', 12345, Blather::Stream::Component, @client, @jid || 'comp.id', 'secret') { |c| @stream = c }
25
+ EM.connect('127.0.0.1', port, Blather::Stream::Component, @client, @jid || 'comp.id', 'secret') { |c| @stream = c }
24
26
  }
25
27
  end
26
28
 
@@ -55,6 +57,17 @@ describe Blather::Stream::Component do
55
57
  end
56
58
  end
57
59
 
60
+ it 'raises a NoConnection exception if the connection is unbound before it can be completed' do
61
+ @client = mock
62
+ proc do
63
+ EventMachine::run {
64
+ EM.add_timer(0.5) { EM.stop if EM.reactor_running? }
65
+
66
+ Blather::Stream::Component.start @client, @jid || Blather::JID.new('n@d/r'), 'pass', '127.0.0.1', 50000 - rand(1000)
67
+ }
68
+ end.must_raise Blather::Stream::ConnectionFailed
69
+ end
70
+
58
71
  it 'starts the stream once the connection is complete' do
59
72
  mocked_server(1) { |val, _| EM.stop; val.must_match(/stream:stream/) }
60
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,23 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-11 00:00:00.000000000 -07:00
13
- default_executable:
12
+ date: 2011-11-24 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: eventmachine
17
- requirement: &2156628380 !ruby/object:Gem::Requirement
16
+ requirement: &2151820120 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
- - - ~>
19
+ - - ! '>='
21
20
  - !ruby/object:Gem::Version
22
21
  version: 0.12.6
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2156628380
24
+ version_requirements: *2151820120
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: nokogiri
28
- requirement: &2156627780 !ruby/object:Gem::Requirement
27
+ requirement: &2151817400 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ~>
@@ -33,21 +32,21 @@ dependencies:
33
32
  version: 1.4.0
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *2156627780
35
+ version_requirements: *2151817400
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: niceogiri
39
- requirement: &2156627280 !ruby/object:Gem::Requirement
38
+ requirement: &2151816340 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ! '>='
43
42
  - !ruby/object:Gem::Version
44
- version: 0.0.4
43
+ version: 0.1.0
45
44
  type: :runtime
46
45
  prerelease: false
47
- version_requirements: *2156627280
46
+ version_requirements: *2151816340
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: activesupport
50
- requirement: &2156626720 !ruby/object:Gem::Requirement
49
+ requirement: &2151814180 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ! '>='
@@ -55,10 +54,10 @@ dependencies:
55
54
  version: 3.0.7
56
55
  type: :runtime
57
56
  prerelease: false
58
- version_requirements: *2156626720
57
+ version_requirements: *2151814180
59
58
  - !ruby/object:Gem::Dependency
60
59
  name: minitest
61
- requirement: &2156626180 !ruby/object:Gem::Requirement
60
+ requirement: &2151826240 !ruby/object:Gem::Requirement
62
61
  none: false
63
62
  requirements:
64
63
  - - ~>
@@ -66,10 +65,10 @@ dependencies:
66
65
  version: 1.7.1
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *2156626180
68
+ version_requirements: *2151826240
70
69
  - !ruby/object:Gem::Dependency
71
70
  name: mocha
72
- requirement: &2156625680 !ruby/object:Gem::Requirement
71
+ requirement: &2151823960 !ruby/object:Gem::Requirement
73
72
  none: false
74
73
  requirements:
75
74
  - - ~>
@@ -77,10 +76,10 @@ dependencies:
77
76
  version: 0.9.12
78
77
  type: :development
79
78
  prerelease: false
80
- version_requirements: *2156625680
79
+ version_requirements: *2151823960
81
80
  - !ruby/object:Gem::Dependency
82
81
  name: bundler
83
- requirement: &2156625120 !ruby/object:Gem::Requirement
82
+ requirement: &2151822020 !ruby/object:Gem::Requirement
84
83
  none: false
85
84
  requirements:
86
85
  - - ~>
@@ -88,10 +87,10 @@ dependencies:
88
87
  version: 1.0.0
89
88
  type: :development
90
89
  prerelease: false
91
- version_requirements: *2156625120
90
+ version_requirements: *2151822020
92
91
  - !ruby/object:Gem::Dependency
93
92
  name: rcov
94
- requirement: &2156624600 !ruby/object:Gem::Requirement
93
+ requirement: &2151832740 !ruby/object:Gem::Requirement
95
94
  none: false
96
95
  requirements:
97
96
  - - ~>
@@ -99,10 +98,10 @@ dependencies:
99
98
  version: 0.9.9
100
99
  type: :development
101
100
  prerelease: false
102
- version_requirements: *2156624600
101
+ version_requirements: *2151832740
103
102
  - !ruby/object:Gem::Dependency
104
103
  name: yard
105
- requirement: &2156624040 !ruby/object:Gem::Requirement
104
+ requirement: &2151843420 !ruby/object:Gem::Requirement
106
105
  none: false
107
106
  requirements:
108
107
  - - ~>
@@ -110,10 +109,10 @@ dependencies:
110
109
  version: 0.6.1
111
110
  type: :development
112
111
  prerelease: false
113
- version_requirements: *2156624040
112
+ version_requirements: *2151843420
114
113
  - !ruby/object:Gem::Dependency
115
114
  name: rake
116
- requirement: &2156623580 !ruby/object:Gem::Requirement
115
+ requirement: &2151848800 !ruby/object:Gem::Requirement
117
116
  none: false
118
117
  requirements:
119
118
  - - ! '>='
@@ -121,10 +120,10 @@ dependencies:
121
120
  version: '0'
122
121
  type: :development
123
122
  prerelease: false
124
- version_requirements: *2156623580
123
+ version_requirements: *2151848800
125
124
  - !ruby/object:Gem::Dependency
126
125
  name: guard-minitest
127
- requirement: &2156623080 !ruby/object:Gem::Requirement
126
+ requirement: &2151861200 !ruby/object:Gem::Requirement
128
127
  none: false
129
128
  requirements:
130
129
  - - ! '>='
@@ -132,10 +131,10 @@ dependencies:
132
131
  version: '0'
133
132
  type: :development
134
133
  prerelease: false
135
- version_requirements: *2156623080
134
+ version_requirements: *2151861200
136
135
  - !ruby/object:Gem::Dependency
137
136
  name: bluecloth
138
- requirement: &2156622540 !ruby/object:Gem::Requirement
137
+ requirement: &2151857080 !ruby/object:Gem::Requirement
139
138
  none: false
140
139
  requirements:
141
140
  - - ! '>='
@@ -143,10 +142,10 @@ dependencies:
143
142
  version: '0'
144
143
  type: :development
145
144
  prerelease: false
146
- version_requirements: *2156622540
145
+ version_requirements: *2151857080
147
146
  - !ruby/object:Gem::Dependency
148
147
  name: growl_notify
149
- requirement: &2156621940 !ruby/object:Gem::Requirement
148
+ requirement: &2151869860 !ruby/object:Gem::Requirement
150
149
  none: false
151
150
  requirements:
152
151
  - - ! '>='
@@ -154,10 +153,10 @@ dependencies:
154
153
  version: '0'
155
154
  type: :development
156
155
  prerelease: false
157
- version_requirements: *2156621940
156
+ version_requirements: *2151869860
158
157
  - !ruby/object:Gem::Dependency
159
158
  name: rb-fsevent
160
- requirement: &2156621480 !ruby/object:Gem::Requirement
159
+ requirement: &2151865360 !ruby/object:Gem::Requirement
161
160
  none: false
162
161
  requirements:
163
162
  - - ! '>='
@@ -165,7 +164,7 @@ dependencies:
165
164
  version: '0'
166
165
  type: :development
167
166
  prerelease: false
168
- version_requirements: *2156621480
167
+ version_requirements: *2151865360
169
168
  description: An XMPP DSL for Ruby written on top of EventMachine and Nokogiri
170
169
  email: sprsquish@gmail.com
171
170
  executables: []
@@ -313,7 +312,6 @@ files:
313
312
  - yard/templates/default/class/html/handlers.erb
314
313
  - yard/templates/default/class/setup.rb
315
314
  - yard/templates/default/class/text/handlers.erb
316
- has_rdoc: true
317
315
  homepage: http://github.com/sprsquish/blather
318
316
  licenses: []
319
317
  post_install_message:
@@ -335,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
333
  version: '0'
336
334
  requirements: []
337
335
  rubyforge_project:
338
- rubygems_version: 1.6.2
336
+ rubygems_version: 1.8.10
339
337
  signing_key:
340
338
  specification_version: 3
341
339
  summary: Simpler XMPP built for speed
@@ -390,3 +388,4 @@ test_files:
390
388
  - spec/blather/xmpp_node_spec.rb
391
389
  - spec/fixtures/pubsub.rb
392
390
  - spec/spec_helper.rb
391
+ has_rdoc: