gmcmillan-xmpp4r 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +91 -0
  3. data/COPYING +340 -0
  4. data/LICENSE +59 -0
  5. data/README.rdoc +122 -0
  6. data/README_ruby19.txt +43 -0
  7. data/Rakefile +258 -0
  8. data/data/doc/xmpp4r/examples/advanced/adventure/README +56 -0
  9. data/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +23 -0
  10. data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +136 -0
  11. data/data/doc/xmpp4r/examples/advanced/adventure/cube.xml +15 -0
  12. data/data/doc/xmpp4r/examples/advanced/adventure/tower.xml +69 -0
  13. data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +424 -0
  14. data/data/doc/xmpp4r/examples/advanced/fileserve.conf +11 -0
  15. data/data/doc/xmpp4r/examples/advanced/fileserve.rb +346 -0
  16. data/data/doc/xmpp4r/examples/advanced/getonline.rb +56 -0
  17. data/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +315 -0
  18. data/data/doc/xmpp4r/examples/advanced/migrate.rb +88 -0
  19. data/data/doc/xmpp4r/examples/advanced/minimuc.rb +266 -0
  20. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
  21. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
  22. data/data/doc/xmpp4r/examples/advanced/recvfile.rb +85 -0
  23. data/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +129 -0
  24. data/data/doc/xmpp4r/examples/advanced/sendfile.conf +10 -0
  25. data/data/doc/xmpp4r/examples/advanced/sendfile.rb +72 -0
  26. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +51 -0
  27. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +43 -0
  28. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +10 -0
  29. data/data/doc/xmpp4r/examples/advanced/versionpoll.rb +109 -0
  30. data/data/doc/xmpp4r/examples/advanced/xmpping.rb +146 -0
  31. data/data/doc/xmpp4r/examples/advanced/xmppingrc.sample +14 -0
  32. data/data/doc/xmpp4r/examples/basic/change_password.rb +41 -0
  33. data/data/doc/xmpp4r/examples/basic/client.rb +70 -0
  34. data/data/doc/xmpp4r/examples/basic/component.rb +11 -0
  35. data/data/doc/xmpp4r/examples/basic/echo.rb +37 -0
  36. data/data/doc/xmpp4r/examples/basic/jabbersend.rb +41 -0
  37. data/data/doc/xmpp4r/examples/basic/mass_sender.rb +68 -0
  38. data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +12 -0
  39. data/data/doc/xmpp4r/examples/basic/mucinfo.rb +41 -0
  40. data/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +82 -0
  41. data/data/doc/xmpp4r/examples/basic/register.rb +42 -0
  42. data/data/doc/xmpp4r/examples/basic/remove_registration.rb +18 -0
  43. data/data/doc/xmpp4r/examples/basic/roster.rb +44 -0
  44. data/data/doc/xmpp4r/examples/basic/rosterprint.rb +50 -0
  45. data/data/doc/xmpp4r/examples/basic/rosterrename.rb +34 -0
  46. data/data/doc/xmpp4r/examples/basic/rosterwatch.rb +171 -0
  47. data/data/doc/xmpp4r/examples/basic/send_vcard.rb +67 -0
  48. data/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
  49. data/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
  50. data/data/doc/xmpp4r/examples/basic/versionbot.rb +75 -0
  51. data/lib/xmpp4r.rb +118 -0
  52. data/lib/xmpp4r/base64.rb +32 -0
  53. data/lib/xmpp4r/bytestreams.rb +15 -0
  54. data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +321 -0
  55. data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +257 -0
  56. data/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +31 -0
  57. data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +54 -0
  58. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +153 -0
  59. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +86 -0
  60. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +198 -0
  61. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +65 -0
  62. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +82 -0
  63. data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +170 -0
  64. data/lib/xmpp4r/bytestreams/iq/si.rb +206 -0
  65. data/lib/xmpp4r/callbacks.rb +133 -0
  66. data/lib/xmpp4r/caps.rb +1 -0
  67. data/lib/xmpp4r/caps/c.rb +67 -0
  68. data/lib/xmpp4r/caps/helper/generator.rb +160 -0
  69. data/lib/xmpp4r/caps/helper/helper.rb +84 -0
  70. data/lib/xmpp4r/client.rb +345 -0
  71. data/lib/xmpp4r/command/helper/responder.rb +53 -0
  72. data/lib/xmpp4r/command/iq/command.rb +154 -0
  73. data/lib/xmpp4r/component.rb +103 -0
  74. data/lib/xmpp4r/connection.rb +231 -0
  75. data/lib/xmpp4r/dataforms.rb +5 -0
  76. data/lib/xmpp4r/dataforms/x/data.rb +297 -0
  77. data/lib/xmpp4r/debuglog.rb +63 -0
  78. data/lib/xmpp4r/delay.rb +5 -0
  79. data/lib/xmpp4r/delay/x/delay.rb +99 -0
  80. data/lib/xmpp4r/discovery.rb +8 -0
  81. data/lib/xmpp4r/discovery/helper/helper.rb +58 -0
  82. data/lib/xmpp4r/discovery/helper/responder.rb +165 -0
  83. data/lib/xmpp4r/discovery/iq/discoinfo.rb +211 -0
  84. data/lib/xmpp4r/discovery/iq/discoitems.rb +147 -0
  85. data/lib/xmpp4r/entity_time.rb +6 -0
  86. data/lib/xmpp4r/entity_time/iq.rb +45 -0
  87. data/lib/xmpp4r/entity_time/responder.rb +57 -0
  88. data/lib/xmpp4r/errors.rb +284 -0
  89. data/lib/xmpp4r/feature_negotiation.rb +5 -0
  90. data/lib/xmpp4r/feature_negotiation/iq/feature.rb +28 -0
  91. data/lib/xmpp4r/framework/base.rb +55 -0
  92. data/lib/xmpp4r/framework/bot.rb +148 -0
  93. data/lib/xmpp4r/httpbinding.rb +5 -0
  94. data/lib/xmpp4r/httpbinding/client.rb +275 -0
  95. data/lib/xmpp4r/idgenerator.rb +37 -0
  96. data/lib/xmpp4r/iq.rb +221 -0
  97. data/lib/xmpp4r/jid.rb +167 -0
  98. data/lib/xmpp4r/last.rb +2 -0
  99. data/lib/xmpp4r/last/helper/helper.rb +37 -0
  100. data/lib/xmpp4r/last/iq/last.rb +67 -0
  101. data/lib/xmpp4r/location.rb +2 -0
  102. data/lib/xmpp4r/location/helper/helper.rb +56 -0
  103. data/lib/xmpp4r/location/location.rb +179 -0
  104. data/lib/xmpp4r/message.rb +226 -0
  105. data/lib/xmpp4r/muc.rb +14 -0
  106. data/lib/xmpp4r/muc/helper/mucbrowser.rb +92 -0
  107. data/lib/xmpp4r/muc/helper/mucclient.rb +469 -0
  108. data/lib/xmpp4r/muc/helper/simplemucclient.rb +332 -0
  109. data/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
  110. data/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
  111. data/lib/xmpp4r/muc/iq/mucowner.rb +15 -0
  112. data/lib/xmpp4r/muc/item.rb +143 -0
  113. data/lib/xmpp4r/muc/x/muc.rb +70 -0
  114. data/lib/xmpp4r/muc/x/mucuserinvite.rb +60 -0
  115. data/lib/xmpp4r/muc/x/mucuseritem.rb +36 -0
  116. data/lib/xmpp4r/presence.rb +232 -0
  117. data/lib/xmpp4r/pubsub.rb +8 -0
  118. data/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
  119. data/lib/xmpp4r/pubsub/children/event.rb +49 -0
  120. data/lib/xmpp4r/pubsub/children/item.rb +35 -0
  121. data/lib/xmpp4r/pubsub/children/items.rb +53 -0
  122. data/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
  123. data/lib/xmpp4r/pubsub/children/publish.rb +38 -0
  124. data/lib/xmpp4r/pubsub/children/retract.rb +41 -0
  125. data/lib/xmpp4r/pubsub/children/subscription.rb +62 -0
  126. data/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
  127. data/lib/xmpp4r/pubsub/children/unsubscribe.rb +63 -0
  128. data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +129 -0
  129. data/lib/xmpp4r/pubsub/helper/nodehelper.rb +156 -0
  130. data/lib/xmpp4r/pubsub/helper/oauth_service_helper.rb +90 -0
  131. data/lib/xmpp4r/pubsub/helper/servicehelper.rb +490 -0
  132. data/lib/xmpp4r/pubsub/iq/pubsub.rb +19 -0
  133. data/lib/xmpp4r/query.rb +15 -0
  134. data/lib/xmpp4r/reliable.rb +168 -0
  135. data/lib/xmpp4r/rexmladdons.rb +197 -0
  136. data/lib/xmpp4r/roster.rb +7 -0
  137. data/lib/xmpp4r/roster/helper/roster.rb +532 -0
  138. data/lib/xmpp4r/roster/iq/roster.rb +215 -0
  139. data/lib/xmpp4r/roster/x/roster.rb +138 -0
  140. data/lib/xmpp4r/rpc.rb +2 -0
  141. data/lib/xmpp4r/rpc/helper/client.rb +123 -0
  142. data/lib/xmpp4r/rpc/helper/server.rb +74 -0
  143. data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +67 -0
  144. data/lib/xmpp4r/rpc/iq/rpc.rb +23 -0
  145. data/lib/xmpp4r/sasl.rb +259 -0
  146. data/lib/xmpp4r/semaphore.rb +38 -0
  147. data/lib/xmpp4r/stream.rb +611 -0
  148. data/lib/xmpp4r/streamparser.rb +66 -0
  149. data/lib/xmpp4r/test/listener_mocker.rb +118 -0
  150. data/lib/xmpp4r/tune.rb +2 -0
  151. data/lib/xmpp4r/tune/helper/helper.rb +58 -0
  152. data/lib/xmpp4r/tune/tune.rb +113 -0
  153. data/lib/xmpp4r/vcard.rb +6 -0
  154. data/lib/xmpp4r/vcard/helper/vcard.rb +84 -0
  155. data/lib/xmpp4r/vcard/iq/vcard.rb +109 -0
  156. data/lib/xmpp4r/version.rb +7 -0
  157. data/lib/xmpp4r/version/helper/responder.rb +72 -0
  158. data/lib/xmpp4r/version/helper/simpleresponder.rb +44 -0
  159. data/lib/xmpp4r/version/iq/version.rb +105 -0
  160. data/lib/xmpp4r/x.rb +37 -0
  161. data/lib/xmpp4r/xhtml.rb +1 -0
  162. data/lib/xmpp4r/xhtml/html.rb +115 -0
  163. data/lib/xmpp4r/xmpp4r.rb +20 -0
  164. data/lib/xmpp4r/xmppelement.rb +168 -0
  165. data/lib/xmpp4r/xmppstanza.rb +162 -0
  166. data/setup.rb +1586 -0
  167. data/test/bytestreams/tc_ibb.rb +188 -0
  168. data/test/bytestreams/tc_socks5bytestreams.rb +114 -0
  169. data/test/caps/tc_helper.rb +158 -0
  170. data/test/dataforms/tc_data.rb +81 -0
  171. data/test/delay/tc_xdelay.rb +51 -0
  172. data/test/discovery/tc_responder.rb +91 -0
  173. data/test/entity_time/tc_responder.rb +65 -0
  174. data/test/last/tc_helper.rb +75 -0
  175. data/test/lib/assert_equal_xml.rb +14 -0
  176. data/test/lib/clienttester.rb +149 -0
  177. data/test/muc/tc_muc_mucclient.rb +834 -0
  178. data/test/muc/tc_muc_simplemucclient.rb +114 -0
  179. data/test/muc/tc_mucowner.rb +50 -0
  180. data/test/pubsub/tc_helper.rb +785 -0
  181. data/test/pubsub/tc_nodeconfig.rb +61 -0
  182. data/test/pubsub/tc_subscriptionconfig.rb +41 -0
  183. data/test/roster/tc_helper.rb +523 -0
  184. data/test/roster/tc_iqqueryroster.rb +173 -0
  185. data/test/roster/tc_xroster.rb +73 -0
  186. data/test/rpc/tc_helper.rb +96 -0
  187. data/test/tc_callbacks.rb +129 -0
  188. data/test/tc_class_names.rb +146 -0
  189. data/test/tc_client.rb +30 -0
  190. data/test/tc_errors.rb +146 -0
  191. data/test/tc_idgenerator.rb +30 -0
  192. data/test/tc_iq.rb +113 -0
  193. data/test/tc_iqquery.rb +31 -0
  194. data/test/tc_jid.rb +204 -0
  195. data/test/tc_presence.rb +150 -0
  196. data/test/tc_rexml.rb +139 -0
  197. data/test/tc_stream.rb +193 -0
  198. data/test/tc_streamComponent.rb +105 -0
  199. data/test/tc_streamError.rb +129 -0
  200. data/test/tc_streamSend.rb +59 -0
  201. data/test/tc_streamparser.rb +137 -0
  202. data/test/tc_xmppstanza.rb +135 -0
  203. data/test/ts_xmpp4r.rb +44 -0
  204. data/test/tune/tc_helper_recv.rb +82 -0
  205. data/test/tune/tc_helper_send.rb +74 -0
  206. data/test/tune/tc_tune.rb +79 -0
  207. data/test/vcard/tc_helper.rb +49 -0
  208. data/test/vcard/tc_iqvcard.rb +62 -0
  209. data/test/version/tc_helper.rb +60 -0
  210. data/test/version/tc_iqqueryversion.rb +97 -0
  211. data/test/xhtml/tc_html.rb +41 -0
  212. data/tools/gen_requires.bash +31 -0
  213. data/tools/xmpp4r-gemspec-test.rb +11 -0
  214. data/xmpp4r.gemspec +249 -0
  215. metadata +299 -0
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift '../lib'
4
+
5
+ require 'test/unit'
6
+ require 'xmpp4r/tune/tune.rb'
7
+
8
+ class Jabber::UserTune::TuneTest < Test::Unit::TestCase
9
+ def test_create
10
+ artist='Mike Flowers Pops'
11
+ title='Light My Fire'
12
+ length=175
13
+ track='4'
14
+ source='A Groovy Place'
15
+ uri='http://musicbrainz.org/track/d44110e6-4b20-4d16-9e69-74bf0e4f7106.html'
16
+ rating=10
17
+
18
+ t=Jabber::UserTune::Tune.new(artist,title,length,track,source,uri,rating)
19
+
20
+ assert_kind_of Jabber::UserTune::Tune,t
21
+ assert_equal 7,t.elements.size
22
+ assert_equal true,t.playing?
23
+ assert_equal artist,t.artist
24
+ assert_equal track,t.track
25
+ assert_equal length,t.length
26
+ assert_equal track,t.track
27
+ assert_equal source,t.source
28
+ assert_equal uri,t.uri
29
+ assert_equal rating,t.rating
30
+ end
31
+
32
+ def test_stop_playing
33
+ t=Jabber::UserTune::Tune.new
34
+
35
+ assert_kind_of Jabber::UserTune::Tune,t
36
+ assert_equal 0,t.elements.size
37
+ assert_equal false, t.playing?
38
+ assert_equal nil,t.artist
39
+ assert_equal nil,t.track
40
+ assert_equal nil,t.length
41
+ assert_equal nil,t.track
42
+ assert_equal nil,t.source
43
+ assert_equal nil,t.uri
44
+ end
45
+
46
+ def test_rating_edgecases
47
+ assert_equal(0, Jabber::UserTune::Tune.new(artist,title,length,track,source,uri,-1.5).rating)
48
+ assert_equal(10, Jabber::UserTune::Tune.new(artist,title,length,track,source,uri,11.5).rating)
49
+ assert_equal(nil, Jabber::UserTune::Tune.new(artist,title,length,track,source,uri,'fantastic').rating)
50
+ end
51
+
52
+ def artist
53
+ 'Mike Flowers Pops'
54
+ end
55
+
56
+ def title
57
+ 'Light My Fire'
58
+ end
59
+
60
+ def length
61
+ 175
62
+ end
63
+
64
+ def track
65
+ '4'
66
+ end
67
+
68
+ def source
69
+ 'A Groovy Place'
70
+ end
71
+
72
+ def uri
73
+ 'http://musicbrainz.org/track/d44110e6-4b20-4d16-9e69-74bf0e4f7106.html'
74
+ end
75
+
76
+ def rating
77
+ 10
78
+ end
79
+ end
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File::dirname(__FILE__) + '/../../lib'
4
+
5
+ require 'test/unit'
6
+ require File::dirname(__FILE__) + '/../lib/clienttester'
7
+
8
+ require 'xmpp4r'
9
+ require 'xmpp4r/vcard/helper/vcard'
10
+ include Jabber
11
+
12
+ class Vcard::HelperTest < Test::Unit::TestCase
13
+ include ClientTester
14
+
15
+ def test_create
16
+ h = Vcard::Helper.new(@client)
17
+ assert_kind_of(Vcard::Helper, h)
18
+ end
19
+
20
+ def test_callback
21
+ # @server.on_exception{|*e| p e}
22
+ class << @client
23
+ remove_method(:jid)
24
+ def jid
25
+ JID.new('b@b.com/b')
26
+ end
27
+ end
28
+
29
+ state { |iq|
30
+ assert_kind_of(Iq, iq)
31
+ assert_equal(JID.new('a@b.com'), iq.to)
32
+ assert_equal(:get, iq.type)
33
+ assert_nil(iq.queryns)
34
+ assert_kind_of(Vcard::IqVcard, iq.vcard)
35
+ children = 0
36
+ iq.vcard.each_child { children += 1 }
37
+ assert_equal(0, children)
38
+
39
+ send("<iq type='result' from='#{iq.to}' to='#{iq.from}' id='#{iq.id}'><vCard xmlns='vcard-temp'><NICKNAME>Mr. B</NICKNAME><PHOTO><TYPE>image/png</TYPE><BINVAL>====</BINVAL></PHOTO></vCard></iq>")
40
+ }
41
+
42
+ res = Vcard::Helper::get(@client, 'a@b.com')
43
+ wait_state
44
+ assert_kind_of(Vcard::IqVcard, res)
45
+ assert_equal('Mr. B', res['NICKNAME'])
46
+ assert_equal('image/png', res['PHOTO/TYPE'])
47
+ assert_equal('====', res['PHOTO/BINVAL'])
48
+ end
49
+ end
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File::dirname(__FILE__) + '/../../lib'
4
+
5
+ require 'test/unit'
6
+ require 'xmpp4r/rexmladdons'
7
+ require 'xmpp4r/vcard/iq/vcard'
8
+ include Jabber
9
+
10
+ class IqVcardTest < Test::Unit::TestCase
11
+ def test_create
12
+ v = Vcard::IqVcard.new
13
+ assert_equal([], v.fields)
14
+ end
15
+
16
+ def test_create_with_fields
17
+ v = Vcard::IqVcard.new({'FN' => 'B C', 'NICKNAME' => 'D'})
18
+ assert_equal(['FN', 'NICKNAME'], v.fields.sort)
19
+ assert_equal('B C', v['FN'])
20
+ assert_equal('D', v['NICKNAME'])
21
+ assert_equal(nil, v['x'])
22
+ end
23
+
24
+ def test_fields
25
+ v = Vcard::IqVcard.new
26
+ f = ['a', 'b', 'c', 'd', 'e']
27
+ f.each { |s|
28
+ v[s.downcase] = s.upcase
29
+ }
30
+
31
+ assert_equal(f, v.fields.sort)
32
+
33
+ f.each { |s|
34
+ assert_equal(s.upcase, v[s.downcase])
35
+ assert_equal(nil, v[s.upcase])
36
+ }
37
+ end
38
+
39
+ def test_deep
40
+ v = Vcard::IqVcard.new({
41
+ 'FN' => 'John D. Random',
42
+ 'PHOTO/TYPE' => 'image/png',
43
+ 'PHOTO/BINVAL' => '===='})
44
+
45
+ assert_equal(['FN', 'PHOTO/BINVAL', 'PHOTO/TYPE'], v.fields.sort)
46
+ assert_equal('John D. Random', v['FN'])
47
+ assert_equal('image/png', v['PHOTO/TYPE'])
48
+ assert_equal('====', v['PHOTO/BINVAL'])
49
+ assert_equal(nil, v['PHOTO'])
50
+ assert_equal(nil, v['NICKNAME'])
51
+ end
52
+
53
+ def test_photo_binval
54
+ v = Vcard::IqVcard.new({'PHOTO/BINVAL'=>"SGVsbG8gd29ybGQ=\n"})
55
+ assert_equal('Hello world', v.photo_binval)
56
+ end
57
+
58
+ def test_photo_binval_nil
59
+ v = Vcard::IqVcard.new({})
60
+ assert_nil(v.photo_binval)
61
+ end
62
+ end
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File::dirname(__FILE__) + '/../../lib'
4
+
5
+ require 'test/unit'
6
+ require File::dirname(__FILE__) + '/../lib/clienttester'
7
+
8
+ require 'xmpp4r'
9
+ require 'xmpp4r/version/helper/responder'
10
+ require 'xmpp4r/version/helper/simpleresponder'
11
+ include Jabber
12
+
13
+ class Version::HelperTest < Test::Unit::TestCase
14
+ include ClientTester
15
+
16
+ def test_create
17
+ h = Version::Responder.new(@client)
18
+ assert_kind_of(Version::Responder, h)
19
+ assert_respond_to(h, :add_version_callback)
20
+ end
21
+
22
+ def test_callback
23
+ # Prepare helper
24
+ h = Version::Responder.new(@client)
25
+
26
+ calls = 0
27
+ h.add_version_callback { |iq,responder|
28
+ calls += 1
29
+ assert('jabber:iq:version', iq.queryns)
30
+ responder.call('Test program', '1.0', 'Ruby Test::Unit')
31
+ }
32
+
33
+ # Send stanzas which shouldn't match
34
+ @server.send("<iq type='set'><query xmlns='jabber:iq:version'/></iq>")
35
+ @server.send("<iq type='get'><query xmlns='jabber:iq:browse'/></iq>")
36
+ assert_equal(0, calls)
37
+
38
+ # Send a query
39
+ @server.send("<iq type='get'><query xmlns='jabber:iq:version'/></iq>") { |reply|
40
+ assert_equal('Test program', reply.query.iname)
41
+ assert_equal('1.0', reply.query.version)
42
+ assert_equal('Ruby Test::Unit', reply.query.os)
43
+ true
44
+ }
45
+ assert_equal(1, calls)
46
+ end
47
+
48
+ def test_simple
49
+ h = Version::SimpleResponder.new(@client, 'Test program', '1.0', 'Ruby Test::Unit')
50
+
51
+ # Send a query
52
+ @server.send("<iq type='get'><query xmlns='jabber:iq:version'/></iq>") { |reply|
53
+ assert_equal('Test program', reply.query.iname)
54
+ assert_equal('1.0', reply.query.version)
55
+ assert_equal('Ruby Test::Unit', reply.query.os)
56
+ true
57
+ }
58
+
59
+ end
60
+ end
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File::dirname(__FILE__) + '/../../lib'
4
+
5
+ require 'test/unit'
6
+ require 'xmpp4r/rexmladdons'
7
+ require 'xmpp4r/iq'
8
+ require 'xmpp4r/version/iq/version'
9
+ include Jabber
10
+
11
+ class Version::IqQueryVersionTest < Test::Unit::TestCase
12
+ def test_create_empty
13
+ x = Version::IqQueryVersion.new
14
+ assert_equal('jabber:iq:version', x.namespace)
15
+ assert_nil(x.iname)
16
+ assert_nil(x.version)
17
+ assert_nil(x.os)
18
+ end
19
+
20
+ def test_create
21
+ x = Version::IqQueryVersion.new('my test', 'XP')
22
+ assert_equal('jabber:iq:version', x.namespace)
23
+ assert_equal('my test', x.iname)
24
+ assert_equal('XP', x.version)
25
+ assert_equal(nil, x.os)
26
+ end
27
+
28
+ def test_create_with_os
29
+ x = Version::IqQueryVersion.new('superbot', '1.0-final', 'FreeBSD 5.4-RELEASE-p4')
30
+ assert_equal('jabber:iq:version', x.namespace)
31
+ assert_equal('superbot', x.iname)
32
+ assert_equal('1.0-final', x.version)
33
+ assert_equal('FreeBSD 5.4-RELEASE-p4', x.os)
34
+ end
35
+
36
+ def test_import1
37
+ iq = Iq.new
38
+ q = REXML::Element.new('query')
39
+ q.add_namespace('jabber:iq:version')
40
+ iq.add(q)
41
+ iq2 = Iq.new.import(iq)
42
+ assert_equal(Version::IqQueryVersion, iq2.query.class)
43
+ end
44
+
45
+ def test_import2
46
+ iq = Iq.new
47
+ q = REXML::Element.new('query')
48
+ q.add_namespace('jabber:iq:version')
49
+ q.add_element('name').text = 'AstroBot'
50
+ q.add_element('version').text = 'XP'
51
+ q.add_element('os').text = 'FreeDOS'
52
+ iq.add(q)
53
+ iq = Iq.new.import(iq)
54
+ assert_equal(Version::IqQueryVersion, iq.query.class)
55
+ assert_equal('AstroBot', iq.query.iname)
56
+ assert_equal('XP', iq.query.version)
57
+ assert_equal('FreeDOS', iq.query.os)
58
+ end
59
+
60
+ def test_replace
61
+ x = Version::IqQueryVersion.new('name', 'version', 'os')
62
+
63
+ num = 0
64
+ x.each_element('name') { |e| num += 1 }
65
+ assert_equal(1, num)
66
+ num = 0
67
+ x.each_element('version') { |e| num += 1 }
68
+ assert_equal(1, num)
69
+ num = 0
70
+ x.each_element('os') { |e| num += 1 }
71
+ assert_equal(1, num)
72
+
73
+ x.set_iname('N').set_version('V').set_os('O')
74
+
75
+ num = 0
76
+ x.each_element('name') { |e| num += 1 }
77
+ assert_equal(1, num)
78
+ num = 0
79
+ x.each_element('version') { |e| num += 1 }
80
+ assert_equal(1, num)
81
+ num = 0
82
+ x.each_element('os') { |e| num += 1 }
83
+ assert_equal(1, num)
84
+
85
+ x.set_iname(nil).set_version(nil).set_os(nil)
86
+
87
+ num = 0
88
+ x.each_element('name') { |e| num += 1 }
89
+ assert_equal(1, num)
90
+ num = 0
91
+ x.each_element('version') { |e| num += 1 }
92
+ assert_equal(1, num)
93
+ num = 0
94
+ x.each_element('os') { |e| num += 1 }
95
+ assert_equal(0, num)
96
+ end
97
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File::dirname(__FILE__) + '/../../lib'
4
+
5
+ require 'test/unit'
6
+ require File::dirname(__FILE__) + '/../lib/clienttester'
7
+
8
+ require 'xmpp4r/xhtml'
9
+ include Jabber
10
+
11
+ class XHTML::HTMLTest < Test::Unit::TestCase
12
+ def test_set
13
+ contents1 = REXML::Element.new('p')
14
+ contents1.text = 'Hello'
15
+ html = XHTML::HTML.new(contents1)
16
+ assert_kind_of(XHTML::Body, html.first_element('body'))
17
+ assert_equal("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'><p>Hello</p></body></html>", html.to_s)
18
+
19
+ contents2 = REXML::Element.new('a')
20
+ contents2.attributes['href'] = 'about:blank'
21
+ contents2.text = 'nothing'
22
+ html.contents = ["Look at ", contents2]
23
+ assert_equal("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>Look at <a href='about:blank'>nothing</a></body></html>", html.to_s)
24
+ end
25
+
26
+ def test_parse
27
+ html = XHTML::HTML.new('There is a fine <a href="http://home.gna.org/xmpp4r/">library</a>')
28
+ assert_equal("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>There is a fine <a href='http://home.gna.org/xmpp4r/'>library</a></body></html>", html.to_s)
29
+ end
30
+
31
+ def test_text
32
+ a1 = REXML::Element.new('a')
33
+ a1.attributes['href'] = 'http://www.jabber.org/'
34
+ a1.text = 'Jabber'
35
+ a2 = REXML::Element.new('a')
36
+ a2.attributes['href'] = 'http://home.gna.org/xmpp4r/'
37
+ a2.text = 'XMPP4R'
38
+ html = XHTML::HTML.new(["Look at ", a1, " & ", a2])
39
+ assert_equal("Look at Jabber & XMPP4R", html.to_text)
40
+ end
41
+ end
@@ -0,0 +1,31 @@
1
+ #!/bin/bash
2
+
3
+ # Generate a full graph of the requires in the Ruby files of this library.
4
+ #
5
+ # Output : The graph is generated as a .png file in the same dir as this script.
6
+ #
7
+ # This script requires the following tools to be installed:
8
+ #
9
+ # * mktemp
10
+ # * dot (Try 'sudo port install graphviz' on OS X)
11
+
12
+ export TMPDIR='/tmp'
13
+ export TMPFILE=$(mktemp $TMPDIR/gen_requires.XXXXXX)
14
+ export OUTFILE='gen_requires.png'
15
+ export SELFDIR=`pwd`
16
+ export LIBDIR=$SELFDIR/../lib
17
+
18
+ #######################################
19
+ # Unlikely you need to edit below here
20
+ #######################################
21
+
22
+ cd $LIBDIR
23
+
24
+ echo "strict digraph requirestree { " > $TMPFILE
25
+ grep -r "^require " * | grep -v swp | sed "s/^\(.*\).rb:require '\(.*\)'/\1 -> \2;/" | sed 's/\//_/g' >> $TMPFILE
26
+ echo "}" >> $TMPFILE
27
+
28
+ cd $SELFDIR
29
+ dot -Tpng $TMPFILE -o $OUTFILE
30
+ rm -f $TMPFILE
31
+
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Since GitHub doesn't allow unsafe commands in a gemspec this script
4
+ # will simulate running in their environment.
5
+
6
+ require 'rubygems/specification'
7
+ data = File.read('../xmpp4r.gemspec')
8
+ spec = nil
9
+ Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
10
+ puts spec
11
+
@@ -0,0 +1,249 @@
1
+ # WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!
2
+ # RUN : 'rake gem:update_gemspec'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.authors = ["Lucas Nussbaum", "Stephan Maka", "Glenn Rempe"]
6
+ s.bindir = "bin"
7
+ s.description = "XMPP4R is an XMPP/Jabber library for Ruby."
8
+ s.email = "xmpp4r-devel@gna.org"
9
+ s.extra_rdoc_files = ["CHANGELOG", "COPYING", "LICENSE", "README.rdoc", "README_ruby19.txt"]
10
+ s.has_rdoc = true
11
+ s.homepage = "http://home.gna.org/xmpp4r/"
12
+ # s.activated = false
13
+ s.name = "gmcmillan-xmpp4r"
14
+ s.platform = "ruby"
15
+ s.rdoc_options = ["--quiet", "--title", "XMPP4R is an XMPP/Jabber library for Ruby.", "--opname", "index.html", "--main", "lib/xmpp4r.rb", "--line-numbers", "--inline-source"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = "xmpp4r"
18
+ s.rubygems_version = "1.3.4"
19
+ s.specification_version = 3
20
+ s.summary = "XMPP4R is an XMPP/Jabber library for Ruby."
21
+ s.version = "0.5"
22
+ s.executables = %w()
23
+
24
+ s.required_ruby_version = ">= 1.8.4"
25
+ s.required_rubygems_version = ">= 0"
26
+
27
+ s.add_dependency 'nokogiri'
28
+ s.add_dependency 'rdoc', '>2.4.2'
29
+
30
+
31
+
32
+
33
+
34
+ s.files = [
35
+ "CHANGELOG",
36
+ "COPYING",
37
+ "LICENSE",
38
+ "README.rdoc",
39
+ "README_ruby19.txt",
40
+ "Rakefile",
41
+ "data/doc/xmpp4r/examples/advanced/adventure/README",
42
+ "data/doc/xmpp4r/examples/advanced/adventure/adventure.rb",
43
+ "data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb",
44
+ "data/doc/xmpp4r/examples/advanced/adventure/cube.xml",
45
+ "data/doc/xmpp4r/examples/advanced/adventure/tower.xml",
46
+ "data/doc/xmpp4r/examples/advanced/adventure/world.rb",
47
+ "data/doc/xmpp4r/examples/advanced/fileserve.conf",
48
+ "data/doc/xmpp4r/examples/advanced/fileserve.rb",
49
+ "data/doc/xmpp4r/examples/advanced/getonline.rb",
50
+ "data/doc/xmpp4r/examples/advanced/gtkmucclient.rb",
51
+ "data/doc/xmpp4r/examples/advanced/migrate.rb",
52
+ "data/doc/xmpp4r/examples/advanced/minimuc.rb",
53
+ "data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl",
54
+ "data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb",
55
+ "data/doc/xmpp4r/examples/advanced/recvfile.rb",
56
+ "data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb",
57
+ "data/doc/xmpp4r/examples/advanced/sendfile.conf",
58
+ "data/doc/xmpp4r/examples/advanced/sendfile.rb",
59
+ "data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb",
60
+ "data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb",
61
+ "data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb",
62
+ "data/doc/xmpp4r/examples/advanced/versionpoll.rb",
63
+ "data/doc/xmpp4r/examples/advanced/xmpping.rb",
64
+ "data/doc/xmpp4r/examples/advanced/xmppingrc.sample",
65
+ "data/doc/xmpp4r/examples/basic/change_password.rb",
66
+ "data/doc/xmpp4r/examples/basic/client.rb",
67
+ "data/doc/xmpp4r/examples/basic/component.rb",
68
+ "data/doc/xmpp4r/examples/basic/echo.rb",
69
+ "data/doc/xmpp4r/examples/basic/jabbersend.rb",
70
+ "data/doc/xmpp4r/examples/basic/mass_sender.rb",
71
+ "data/doc/xmpp4r/examples/basic/muc_owner_config.rb",
72
+ "data/doc/xmpp4r/examples/basic/mucinfo.rb",
73
+ "data/doc/xmpp4r/examples/basic/mucsimplebot.rb",
74
+ "data/doc/xmpp4r/examples/basic/register.rb",
75
+ "data/doc/xmpp4r/examples/basic/remove_registration.rb",
76
+ "data/doc/xmpp4r/examples/basic/roster.rb",
77
+ "data/doc/xmpp4r/examples/basic/rosterprint.rb",
78
+ "data/doc/xmpp4r/examples/basic/rosterrename.rb",
79
+ "data/doc/xmpp4r/examples/basic/rosterwatch.rb",
80
+ "data/doc/xmpp4r/examples/basic/send_vcard.rb",
81
+ "data/doc/xmpp4r/examples/basic/tune_client.rb",
82
+ "data/doc/xmpp4r/examples/basic/tune_server.rb",
83
+ "data/doc/xmpp4r/examples/basic/versionbot.rb",
84
+ "lib/xmpp4r.rb",
85
+ "lib/xmpp4r/base64.rb",
86
+ "lib/xmpp4r/bytestreams.rb",
87
+ "lib/xmpp4r/bytestreams/helper/filetransfer.rb",
88
+ "lib/xmpp4r/bytestreams/helper/ibb/base.rb",
89
+ "lib/xmpp4r/bytestreams/helper/ibb/initiator.rb",
90
+ "lib/xmpp4r/bytestreams/helper/ibb/target.rb",
91
+ "lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb",
92
+ "lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb",
93
+ "lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb",
94
+ "lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb",
95
+ "lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb",
96
+ "lib/xmpp4r/bytestreams/iq/bytestreams.rb",
97
+ "lib/xmpp4r/bytestreams/iq/si.rb",
98
+ "lib/xmpp4r/callbacks.rb",
99
+ "lib/xmpp4r/caps.rb",
100
+ "lib/xmpp4r/caps/c.rb",
101
+ "lib/xmpp4r/caps/helper/generator.rb",
102
+ "lib/xmpp4r/caps/helper/helper.rb",
103
+ "lib/xmpp4r/client.rb",
104
+ "lib/xmpp4r/command/helper/responder.rb",
105
+ "lib/xmpp4r/command/iq/command.rb",
106
+ "lib/xmpp4r/component.rb",
107
+ "lib/xmpp4r/connection.rb",
108
+ "lib/xmpp4r/dataforms.rb",
109
+ "lib/xmpp4r/dataforms/x/data.rb",
110
+ "lib/xmpp4r/debuglog.rb",
111
+ "lib/xmpp4r/delay.rb",
112
+ "lib/xmpp4r/delay/x/delay.rb",
113
+ "lib/xmpp4r/discovery.rb",
114
+ "lib/xmpp4r/discovery/helper/helper.rb",
115
+ "lib/xmpp4r/discovery/helper/responder.rb",
116
+ "lib/xmpp4r/discovery/iq/discoinfo.rb",
117
+ "lib/xmpp4r/discovery/iq/discoitems.rb",
118
+ "lib/xmpp4r/entity_time.rb",
119
+ "lib/xmpp4r/entity_time/iq.rb",
120
+ "lib/xmpp4r/entity_time/responder.rb",
121
+ "lib/xmpp4r/errors.rb",
122
+ "lib/xmpp4r/feature_negotiation.rb",
123
+ "lib/xmpp4r/feature_negotiation/iq/feature.rb",
124
+ "lib/xmpp4r/framework/base.rb",
125
+ "lib/xmpp4r/framework/bot.rb",
126
+ "lib/xmpp4r/httpbinding.rb",
127
+ "lib/xmpp4r/httpbinding/client.rb",
128
+ "lib/xmpp4r/idgenerator.rb",
129
+ "lib/xmpp4r/iq.rb",
130
+ "lib/xmpp4r/jid.rb",
131
+ "lib/xmpp4r/last.rb",
132
+ "lib/xmpp4r/last/helper/helper.rb",
133
+ "lib/xmpp4r/last/iq/last.rb",
134
+ "lib/xmpp4r/location.rb",
135
+ "lib/xmpp4r/location/helper/helper.rb",
136
+ "lib/xmpp4r/location/location.rb",
137
+ "lib/xmpp4r/message.rb",
138
+ "lib/xmpp4r/muc.rb",
139
+ "lib/xmpp4r/muc/helper/mucbrowser.rb",
140
+ "lib/xmpp4r/muc/helper/mucclient.rb",
141
+ "lib/xmpp4r/muc/helper/simplemucclient.rb",
142
+ "lib/xmpp4r/muc/iq/mucadmin.rb",
143
+ "lib/xmpp4r/muc/iq/mucadminitem.rb",
144
+ "lib/xmpp4r/muc/iq/mucowner.rb",
145
+ "lib/xmpp4r/muc/item.rb",
146
+ "lib/xmpp4r/muc/x/muc.rb",
147
+ "lib/xmpp4r/muc/x/mucuserinvite.rb",
148
+ "lib/xmpp4r/muc/x/mucuseritem.rb",
149
+ "lib/xmpp4r/presence.rb",
150
+ "lib/xmpp4r/pubsub.rb",
151
+ "lib/xmpp4r/pubsub/children/configuration.rb",
152
+ "lib/xmpp4r/pubsub/children/event.rb",
153
+ "lib/xmpp4r/pubsub/children/item.rb",
154
+ "lib/xmpp4r/pubsub/children/items.rb",
155
+ "lib/xmpp4r/pubsub/children/node_config.rb",
156
+ "lib/xmpp4r/pubsub/children/publish.rb",
157
+ "lib/xmpp4r/pubsub/children/retract.rb",
158
+ "lib/xmpp4r/pubsub/children/subscription.rb",
159
+ "lib/xmpp4r/pubsub/children/subscription_config.rb",
160
+ "lib/xmpp4r/pubsub/children/unsubscribe.rb",
161
+ "lib/xmpp4r/pubsub/helper/nodebrowser.rb",
162
+ "lib/xmpp4r/pubsub/helper/nodehelper.rb",
163
+ "lib/xmpp4r/pubsub/helper/oauth_service_helper.rb",
164
+ "lib/xmpp4r/pubsub/helper/servicehelper.rb",
165
+ "lib/xmpp4r/pubsub/iq/pubsub.rb",
166
+ "lib/xmpp4r/query.rb",
167
+ "lib/xmpp4r/reliable.rb",
168
+ "lib/xmpp4r/rexmladdons.rb",
169
+ "lib/xmpp4r/roster.rb",
170
+ "lib/xmpp4r/roster/helper/roster.rb",
171
+ "lib/xmpp4r/roster/iq/roster.rb",
172
+ "lib/xmpp4r/roster/x/roster.rb",
173
+ "lib/xmpp4r/rpc.rb",
174
+ "lib/xmpp4r/rpc/helper/client.rb",
175
+ "lib/xmpp4r/rpc/helper/server.rb",
176
+ "lib/xmpp4r/rpc/helper/xmlrpcaddons.rb",
177
+ "lib/xmpp4r/rpc/iq/rpc.rb",
178
+ "lib/xmpp4r/sasl.rb",
179
+ "lib/xmpp4r/semaphore.rb",
180
+ "lib/xmpp4r/stream.rb",
181
+ "lib/xmpp4r/streamparser.rb",
182
+ "lib/xmpp4r/test/listener_mocker.rb",
183
+ "lib/xmpp4r/tune.rb",
184
+ "lib/xmpp4r/tune/helper/helper.rb",
185
+ "lib/xmpp4r/tune/tune.rb",
186
+ "lib/xmpp4r/vcard.rb",
187
+ "lib/xmpp4r/vcard/helper/vcard.rb",
188
+ "lib/xmpp4r/vcard/iq/vcard.rb",
189
+ "lib/xmpp4r/version.rb",
190
+ "lib/xmpp4r/version/helper/responder.rb",
191
+ "lib/xmpp4r/version/helper/simpleresponder.rb",
192
+ "lib/xmpp4r/version/iq/version.rb",
193
+ "lib/xmpp4r/x.rb",
194
+ "lib/xmpp4r/xhtml.rb",
195
+ "lib/xmpp4r/xhtml/html.rb",
196
+ "lib/xmpp4r/xmpp4r.rb",
197
+ "lib/xmpp4r/xmppelement.rb",
198
+ "lib/xmpp4r/xmppstanza.rb",
199
+ "setup.rb",
200
+ "test/bytestreams/tc_ibb.rb",
201
+ "test/bytestreams/tc_socks5bytestreams.rb",
202
+ "test/caps/tc_helper.rb",
203
+ "test/dataforms/tc_data.rb",
204
+ "test/delay/tc_xdelay.rb",
205
+ "test/discovery/tc_responder.rb",
206
+ "test/entity_time/tc_responder.rb",
207
+ "test/last/tc_helper.rb",
208
+ "test/lib/assert_equal_xml.rb",
209
+ "test/lib/clienttester.rb",
210
+ "test/muc/tc_muc_mucclient.rb",
211
+ "test/muc/tc_muc_simplemucclient.rb",
212
+ "test/muc/tc_mucowner.rb",
213
+ "test/pubsub/tc_helper.rb",
214
+ "test/pubsub/tc_nodeconfig.rb",
215
+ "test/pubsub/tc_subscriptionconfig.rb",
216
+ "test/roster/tc_helper.rb",
217
+ "test/roster/tc_iqqueryroster.rb",
218
+ "test/roster/tc_xroster.rb",
219
+ "test/rpc/tc_helper.rb",
220
+ "test/tc_callbacks.rb",
221
+ "test/tc_class_names.rb",
222
+ "test/tc_client.rb",
223
+ "test/tc_errors.rb",
224
+ "test/tc_idgenerator.rb",
225
+ "test/tc_iq.rb",
226
+ "test/tc_iqquery.rb",
227
+ "test/tc_jid.rb",
228
+ "test/tc_presence.rb",
229
+ "test/tc_rexml.rb",
230
+ "test/tc_stream.rb",
231
+ "test/tc_streamComponent.rb",
232
+ "test/tc_streamError.rb",
233
+ "test/tc_streamSend.rb",
234
+ "test/tc_streamparser.rb",
235
+ "test/tc_xmppstanza.rb",
236
+ "test/ts_xmpp4r.rb",
237
+ "test/tune/tc_helper_recv.rb",
238
+ "test/tune/tc_helper_send.rb",
239
+ "test/tune/tc_tune.rb",
240
+ "test/vcard/tc_helper.rb",
241
+ "test/vcard/tc_iqvcard.rb",
242
+ "test/version/tc_helper.rb",
243
+ "test/version/tc_iqqueryversion.rb",
244
+ "test/xhtml/tc_html.rb",
245
+ "tools/gen_requires.bash",
246
+ "tools/xmpp4r-gemspec-test.rb",
247
+ "xmpp4r.gemspec"
248
+ ]
249
+ end