xmpp4r 0.3.2 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/{ChangeLog → CHANGELOG} +33 -0
  2. data/LICENSE +9 -9
  3. data/README.rdoc +110 -0
  4. data/README_ruby19.txt +43 -0
  5. data/Rakefile +235 -74
  6. data/data/doc/xmpp4r/examples/advanced/adventure/README +0 -1
  7. data/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +1 -1
  8. data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +12 -12
  9. data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +10 -11
  10. data/data/doc/xmpp4r/examples/advanced/fileserve.rb +11 -11
  11. data/data/doc/xmpp4r/examples/advanced/getonline.rb +7 -7
  12. data/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +3 -3
  13. data/data/doc/xmpp4r/examples/advanced/migrate.rb +21 -22
  14. data/data/doc/xmpp4r/examples/advanced/minimuc.rb +22 -22
  15. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
  16. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
  17. data/data/doc/xmpp4r/examples/advanced/recvfile.rb +0 -1
  18. data/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +2 -3
  19. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +3 -3
  20. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +10 -10
  21. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +2 -2
  22. data/data/doc/xmpp4r/examples/advanced/versionpoll.rb +12 -12
  23. data/data/doc/xmpp4r/examples/advanced/xmpping.rb +2 -3
  24. data/data/doc/xmpp4r/examples/basic/change_password.rb +3 -3
  25. data/data/doc/xmpp4r/examples/basic/client.rb +5 -3
  26. data/data/doc/xmpp4r/examples/basic/component.rb +1 -1
  27. data/data/doc/xmpp4r/examples/basic/{echo_threaded.rb → echo.rb} +8 -7
  28. data/data/doc/xmpp4r/examples/basic/jabbersend.rb +5 -5
  29. data/data/doc/xmpp4r/examples/basic/mass_sender.rb +11 -11
  30. data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +0 -1
  31. data/data/doc/xmpp4r/examples/basic/mucinfo.rb +3 -1
  32. data/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +0 -1
  33. data/data/doc/xmpp4r/examples/basic/register.rb +21 -4
  34. data/data/doc/xmpp4r/examples/basic/roster.rb +7 -5
  35. data/data/doc/xmpp4r/examples/basic/rosterprint.rb +0 -0
  36. data/data/doc/xmpp4r/examples/basic/rosterrename.rb +2 -2
  37. data/data/doc/xmpp4r/examples/basic/rosterwatch.rb +6 -7
  38. data/data/doc/xmpp4r/examples/basic/send_vcard.rb +3 -4
  39. data/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
  40. data/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
  41. data/data/doc/xmpp4r/examples/basic/versionbot.rb +1 -1
  42. data/lib/xmpp4r.rb +4 -4
  43. data/lib/xmpp4r/base64.rb +32 -0
  44. data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +10 -11
  45. data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +6 -8
  46. data/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +3 -6
  47. data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +0 -1
  48. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +8 -11
  49. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +4 -7
  50. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +7 -3
  51. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +10 -5
  52. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +14 -4
  53. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig +62 -0
  54. data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +0 -1
  55. data/lib/xmpp4r/callbacks.rb +5 -5
  56. data/lib/xmpp4r/caps.rb +1 -0
  57. data/lib/xmpp4r/caps/c.rb +53 -0
  58. data/lib/xmpp4r/caps/helper/generator.rb +160 -0
  59. data/lib/xmpp4r/caps/helper/helper.rb +87 -0
  60. data/lib/xmpp4r/client.rb +111 -40
  61. data/lib/xmpp4r/command/iq/command.rb +1 -1
  62. data/lib/xmpp4r/component.rb +8 -8
  63. data/lib/xmpp4r/connection.rb +25 -9
  64. data/lib/xmpp4r/dataforms/x/data.rb +17 -5
  65. data/lib/xmpp4r/debuglog.rb +13 -5
  66. data/lib/xmpp4r/delay/x/delay.rb +1 -1
  67. data/lib/xmpp4r/discovery.rb +3 -2
  68. data/lib/xmpp4r/discovery/helper/responder.rb +165 -0
  69. data/lib/xmpp4r/discovery/iq/discoinfo.rb +11 -12
  70. data/lib/xmpp4r/discovery/iq/discoitems.rb +12 -4
  71. data/lib/xmpp4r/{error.rb → errors.rb} +66 -10
  72. data/lib/xmpp4r/framework/base.rb +55 -0
  73. data/lib/xmpp4r/framework/bot.rb +148 -0
  74. data/lib/xmpp4r/httpbinding/client.rb +1 -1
  75. data/lib/xmpp4r/idgenerator.rb +1 -1
  76. data/lib/xmpp4r/iq.rb +34 -23
  77. data/lib/xmpp4r/jid.rb +2 -2
  78. data/lib/xmpp4r/message.rb +1 -1
  79. data/lib/xmpp4r/muc.rb +2 -0
  80. data/lib/xmpp4r/muc/helper/mucbrowser.rb +4 -19
  81. data/lib/xmpp4r/muc/helper/mucclient.rb +54 -23
  82. data/lib/xmpp4r/muc/helper/simplemucclient.rb +107 -1
  83. data/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
  84. data/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
  85. data/lib/xmpp4r/muc/iq/mucowner.rb +5 -1
  86. data/lib/xmpp4r/muc/item.rb +143 -0
  87. data/lib/xmpp4r/muc/x/mucuserinvite.rb +2 -2
  88. data/lib/xmpp4r/muc/x/mucuseritem.rb +3 -117
  89. data/lib/xmpp4r/presence.rb +2 -1
  90. data/lib/xmpp4r/pubsub.rb +7 -0
  91. data/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
  92. data/lib/xmpp4r/pubsub/{stanzas → children}/event.rb +13 -13
  93. data/lib/xmpp4r/pubsub/{stanzas → children}/item.rb +9 -1
  94. data/lib/xmpp4r/pubsub/{stanzas → children}/items.rb +10 -1
  95. data/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
  96. data/lib/xmpp4r/pubsub/children/publish.rb +24 -0
  97. data/lib/xmpp4r/pubsub/{stanzas → children}/subscription.rb +16 -12
  98. data/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
  99. data/lib/xmpp4r/pubsub/children/unsubscribe.rb +48 -0
  100. data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +49 -93
  101. data/lib/xmpp4r/pubsub/helper/nodehelper.rb +39 -36
  102. data/lib/xmpp4r/pubsub/helper/servicehelper.rb +253 -162
  103. data/lib/xmpp4r/pubsub/iq/pubsub.rb +1 -1
  104. data/lib/xmpp4r/rexmladdons.rb +56 -28
  105. data/lib/xmpp4r/roster.rb +0 -1
  106. data/lib/xmpp4r/roster/helper/roster.rb +26 -15
  107. data/lib/xmpp4r/roster/iq/roster.rb +19 -19
  108. data/lib/xmpp4r/roster/x/roster.rb +10 -10
  109. data/lib/xmpp4r/rpc/helper/client.rb +17 -8
  110. data/lib/xmpp4r/rpc/helper/server.rb +1 -2
  111. data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +14 -4
  112. data/lib/xmpp4r/rpc/iq/rpc.rb +0 -1
  113. data/lib/xmpp4r/sasl.rb +27 -6
  114. data/lib/xmpp4r/stream.rb +39 -44
  115. data/lib/xmpp4r/streamparser.rb +4 -4
  116. data/lib/xmpp4r/tune.rb +2 -0
  117. data/lib/xmpp4r/tune/helper/helper.rb +58 -0
  118. data/lib/xmpp4r/tune/tune.rb +113 -0
  119. data/lib/xmpp4r/vcard.rb +0 -1
  120. data/lib/xmpp4r/vcard/helper/vcard.rb +1 -3
  121. data/lib/xmpp4r/vcard/iq/vcard.rb +14 -0
  122. data/lib/xmpp4r/version/iq/version.rb +0 -1
  123. data/lib/xmpp4r/x.rb +1 -1
  124. data/lib/xmpp4r/xhtml.rb +1 -0
  125. data/lib/xmpp4r/xhtml/html.rb +115 -0
  126. data/lib/xmpp4r/xmpp4r.rb +7 -5
  127. data/lib/xmpp4r/xmppelement.rb +21 -5
  128. data/lib/xmpp4r/xmppstanza.rb +6 -6
  129. data/setup.rb +4 -4
  130. data/test/bytestreams/tc_ibb.rb +2 -2
  131. data/test/bytestreams/tc_socks5bytestreams.rb +12 -2
  132. data/test/caps/tc_helper.rb +156 -0
  133. data/test/dataforms/tc_data.rb +0 -0
  134. data/test/delay/tc_xdelay.rb +2 -2
  135. data/test/discovery/tc_responder.rb +91 -0
  136. data/test/lib/assert_equal_xml.rb +14 -0
  137. data/test/lib/clienttester.rb +31 -24
  138. data/test/muc/tc_muc_mucclient.rb +249 -13
  139. data/test/muc/tc_muc_simplemucclient.rb +41 -2
  140. data/test/muc/tc_mucowner.rb +0 -0
  141. data/test/pubsub/tc_helper.rb +486 -51
  142. data/test/pubsub/tc_nodeconfig.rb +54 -0
  143. data/test/pubsub/tc_subscriptionconfig.rb +41 -0
  144. data/test/roster/tc_helper.rb +6 -7
  145. data/test/roster/tc_iqqueryroster.rb +16 -16
  146. data/test/roster/tc_xroster.rb +1 -1
  147. data/test/rpc/tc_helper.rb +15 -3
  148. data/test/tc_callbacks.rb +7 -7
  149. data/test/tc_class_names.rb +15 -6
  150. data/test/tc_client.rb +3 -3
  151. data/test/{tc_error.rb → tc_errors.rb} +54 -12
  152. data/test/tc_idgenerator.rb +0 -0
  153. data/test/tc_iq.rb +32 -29
  154. data/test/tc_iqquery.rb +2 -2
  155. data/test/tc_jid.rb +44 -42
  156. data/test/tc_message.rb +13 -12
  157. data/test/tc_presence.rb +25 -24
  158. data/test/tc_rexml.rb +81 -2
  159. data/test/tc_stream.rb +15 -13
  160. data/test/tc_streamComponent.rb +6 -5
  161. data/test/tc_streamError.rb +21 -15
  162. data/test/tc_streamSend.rb +9 -9
  163. data/test/tc_streamparser.rb +112 -0
  164. data/test/tc_xmppstanza.rb +19 -9
  165. data/test/ts_xmpp4r.rb +10 -1
  166. data/test/tune/tc_helper_recv.rb +84 -0
  167. data/test/tune/tc_helper_send.rb +74 -0
  168. data/test/tune/tc_tune.rb +79 -0
  169. data/test/vcard/tc_helper.rb +2 -2
  170. data/test/vcard/tc_iqvcard.rb +13 -3
  171. data/test/version/tc_helper.rb +2 -2
  172. data/test/version/tc_iqqueryversion.rb +10 -10
  173. data/test/xhtml/tc_html.rb +41 -0
  174. data/tools/gen_requires.bash +29 -8
  175. data/tools/xmpp4r-gemspec-test.rb +11 -0
  176. data/xmpp4r.gemspec +291 -0
  177. metadata +277 -218
  178. data/README +0 -28
  179. data/UPDATING +0 -40
  180. data/data/doc/xmpp4r/examples/buggy/jabber2jabber/jabber2jabber.rb +0 -18
  181. data/data/doc/xmpp4r/examples/buggy/miniedgarr_cgi.rb +0 -192
  182. data/data/doc/xmpp4r/examples/buggy/miniedgarr_watch.rb +0 -82
  183. data/lib/xmpp4r/authenticationfailure.rb +0 -13
  184. data/lib/xmpp4r/errorexception.rb +0 -32
  185. data/tools/doctoweb.bash +0 -30
@@ -1,3 +1,35 @@
1
+ XMPP4R 0.4 (05/08/2008)
2
+ =======================
3
+ * Initial support for Ruby 1.9 (see README_ruby19.txt)
4
+ * Complete PubSub API Change - more logical and better for
5
+ childclasses, support for collection node creation
6
+ * a Helper to assist with XEP-0115 Entity Capabilities
7
+ * SASL anonymous support
8
+ * File transfer fixes
9
+ * MUC room configuration fixes
10
+ * initial support for XEP-0118 User Tune
11
+ * fix for an xmlrpc exception-during-serialisation bug, which would cause
12
+ a hang
13
+ * Support auto-gem generation on GitHub with improved and DRY'er RakeFile and
14
+ gemspec.
15
+ * Add support for the old SSL protocol (needed to connect to GTalk)
16
+ * Changed API for Client, Component, Connection, Stream to remove
17
+ need for antiquated 'threaded' param in the initializer.
18
+ * Use a Logger instance instead of directly writing to stdout
19
+ * Re-factored & consolidated Error classes. See xmpp4r/errors.rb for all
20
+ custom errors that can be caught. All inherit from Jabber::Error which
21
+ itself inherits from Ruby's StandardError. This is a first step in
22
+ re-factoring errors. The next step will be to convert all 'raise' calls to
23
+ raise a custom Jabber::Error or one of its children instead of anonymous
24
+ RuntimeErrors. This allows much more granularity in catching and handling
25
+ errors later.
26
+ If you were catching Jabber::ErrorException before you should probably
27
+ change that in your code to now catch Jabber::Error if you want to
28
+ catch everything or one of the custom children of Jabber::Error defined in
29
+ 'lib/xmpp4r/errors.rb'. Additionally, the Error class which encapsulated
30
+ the xmpp error response, has been renamed to ErrorResponse to reflect its
31
+ real usage. This free's up 'Jabber::Error' for use as our base Error class.
32
+
1
33
  XMPP4R 0.3.2 (15/10/2007)
2
34
  =========================
3
35
  * Serious bug involving Ruby threading fixed (caused exceptions with
@@ -48,3 +80,4 @@ XMPP4R 0.2 (20/10/2005)
48
80
  XMPP4R 0.1 (12/09/2005)
49
81
  =======================
50
82
  * first public release.
83
+
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  XMPP4R is copyrighted free software by Lucas Nussbaum
2
- <lucas@lucas-nussbaum.net>, Stephan Maka <astro@spaceboyz.net>, and others.
2
+ <lucas@lucas-nussbaum.net>, Stephan Maka <stephan@spaceboyz.net>, and others.
3
3
  You can redistribute it and/or modify it under either the terms of the GPL (see
4
4
  COPYING file), or the conditions below:
5
5
 
@@ -12,14 +12,14 @@ COPYING file), or the conditions below:
12
12
 
13
13
  a) place your modifications in the Public Domain or otherwise
14
14
  make them Freely Available, such as by posting said
15
- modifications to Usenet or an equivalent medium, or by allowing
16
- the author to include your modifications in the software.
15
+ modifications to Usenet or an equivalent medium, or by allowing
16
+ the author to include your modifications in the software.
17
17
 
18
18
  b) use the modified software only within your corporation or
19
19
  organization.
20
20
 
21
21
  c) rename any non-standard executables so the names do not conflict
22
- with standard executables, which must also be provided.
22
+ with standard executables, which must also be provided.
23
23
 
24
24
  d) make other distribution arrangements with the author.
25
25
 
@@ -27,11 +27,11 @@ COPYING file), or the conditions below:
27
27
  form, provided that you do at least ONE of the following:
28
28
 
29
29
  a) distribute the executables and library files of the software,
30
- together with instructions (in the manual page or equivalent)
31
- on where to get the original distribution.
30
+ together with instructions (in the manual page or equivalent)
31
+ on where to get the original distribution.
32
32
 
33
33
  b) accompany the distribution with the machine-readable source of
34
- the software.
34
+ the software.
35
35
 
36
36
  c) give non-standard executables non-standard names, with
37
37
  instructions on where to get the original software distribution.
@@ -46,9 +46,9 @@ COPYING file), or the conditions below:
46
46
  files under the ./missing directory. See each file for the copying
47
47
  condition.
48
48
 
49
- 5. The scripts and library files supplied as input to or produced as
49
+ 5. The scripts and library files supplied as input to or produced as
50
50
  output from the software do not automatically fall under the
51
- copyright of the software, but belong to whomever generated them,
51
+ copyright of the software, but belong to whomever generated them,
52
52
  and may be sold commercially, and may be aggregated with this
53
53
  software.
54
54
 
@@ -0,0 +1,110 @@
1
+ = XMPP4R
2
+
3
+ == Project Home
4
+
5
+ You can find info about the xmpp4r project and how to contribute
6
+ at the project home page:
7
+
8
+ http://home.gna.org/xmpp4r/
9
+
10
+ If you need to ask questions, or want feedback on proposed changes
11
+ please feel free to ask them on the 'xmpp4r-devel@gna.org' mailing
12
+ list. You can join or view archives of the mailing list at:
13
+
14
+ https://gna.org/mail/?group=xmpp4r
15
+
16
+ If you are having a problem and would like to report it
17
+ to the mailing list please include a protocol dump
18
+ which can be enabled in your code with:
19
+
20
+ Jabber::debug = true
21
+
22
+
23
+ == Contributors
24
+
25
+ Lucas Nussbaum <lucas@lucas-nussbaum.net>
26
+ Stephan Maka <stephan@spaceboyz.net>
27
+ Kirill A. Shutemov <k.shutemov@gmail.com>
28
+ Yuki Mitsui
29
+ Peter Schrammel
30
+ Olli
31
+ Vojtech Vobr
32
+ Andreas Wiese
33
+ Chris Zelenak
34
+ Matthew Wood
35
+ Sam Ruby
36
+ Glenn Rempe <glenn@rempe.us>
37
+ Tim Carey-Smith
38
+ Scott Lillibridge
39
+ Joshua Sierles
40
+
41
+
42
+ == Source Code
43
+
44
+ The source for xmpp4r is managed using the Git SCM and can be
45
+ found in our GitHub.com project page:
46
+
47
+ http://github.com/ln/xmpp4r/tree/master
48
+
49
+
50
+ == Installation
51
+
52
+ There are a number of ways that you can install xmpp4r depending
53
+ on your needs and the methods you prefer.
54
+
55
+ === Install over the network using RubyGems
56
+
57
+ You can install the current release of the xmpp4r library from a stable
58
+ release gem on RubyForge using RubyGems:
59
+
60
+ sudo gem install xmpp4r
61
+
62
+ === Install over the network using a Debian package
63
+
64
+ You can install the current release of the xmpp4r library from a stable release copy
65
+ on your .deb friendly linux system (e.g. Debian or Ubuntu) using apt:
66
+
67
+ sudo apt-get install libxmpp4r-ruby
68
+
69
+ === Install from local source code (Developers Only)
70
+
71
+ If you have a local Git clone of the source repository or a tarball
72
+ you can install xmpp4r using several methods. First you'll
73
+ need to get a local copy.
74
+
75
+ Clone the Git repository (recommended):
76
+
77
+ git clone git://github.com/ln/xmpp4r.git
78
+
79
+ OR download a stable release tarball from:
80
+
81
+ http://download.gna.org/xmpp4r/xmpp4r-0.3.2.tgz
82
+
83
+ OR download a snapshot of the latest source in .tar.gz format from:
84
+
85
+ http://github.com/ln/xmpp4r/tarball/master
86
+
87
+ ==== Install : Using Rake
88
+
89
+ # Show all available rake tasks
90
+ cd xmpp4r/
91
+ rake -T
92
+
93
+ # Package up the gem file and install it
94
+ rake gem:install
95
+
96
+ ==== Install : Using setup.rb
97
+
98
+ This will install a copy of the library in your Ruby path and does not
99
+ require RubyGems to be installed.
100
+
101
+ cd xmpp4r/
102
+ ./setup.rb
103
+
104
+
105
+ == License
106
+
107
+ XMPP4R is released under the Ruby license (see the LICENSE file), which is
108
+ compatible with the GNU GPL (see the COPYING file) via an explicit
109
+ dual-licensing clause.
110
+
@@ -0,0 +1,43 @@
1
+ Ruby 1.9 is a development release in anticipation of Ruby 2.0, which has
2
+ overall better performance, real threading, and character encoding support.
3
+ Note: Ruby 1.9 is a development release, meaning that everything is
4
+ subject to change without prior notice. Among other things, this means
5
+ that xmpp4r could stop working on Ruby 1.9 at any time.
6
+
7
+ This version of xmpp4r has made a number of internal changes (nothing visible
8
+ at the API) to remove depency on deprecated Ruby Kernel APIs, support the new
9
+ encoding APIs, etc.
10
+
11
+ At the present time, all tests pass except tc_helper.rb and tc_stream.rb.
12
+ These tests themselves make assumptions about timinings of events,
13
+ assumptions that are not guaranteed with true multi-tasking. Initial
14
+ analysis indicates that xmpp4r is operating correctly, it is the tests
15
+ themselves that need to be corrected, but this could turn out to be
16
+ incorrect.
17
+
18
+ The executing of these two tests are disabled by a check in ts_xmpp4r.rb,
19
+ which is marked as a TODO.
20
+
21
+ A specific example: test_bidi in test/tc_stream.rb defines two threads,
22
+ one pumps out requests, the other echoes them. The receiver then verifies
23
+ that it gets back what it sent. With Ruby 1.8, these threads tend to
24
+ alternate in lock step, and the test usually passes. What happens in Ruby 1.9
25
+ is that the first thread waits for a message, and the second one creates a
26
+ callback block, generates a message, and then proceeds on to create a second
27
+ callback block -- even before the first message has been responded to.
28
+ The way xmpp4r works is that callbacks are saved on a pushdown stack.
29
+
30
+ The net result is that the first response typically is processed first by
31
+ the second callback, which decides that the ids don't match, and the test fails.
32
+
33
+ The way it is supposed to work is that the reply callback is supposed to
34
+ only process requests destined for it (and return true) and ignore
35
+ everything else (returning false).
36
+
37
+ This is but one test. Many of the tests in these two files are of this
38
+ nature.
39
+
40
+ The current status of the tests that are expected to pass on Ruby 1.9
41
+ can generally be found here:
42
+
43
+ http://intertwingly.net/projects/ruby19/logs/xmpp4r.html
data/Rakefile CHANGED
@@ -1,101 +1,262 @@
1
+ require 'rake'
2
+ require "rake/clean"
1
3
  require 'rake/testtask'
2
- require 'rake/packagetask'
3
4
  require 'rake/rdoctask'
4
- require 'rake'
5
- require 'find'
6
5
 
7
- begin
8
- require 'rubygems'
9
- require 'rcov/rcovtask'
10
- RCOV = true
11
- rescue LoadError
12
- RCOV = false
13
- end
6
+ $:.unshift 'lib'
7
+ require "xmpp4r"
14
8
 
9
+ ##############################################################################
10
+ # OPTIONS
11
+ ##############################################################################
15
12
 
16
- # Globals
13
+ PKG_NAME = 'xmpp4r'
14
+ PKG_VERSION = Jabber::XMPP4R_VERSION
15
+ AUTHORS = ['Lucas Nussbaum', 'Stephan Maka', 'Glenn Rempe']
16
+ EMAIL = "xmpp4r-devel@gna.org"
17
+ HOMEPAGE = "http://home.gna.org/xmpp4r/"
18
+ SUMMARY = "XMPP4R is an XMPP/Jabber library for Ruby."
17
19
 
18
- PKG_NAME = 'xmpp4r'
19
- PKG_VERSION = '0.3.2'
20
+ # These are the common rdoc options that are shared between generation of
21
+ # rdoc files using BOTH 'rake rdoc' and the installation by users of a
22
+ # RubyGem version which builds rdoc's along with its installation. Any
23
+ # rdoc options that are ONLY for developers running 'rake rdoc' should be
24
+ # added in the 'Rake::RDocTask' block below.
25
+ RDOC_OPTIONS = [
26
+ "--quiet",
27
+ "--title", SUMMARY,
28
+ "--opname", "index.html",
29
+ "--main", "lib/xmpp4r.rb",
30
+ "--line-numbers",
31
+ "--inline-source"
32
+ ]
20
33
 
21
- PKG_FILES = ['ChangeLog', 'README', 'COPYING', 'LICENSE', 'setup.rb', 'Rakefile', 'UPDATING']
22
- Find.find('lib/', 'data/', 'test/', 'tools/') do |f|
23
- if FileTest.directory?(f) and f =~ /\.svn/
24
- Find.prune
25
- else
26
- PKG_FILES << f
27
- end
28
- end
34
+ # Extra files outside of the lib dir that should be included with the rdocs.
35
+ RDOC_FILES = %w( README.rdoc README_ruby19.txt CHANGELOG LICENSE COPYING )
29
36
 
37
+ # The full file list used for rdocs, tarballs, gems, and for generating the xmpp4r.gemspec.
38
+ PKG_FILES = %w( Rakefile setup.rb xmpp4r.gemspec ) + RDOC_FILES + Dir["{lib,test,data,tools}/**/*"]
30
39
 
31
- # Tasks
40
+ ##############################################################################
41
+ # DEFAULT TASK
42
+ ##############################################################################
32
43
 
33
- task :default => [:package]
44
+ # The task that will run when a simple 'rake' command is issued.
45
+ # Default to running the test suite as that's a nice safe command
46
+ # we should run frequently.
47
+ task :default => [:test]
48
+
49
+ ##############################################################################
50
+ # TESTING TASKS
51
+ ##############################################################################
34
52
 
35
53
  Rake::TestTask.new do |t|
36
- t.libs << "test"
37
- t.test_files = ['test/ts_xmpp4r.rb']
54
+ t.libs << "test"
55
+ t.test_files = ['test/ts_xmpp4r.rb']
38
56
  end
39
57
 
58
+ ##############################################################################
59
+ # DOCUMENTATION TASKS
60
+ ##############################################################################
61
+
62
+ # RDOC
63
+ #######
40
64
  Rake::RDocTask.new do |rd|
41
- f = []
42
- require 'find'
43
- Find.find('lib/') do |file|
44
- # Skip hidden files (.svn/ directories and Vim swapfiles)
45
- if file.split(/\//).last =~ /^\./
46
- Find.prune
47
- else
48
- f << file if not FileTest.directory?(file)
49
- end
50
- end
51
- f.delete('lib/xmpp4r.rb')
52
- # hack to document the Jabber module properly
53
- f.unshift('lib/xmpp4r.rb')
54
- rd.rdoc_files.include(f)
55
- rd.options << '--all'
56
- rd.options << '--diagram'
57
- rd.options << '--fileboxes'
58
- rd.options << '--inline-source'
59
- rd.options << '--line-numbers'
65
+
66
+ # which dir should rdoc files be installed in?
60
67
  rd.rdoc_dir = 'rdoc'
68
+
69
+ # the full list of files to be included
70
+ rd.rdoc_files.include(RDOC_FILES, "lib/**/*.rb")
71
+
72
+ # the full list of options that are common between gem build
73
+ # and 'rake rdoc' build of docs.
74
+ rd.options = RDOC_OPTIONS
75
+
76
+ # Devs Only : Uncomment to also document private methods in the rdocs
77
+ # Please don't check this change in to the source repo.
78
+ #rd.options << '--all'
79
+
80
+ # Devs Only : Uncomment to generate dot (graphviz) diagrams along with rdocs.
81
+ # This requires that graphiz (dot) be installed as a local binary and on your path.
82
+ # See : http://www.graphviz.org/
83
+ # Please don't check this change in to the source repo as it introduces a binary dependency.
84
+ #rd.options << '--diagram'
85
+ #rd.options << '--fileboxes'
86
+
61
87
  end
62
88
 
63
- task :doctoweb => [:rdoc] do |t|
64
- # copies the rdoc to the CVS repository for xmpp4r website
65
- # repository is in $CVSDIR (default: ~/dev/xmpp4r-web)
66
- sh "tools/doctoweb.bash"
89
+
90
+ # RCOV
91
+ #######
92
+
93
+ # Conditional require rcov/rcovtask if present
94
+ begin
95
+ require 'rcov/rcovtask'
96
+
97
+ Rcov::RcovTask.new do |t|
98
+ t.test_files = ['test/ts_xmpp4r.rb']
99
+ t.output_dir = "coverage"
100
+ end
101
+ rescue Object
67
102
  end
68
103
 
69
- Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
70
- p.need_tar = true
71
- p.package_files = PKG_FILES
104
+ # DOT GRAPH
105
+ ############
106
+ desc "Generate requires graph"
107
+ task :gen_requires_graph do
108
+ sh %{cd tools; ./gen_requires.bash}
72
109
  end
73
110
 
74
- if RCOV
75
- Rcov::RcovTask.new do |t|
76
- t.test_files = ['test/ts_xmpp4r.rb']
77
- end
111
+ # UPDATE WEBSITE (for Lucas only)
112
+ #################################
113
+ desc "Update website (for Lucas only)"
114
+ task :update_website do
115
+ sh %{cp website/* ~/dev/xmpp4r/website/ && cd ~/dev/xmpp4r/website/ && svn commit -m "website update"}
116
+ end
117
+
118
+
119
+ ##############################################################################
120
+ # SYNTAX CHECKING
121
+ ##############################################################################
122
+
123
+ desc "Check syntax of all Ruby files."
124
+ task :check_syntax do
125
+ `find . -name "*.rb" |xargs -n1 ruby -c |grep -v "Syntax OK"`
126
+ puts "* Done"
78
127
  end
79
128
 
80
- # "Gem" part of the Rakefile
129
+ ##############################################################################
130
+ # PACKAGING & INSTALLATION
131
+ ##############################################################################
132
+
133
+ # What files/dirs should 'rake clean' remove?
134
+ CLEAN.include ["*.gem", "pkg", "rdoc", "coverage", "tools/*.png"]
135
+
136
+ # Flag for RubyGems installation used to add rake package tasks conditionally.
137
+ # Full gem + tarball on systems with RubyGems. More limited on systems without.
138
+ @rubygems = nil
139
+
81
140
  begin
82
- require 'rake/gempackagetask'
83
-
84
- spec = Gem::Specification.new do |s|
85
- s.platform = Gem::Platform::RUBY
86
- s.summary = "Ruby library for Jabber Instant-Messaging"
87
- s.name = PKG_NAME
88
- s.version = PKG_VERSION
89
- s.requirements << 'none'
90
- s.require_path = 'lib'
91
- s.autorequire = 'xmpp4r'
92
- s.files = PKG_FILES
93
- s.description = "Ruby library for Jabber Instant-Messaging"
94
- end
95
-
96
- Rake::GemPackageTask.new(spec) do |pkg|
97
- pkg.need_zip = true
98
- pkg.need_tar = true
99
- end
141
+ require 'rake/gempackagetask'
142
+
143
+ # RubyGems is installed, known since require 'rake/gempackagetask' succeeded.
144
+ @rubygems = true
145
+
146
+ spec = Gem::Specification.new do |s|
147
+ s.name = PKG_NAME
148
+ s.version = PKG_VERSION
149
+ s.authors = AUTHORS
150
+ s.email = EMAIL
151
+ s.homepage = HOMEPAGE
152
+ s.rubyforge_project = PKG_NAME
153
+ s.summary = SUMMARY
154
+ s.description = s.summary
155
+ s.platform = Gem::Platform::RUBY
156
+ s.require_path = 'lib'
157
+ s.executables = []
158
+ s.files = PKG_FILES
159
+ s.test_files = []
160
+ s.has_rdoc = true
161
+ s.extra_rdoc_files = RDOC_FILES
162
+ s.rdoc_options = RDOC_OPTIONS
163
+ s.required_ruby_version = ">= 1.8.4"
164
+ end
165
+
166
+ Rake::GemPackageTask.new(spec) do |pkg|
167
+ pkg.gem_spec = spec
168
+ pkg.need_tar = true
169
+ end
170
+
171
+ namespace :gem do
172
+
173
+ desc "Run :package and install the .gem locally"
174
+ task :install => [:update_gemspec, :package] do
175
+ sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem}
176
+ end
177
+
178
+ desc "Like gem:install but without ri or rdocs"
179
+ task :install_fast => [:update_gemspec, :package] do
180
+ sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem --no-rdoc --no-ri}
181
+ end
182
+
183
+ desc "Run :clean and uninstall the .gem"
184
+ task :uninstall => :clean do
185
+ sh %{sudo gem uninstall #{PKG_NAME}}
186
+ end
187
+
188
+ # Thanks to the Merb project for this code.
189
+ desc "Update Github Gemspec"
190
+ task :update_gemspec do
191
+ skip_fields = %w(new_platform original_platform date)
192
+ integer_fields = %w(specification_version)
193
+
194
+ result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
195
+ result << "# RUN : 'rake gem:update_gemspec'\n\n"
196
+ result << "Gem::Specification.new do |s|\n"
197
+ spec.instance_variables.each do |ivar|
198
+ value = spec.instance_variable_get(ivar)
199
+ name = ivar.split("@").last
200
+ next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
201
+ if name == "dependencies"
202
+ value.each do |d|
203
+ dep, *ver = d.to_s.split(" ")
204
+ result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "")}\n"
205
+ end
206
+ else
207
+ case value
208
+ when Array
209
+ value = name != "files" ? value.inspect : value.sort.uniq.inspect.split(",").join(",\n")
210
+ when String
211
+ value = value.to_i if integer_fields.include?(name)
212
+ value = value.inspect
213
+ else
214
+ value = value.to_s.inspect
215
+ end
216
+ result << " s.#{name} = #{value}\n"
217
+ end
218
+ end
219
+ result << "end"
220
+ File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
221
+ end
222
+
223
+ end # namespace :gem
224
+
225
+ # also keep the gemspec up to date each time we package a tarball or gem
226
+ task :package => ['gem:update_gemspec']
227
+ task :gem => ['gem:update_gemspec']
228
+
100
229
  rescue LoadError
230
+ @rubygems = false
231
+ warning = <<EOF
232
+ ###
233
+ Packaging Warning : RubyGems is apparently not installed on this
234
+ system and any file add/remove/rename will not
235
+ be auto-updated in the 'xmpp4r.gemspec' when you run any
236
+ package tasks. All such file changes are recommended
237
+ to be packaged on a system with RubyGems installed
238
+ if you intend to push commits to the Git repo so the
239
+ gemspec will also stay in sync for others.
240
+ ###
241
+ EOF
242
+ puts warning
243
+ end
244
+
245
+ # we are apparently on a system that does not have RubyGems installed.
246
+ # Lets try to provide only the basic tarball package tasks as a fallback.
247
+ if @rubygems == false
248
+ begin
249
+ require 'rake/packagetask'
250
+ Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
251
+ p.package_files = PKG_FILES
252
+ p.need_tar = true
253
+ end
254
+ rescue LoadError
255
+ warning = <<EOF
256
+ ###
257
+ Warning : Unable to require the 'rake/packagetask'. Is Rake installed?
258
+ ###
259
+ EOF
260
+ puts warning
261
+ end
101
262
  end