blather 0.4.16 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
- data/CHANGELOG +12 -5
- data/README.md +1 -1
- data/Rakefile +1 -3
- data/blather.gemspec +11 -24
- data/examples/echo.rb +1 -0
- data/examples/execute.rb +1 -0
- data/examples/ping_pong.rb +1 -0
- data/examples/print_hierarchy.rb +1 -0
- data/examples/rosterprint.rb +1 -0
- data/examples/stream_only.rb +1 -0
- data/examples/xmpp4r/echo.rb +1 -0
- data/lib/blather.rb +5 -1
- data/lib/blather/client/client.rb +29 -154
- data/lib/blather/client/dsl.rb +9 -3
- data/lib/blather/client/dsl/pubsub.rb +2 -0
- data/lib/blather/core_ext/eventmachine.rb +4 -1
- data/lib/blather/core_ext/ipaddr.rb +2 -1
- data/lib/blather/core_ext/nokogiri.rb +3 -1
- data/lib/blather/errors/sasl_error.rb +1 -0
- data/lib/blather/errors/stanza_error.rb +3 -1
- data/lib/blather/errors/stream_error.rb +1 -0
- data/lib/blather/file_transfer.rb +4 -1
- data/lib/blather/file_transfer/s5b.rb +3 -4
- data/lib/blather/jid.rb +2 -0
- data/lib/blather/roster_item.rb +13 -3
- data/lib/blather/stanza.rb +11 -3
- data/lib/blather/stanza/disco/capabilities.rb +161 -0
- data/lib/blather/stanza/disco/disco_info.rb +3 -1
- data/lib/blather/stanza/disco/disco_items.rb +0 -1
- data/lib/blather/stanza/iq.rb +8 -2
- data/lib/blather/stanza/iq/command.rb +18 -3
- data/lib/blather/stanza/iq/ibb.rb +6 -3
- data/lib/blather/stanza/iq/s5b.rb +6 -3
- data/lib/blather/stanza/iq/si.rb +6 -1
- data/lib/blather/stanza/iq/vcard.rb +3 -1
- data/lib/blather/stanza/message.rb +5 -0
- data/lib/blather/stanza/presence.rb +1 -0
- data/lib/blather/stanza/presence/c.rb +1 -0
- data/lib/blather/stanza/presence/status.rb +1 -0
- data/lib/blather/stanza/pubsub/event.rb +2 -4
- data/lib/blather/stanza/pubsub/subscription.rb +1 -0
- data/lib/blather/stanza/x.rb +8 -0
- data/lib/blather/stream.rb +2 -0
- data/lib/blather/stream/client.rb +1 -0
- data/lib/blather/stream/component.rb +1 -0
- data/lib/blather/stream/features.rb +4 -3
- data/lib/blather/stream/features/resource.rb +4 -3
- data/lib/blather/stream/features/sasl.rb +9 -6
- data/lib/blather/stream/features/session.rb +5 -4
- data/lib/blather/stream/features/tls.rb +4 -3
- data/lib/blather/stream/parser.rb +4 -5
- data/lib/blather/version.rb +2 -1
- data/lib/blather/xmpp_node.rb +9 -0
- data/spec/blather/client/client_spec.rb +14 -1
- data/spec/blather/stanza/iq_spec.rb +16 -0
- data/spec/blather/stanza/presence_spec.rb +1 -1
- data/spec/blather/stanza_spec.rb +18 -0
- data/spec/blather/stream/client_spec.rb +2 -2
- metadata +52 -35
- data/lib/blather/core_ext/active_support.rb +0 -45
- data/lib/blather/core_ext/active_support/inheritable_attributes.rb +0 -117
@@ -1,7 +1,8 @@
|
|
1
|
-
module Blather
|
2
|
-
class Stream
|
1
|
+
module Blather
|
2
|
+
class Stream
|
3
3
|
|
4
|
-
|
4
|
+
# @private
|
5
|
+
class Session < Features
|
5
6
|
SESSION_NS = 'urn:ietf:params:xml:ns:xmpp-session'.freeze
|
6
7
|
register SESSION_NS
|
7
8
|
|
@@ -22,7 +23,7 @@ class Stream # :nodoc:
|
|
22
23
|
private
|
23
24
|
def check_response
|
24
25
|
if @node[:type] == 'result'
|
25
|
-
succeed!
|
26
|
+
succeed!
|
26
27
|
else
|
27
28
|
fail!(StanzaError.import(@node))
|
28
29
|
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
1
|
+
module Blather
|
2
|
+
class Stream
|
2
3
|
|
3
|
-
|
4
|
-
class
|
5
|
-
|
6
|
-
class Parser < Nokogiri::XML::SAX::Document # :nodoc:
|
4
|
+
# @private
|
5
|
+
class Parser < Nokogiri::XML::SAX::Document
|
7
6
|
NS_TO_IGNORE = %w[jabber:client jabber:component:accept]
|
8
7
|
|
9
8
|
@@debug = false
|
data/lib/blather/version.rb
CHANGED
data/lib/blather/xmpp_node.rb
CHANGED
@@ -210,14 +210,23 @@ module Blather
|
|
210
210
|
self
|
211
211
|
end
|
212
212
|
|
213
|
+
# The node as XML
|
214
|
+
#
|
215
|
+
# @return [String] XML representation of the node
|
213
216
|
def inspect
|
214
217
|
self.to_xml
|
215
218
|
end
|
216
219
|
|
220
|
+
# Check that a set of fields are equal between nodes
|
221
|
+
#
|
222
|
+
# @param [XMPPNode] other the other node to compare against
|
223
|
+
# @param [*#to_s] fields the set of fields to compare
|
224
|
+
# @return [Fixnum<-1,0,1>]
|
217
225
|
def eql?(o, *fields)
|
218
226
|
o.is_a?(self.class) && fields.all? { |f| self.__send__(f) == o.__send__(f) }
|
219
227
|
end
|
220
228
|
|
229
|
+
# @private
|
221
230
|
def ==(o)
|
222
231
|
eql?(o)
|
223
232
|
end
|
@@ -28,7 +28,7 @@ describe Blather::Client do
|
|
28
28
|
|
29
29
|
it 'should have a caps handler' do
|
30
30
|
@client.must_respond_to :caps
|
31
|
-
@client.caps.must_be_kind_of Blather::
|
31
|
+
@client.caps.must_be_kind_of Blather::Stanza::Capabilities
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'can be setup' do
|
@@ -61,6 +61,19 @@ describe Blather::Client do
|
|
61
61
|
@client.run
|
62
62
|
end
|
63
63
|
|
64
|
+
it 'knows if it is disconnected' do
|
65
|
+
@client.must_respond_to :connected?
|
66
|
+
@client.connected?.must_equal false
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'knows if it is connected' do
|
70
|
+
stream = mock()
|
71
|
+
stream.expects(:stopped?).returns false
|
72
|
+
@client.setup('me.com', 'secret')
|
73
|
+
@client.post_init stream, Blather::JID.new('me.com')
|
74
|
+
@client.connected?.must_equal true
|
75
|
+
end
|
76
|
+
|
64
77
|
it 'writes to the connection the closes when #close is called' do
|
65
78
|
stream = mock()
|
66
79
|
stream.expects(:close_connection_after_writing)
|
@@ -42,4 +42,20 @@ describe Blather::Stanza::Iq do
|
|
42
42
|
Blather::Stanza::Iq.new.must_respond_to :"#{valid_type}?"
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
it 'removes the body when replying' do
|
47
|
+
iq = Blather::Stanza::Iq.new :get, 'me@example.com'
|
48
|
+
iq.from = 'them@example.com'
|
49
|
+
iq << Blather::XMPPNode.new('query', iq.document)
|
50
|
+
r = iq.reply
|
51
|
+
r.children.empty?.must_equal true
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'does not remove the body when replying if we ask to keep it' do
|
55
|
+
iq = Blather::Stanza::Iq.new :get, 'me@example.com'
|
56
|
+
iq.from = 'them@example.com'
|
57
|
+
iq << Blather::XMPPNode.new('query', iq.document)
|
58
|
+
r = iq.reply :remove_children => false
|
59
|
+
r.children.empty?.must_equal false
|
60
|
+
end
|
45
61
|
end
|
@@ -56,7 +56,7 @@ describe Blather::Stanza::Presence do
|
|
56
56
|
s.type.must_equal :subscribe
|
57
57
|
end
|
58
58
|
|
59
|
-
it 'creates a Presence object when importing a node with type equal to something
|
59
|
+
it 'creates a Presence object when importing a node with type equal to something unknown' do
|
60
60
|
n = Blather::XMPPNode.new
|
61
61
|
n[:type] = :foo
|
62
62
|
s = Blather::Stanza::Presence.import(n)
|
data/spec/blather/stanza_spec.rb
CHANGED
@@ -62,6 +62,24 @@ describe Blather::Stanza do
|
|
62
62
|
r.to.must_equal f
|
63
63
|
end
|
64
64
|
|
65
|
+
it 'does not remove the body when replying' do
|
66
|
+
s = Blather::Stanza.new('message')
|
67
|
+
s.from = f = Blather::JID.new('n@d/r')
|
68
|
+
s.to = t = Blather::JID.new('d@n/r')
|
69
|
+
s << Blather::XMPPNode.new('query', s.document)
|
70
|
+
r = s.reply
|
71
|
+
r.children.empty?.must_equal false
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'removes the body when replying if we ask to remove it' do
|
75
|
+
s = Blather::Stanza.new('message')
|
76
|
+
s.from = f = Blather::JID.new('n@d/r')
|
77
|
+
s.to = t = Blather::JID.new('d@n/r')
|
78
|
+
s << Blather::XMPPNode.new('query', s.document)
|
79
|
+
r = s.reply :remove_children => true
|
80
|
+
r.children.empty?.must_equal true
|
81
|
+
end
|
82
|
+
|
65
83
|
it 'provides "attr_accessor" for id' do
|
66
84
|
s = Blather::Stanza.new('message')
|
67
85
|
s.id.must_be_nil
|
@@ -666,7 +666,7 @@ describe Blather::Stream::Client do
|
|
666
666
|
end
|
667
667
|
end
|
668
668
|
|
669
|
-
it 'fails when an
|
669
|
+
it 'fails when an unknown node comes through during SASL negotiation' do
|
670
670
|
@client = mock()
|
671
671
|
@client.expects(:receive_data).with do |n|
|
672
672
|
n.must_be_instance_of Blather::UnknownResponse
|
@@ -827,7 +827,7 @@ describe Blather::Stream::Client do
|
|
827
827
|
end
|
828
828
|
end
|
829
829
|
|
830
|
-
it 'will return an error if an
|
830
|
+
it 'will return an error if an unknown node comes through during resouce binding' do
|
831
831
|
state = nil
|
832
832
|
@client = mock()
|
833
833
|
@client.expects(:receive_data).with do |n|
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Jeff Smick
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-09-02 00:00:00
|
17
|
+
date: 2010-09-02 00:00:00 +01:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ~>
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 35
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
- 12
|
@@ -40,9 +38,8 @@ dependencies:
|
|
40
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
43
|
-
- -
|
41
|
+
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 7
|
46
43
|
segments:
|
47
44
|
- 1
|
48
45
|
- 4
|
@@ -54,112 +51,135 @@ dependencies:
|
|
54
51
|
name: minitest
|
55
52
|
prerelease: false
|
56
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 1
|
60
|
+
- 7
|
61
|
+
- 1
|
62
|
+
version: 1.7.1
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: activesupport
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 3
|
75
|
+
- 0
|
76
|
+
- 7
|
77
|
+
version: 3.0.7
|
78
|
+
type: :runtime
|
79
|
+
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: minitest
|
82
|
+
prerelease: false
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
57
84
|
none: false
|
58
85
|
requirements:
|
59
86
|
- - ~>
|
60
87
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 9
|
62
88
|
segments:
|
63
89
|
- 1
|
64
90
|
- 7
|
65
91
|
- 1
|
66
92
|
version: 1.7.1
|
67
93
|
type: :development
|
68
|
-
version_requirements: *
|
94
|
+
version_requirements: *id005
|
69
95
|
- !ruby/object:Gem::Dependency
|
70
96
|
name: mocha
|
71
97
|
prerelease: false
|
72
|
-
requirement: &
|
98
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
73
99
|
none: false
|
74
100
|
requirements:
|
75
101
|
- - ~>
|
76
102
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 35
|
78
103
|
segments:
|
79
104
|
- 0
|
80
105
|
- 9
|
81
106
|
- 12
|
82
107
|
version: 0.9.12
|
83
108
|
type: :development
|
84
|
-
version_requirements: *
|
109
|
+
version_requirements: *id006
|
85
110
|
- !ruby/object:Gem::Dependency
|
86
111
|
name: bundler
|
87
112
|
prerelease: false
|
88
|
-
requirement: &
|
113
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
89
114
|
none: false
|
90
115
|
requirements:
|
91
116
|
- - ~>
|
92
117
|
- !ruby/object:Gem::Version
|
93
|
-
hash: 23
|
94
118
|
segments:
|
95
119
|
- 1
|
96
120
|
- 0
|
97
121
|
- 0
|
98
122
|
version: 1.0.0
|
99
123
|
type: :development
|
100
|
-
version_requirements: *
|
124
|
+
version_requirements: *id007
|
101
125
|
- !ruby/object:Gem::Dependency
|
102
126
|
name: rcov
|
103
127
|
prerelease: false
|
104
|
-
requirement: &
|
128
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
105
129
|
none: false
|
106
130
|
requirements:
|
107
131
|
- - ~>
|
108
132
|
- !ruby/object:Gem::Version
|
109
|
-
hash: 41
|
110
133
|
segments:
|
111
134
|
- 0
|
112
135
|
- 9
|
113
136
|
- 9
|
114
137
|
version: 0.9.9
|
115
138
|
type: :development
|
116
|
-
version_requirements: *
|
139
|
+
version_requirements: *id008
|
117
140
|
- !ruby/object:Gem::Dependency
|
118
141
|
name: yard
|
119
142
|
prerelease: false
|
120
|
-
requirement: &
|
143
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
121
144
|
none: false
|
122
145
|
requirements:
|
123
146
|
- - ~>
|
124
147
|
- !ruby/object:Gem::Version
|
125
|
-
hash: 5
|
126
148
|
segments:
|
127
149
|
- 0
|
128
150
|
- 6
|
129
151
|
- 1
|
130
152
|
version: 0.6.1
|
131
153
|
type: :development
|
132
|
-
version_requirements: *
|
154
|
+
version_requirements: *id009
|
133
155
|
- !ruby/object:Gem::Dependency
|
134
156
|
name: bluecloth
|
135
157
|
prerelease: false
|
136
|
-
requirement: &
|
158
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
137
159
|
none: false
|
138
160
|
requirements:
|
139
161
|
- - ~>
|
140
162
|
- !ruby/object:Gem::Version
|
141
|
-
hash: 11
|
142
163
|
segments:
|
143
164
|
- 2
|
144
165
|
- 1
|
145
166
|
- 0
|
146
167
|
version: 2.1.0
|
147
168
|
type: :development
|
148
|
-
version_requirements: *
|
169
|
+
version_requirements: *id010
|
149
170
|
- !ruby/object:Gem::Dependency
|
150
171
|
name: rake
|
151
172
|
prerelease: false
|
152
|
-
requirement: &
|
173
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
153
174
|
none: false
|
154
175
|
requirements:
|
155
176
|
- - ">="
|
156
177
|
- !ruby/object:Gem::Version
|
157
|
-
hash: 3
|
158
178
|
segments:
|
159
179
|
- 0
|
160
180
|
version: "0"
|
161
181
|
type: :development
|
162
|
-
version_requirements: *
|
182
|
+
version_requirements: *id011
|
163
183
|
description: An XMPP DSL for Ruby written on top of EventMachine and Nokogiri
|
164
184
|
email: sprsquish@gmail.com
|
165
185
|
executables: []
|
@@ -171,10 +191,10 @@ extra_rdoc_files:
|
|
171
191
|
- README.md
|
172
192
|
files:
|
173
193
|
- .autotest
|
194
|
+
- .gemtest
|
174
195
|
- .gitignore
|
175
196
|
- CHANGELOG
|
176
197
|
- Gemfile
|
177
|
-
- Gemfile.lock
|
178
198
|
- LICENSE
|
179
199
|
- README.md
|
180
200
|
- Rakefile
|
@@ -193,8 +213,6 @@ files:
|
|
193
213
|
- lib/blather/client/client.rb
|
194
214
|
- lib/blather/client/dsl.rb
|
195
215
|
- lib/blather/client/dsl/pubsub.rb
|
196
|
-
- lib/blather/core_ext/active_support.rb
|
197
|
-
- lib/blather/core_ext/active_support/inheritable_attributes.rb
|
198
216
|
- lib/blather/core_ext/eventmachine.rb
|
199
217
|
- lib/blather/core_ext/ipaddr.rb
|
200
218
|
- lib/blather/core_ext/nokogiri.rb
|
@@ -210,6 +228,7 @@ files:
|
|
210
228
|
- lib/blather/roster_item.rb
|
211
229
|
- lib/blather/stanza.rb
|
212
230
|
- lib/blather/stanza/disco.rb
|
231
|
+
- lib/blather/stanza/disco/capabilities.rb
|
213
232
|
- lib/blather/stanza/disco/disco_info.rb
|
214
233
|
- lib/blather/stanza/disco/disco_items.rb
|
215
234
|
- lib/blather/stanza/iq.rb
|
@@ -318,7 +337,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
318
337
|
requirements:
|
319
338
|
- - ">="
|
320
339
|
- !ruby/object:Gem::Version
|
321
|
-
hash: 3
|
322
340
|
segments:
|
323
341
|
- 0
|
324
342
|
version: "0"
|
@@ -327,14 +345,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
327
345
|
requirements:
|
328
346
|
- - ">="
|
329
347
|
- !ruby/object:Gem::Version
|
330
|
-
hash: 3
|
331
348
|
segments:
|
332
349
|
- 0
|
333
350
|
version: "0"
|
334
351
|
requirements: []
|
335
352
|
|
336
353
|
rubyforge_project:
|
337
|
-
rubygems_version: 1.
|
354
|
+
rubygems_version: 1.3.7
|
338
355
|
signing_key:
|
339
356
|
specification_version: 3
|
340
357
|
summary: Simpler XMPP built for speed
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'active_support', 'inheritable_attributes')
|
2
|
-
|
3
|
-
class Object # @private
|
4
|
-
def duplicable?; true; end
|
5
|
-
def blank?; respond_to?(:empty?) ? empty? : !self; end
|
6
|
-
def present?; !blank?; end
|
7
|
-
end
|
8
|
-
|
9
|
-
class Array # @private
|
10
|
-
alias_method :blank?, :empty?
|
11
|
-
def extract_options!; last.is_a?(::Hash) ? pop : {}; end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Hash # @private
|
15
|
-
alias_method :blank?, :empty?
|
16
|
-
end
|
17
|
-
|
18
|
-
class String # @private
|
19
|
-
def blank?; self !~ /\S/; end
|
20
|
-
end
|
21
|
-
|
22
|
-
class NilClass # @private
|
23
|
-
def duplicable?; false; end
|
24
|
-
def blank?; true; end
|
25
|
-
end
|
26
|
-
|
27
|
-
class FalseClass # @private
|
28
|
-
def duplicable?; false; end
|
29
|
-
def blank?; true; end
|
30
|
-
end
|
31
|
-
|
32
|
-
class TrueClass # @private
|
33
|
-
def duplicable?; false; end
|
34
|
-
def blank?; false; end
|
35
|
-
end
|
36
|
-
|
37
|
-
class Symbol # @private
|
38
|
-
def duplicable?; false; end
|
39
|
-
def to_proc; Proc.new { |*args| args.shift.__send__(self, *args) }; end
|
40
|
-
end
|
41
|
-
|
42
|
-
class Numeric # @private
|
43
|
-
def duplicable?; false; end
|
44
|
-
def blank?; false; end
|
45
|
-
end
|