mojodna-xmpp4r 0.4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +83 -0
- data/COPYING +340 -0
- data/LICENSE +59 -0
- data/README.rdoc +133 -0
- data/README_ruby19.txt +43 -0
- data/Rakefile +252 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/README +56 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +23 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +136 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/cube.xml +15 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/tower.xml +69 -0
- data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +424 -0
- data/data/doc/xmpp4r/examples/advanced/fileserve.conf +11 -0
- data/data/doc/xmpp4r/examples/advanced/fileserve.rb +346 -0
- data/data/doc/xmpp4r/examples/advanced/getonline.rb +56 -0
- data/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +315 -0
- data/data/doc/xmpp4r/examples/advanced/migrate.rb +88 -0
- data/data/doc/xmpp4r/examples/advanced/minimuc.rb +266 -0
- data/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
- data/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
- data/data/doc/xmpp4r/examples/advanced/recvfile.rb +84 -0
- data/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +129 -0
- data/data/doc/xmpp4r/examples/advanced/sendfile.conf +10 -0
- data/data/doc/xmpp4r/examples/advanced/sendfile.rb +72 -0
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +51 -0
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +43 -0
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +10 -0
- data/data/doc/xmpp4r/examples/advanced/versionpoll.rb +109 -0
- data/data/doc/xmpp4r/examples/advanced/xmpping.rb +146 -0
- data/data/doc/xmpp4r/examples/advanced/xmppingrc.sample +14 -0
- data/data/doc/xmpp4r/examples/basic/change_password.rb +41 -0
- data/data/doc/xmpp4r/examples/basic/client.rb +70 -0
- data/data/doc/xmpp4r/examples/basic/component.rb +11 -0
- data/data/doc/xmpp4r/examples/basic/echo.rb +37 -0
- data/data/doc/xmpp4r/examples/basic/jabbersend.rb +41 -0
- data/data/doc/xmpp4r/examples/basic/mass_sender.rb +68 -0
- data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +12 -0
- data/data/doc/xmpp4r/examples/basic/mucinfo.rb +41 -0
- data/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +82 -0
- data/data/doc/xmpp4r/examples/basic/register.rb +42 -0
- data/data/doc/xmpp4r/examples/basic/remove_registration.rb +18 -0
- data/data/doc/xmpp4r/examples/basic/roster.rb +44 -0
- data/data/doc/xmpp4r/examples/basic/rosterprint.rb +50 -0
- data/data/doc/xmpp4r/examples/basic/rosterrename.rb +34 -0
- data/data/doc/xmpp4r/examples/basic/rosterwatch.rb +171 -0
- data/data/doc/xmpp4r/examples/basic/send_vcard.rb +67 -0
- data/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
- data/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
- data/data/doc/xmpp4r/examples/basic/versionbot.rb +75 -0
- data/lib/xmpp4r/base64.rb +32 -0
- data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +319 -0
- data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +257 -0
- data/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +31 -0
- data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +47 -0
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +152 -0
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +86 -0
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +198 -0
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +65 -0
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +73 -0
- data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +170 -0
- data/lib/xmpp4r/bytestreams/iq/si.rb +206 -0
- data/lib/xmpp4r/bytestreams.rb +15 -0
- data/lib/xmpp4r/callbacks.rb +133 -0
- data/lib/xmpp4r/caps/c.rb +67 -0
- data/lib/xmpp4r/caps/helper/generator.rb +160 -0
- data/lib/xmpp4r/caps/helper/helper.rb +87 -0
- data/lib/xmpp4r/caps.rb +1 -0
- data/lib/xmpp4r/client.rb +344 -0
- data/lib/xmpp4r/command/helper/responder.rb +53 -0
- data/lib/xmpp4r/command/iq/command.rb +154 -0
- data/lib/xmpp4r/component.rb +103 -0
- data/lib/xmpp4r/connection.rb +219 -0
- data/lib/xmpp4r/dataforms/x/data.rb +297 -0
- data/lib/xmpp4r/dataforms.rb +5 -0
- data/lib/xmpp4r/debuglog.rb +42 -0
- data/lib/xmpp4r/delay/x/delay.rb +99 -0
- data/lib/xmpp4r/delay.rb +5 -0
- data/lib/xmpp4r/discovery/helper/helper.rb +58 -0
- data/lib/xmpp4r/discovery/helper/responder.rb +165 -0
- data/lib/xmpp4r/discovery/iq/discoinfo.rb +211 -0
- data/lib/xmpp4r/discovery/iq/discoitems.rb +147 -0
- data/lib/xmpp4r/discovery.rb +8 -0
- data/lib/xmpp4r/errors.rb +283 -0
- data/lib/xmpp4r/feature_negotiation/iq/feature.rb +28 -0
- data/lib/xmpp4r/feature_negotiation.rb +5 -0
- data/lib/xmpp4r/framework/base.rb +55 -0
- data/lib/xmpp4r/framework/bot.rb +148 -0
- data/lib/xmpp4r/httpbinding/client.rb +275 -0
- data/lib/xmpp4r/httpbinding.rb +5 -0
- data/lib/xmpp4r/idgenerator.rb +37 -0
- data/lib/xmpp4r/iq.rb +221 -0
- data/lib/xmpp4r/jid.rb +167 -0
- data/lib/xmpp4r/last/helper/helper.rb +37 -0
- data/lib/xmpp4r/last/iq/last.rb +67 -0
- data/lib/xmpp4r/last.rb +2 -0
- data/lib/xmpp4r/location/helper/helper.rb +56 -0
- data/lib/xmpp4r/location/location.rb +179 -0
- data/lib/xmpp4r/location.rb +2 -0
- data/lib/xmpp4r/message.rb +181 -0
- data/lib/xmpp4r/muc/helper/mucbrowser.rb +92 -0
- data/lib/xmpp4r/muc/helper/mucclient.rb +462 -0
- data/lib/xmpp4r/muc/helper/simplemucclient.rb +332 -0
- data/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
- data/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
- data/lib/xmpp4r/muc/iq/mucowner.rb +15 -0
- data/lib/xmpp4r/muc/item.rb +143 -0
- data/lib/xmpp4r/muc/x/muc.rb +70 -0
- data/lib/xmpp4r/muc/x/mucuserinvite.rb +60 -0
- data/lib/xmpp4r/muc/x/mucuseritem.rb +36 -0
- data/lib/xmpp4r/muc.rb +14 -0
- data/lib/xmpp4r/presence.rb +232 -0
- data/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
- data/lib/xmpp4r/pubsub/children/event.rb +49 -0
- data/lib/xmpp4r/pubsub/children/item.rb +35 -0
- data/lib/xmpp4r/pubsub/children/items.rb +53 -0
- data/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
- data/lib/xmpp4r/pubsub/children/publish.rb +38 -0
- data/lib/xmpp4r/pubsub/children/retract.rb +41 -0
- data/lib/xmpp4r/pubsub/children/subscription.rb +62 -0
- data/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
- data/lib/xmpp4r/pubsub/children/unsubscribe.rb +48 -0
- data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +130 -0
- data/lib/xmpp4r/pubsub/helper/nodehelper.rb +156 -0
- data/lib/xmpp4r/pubsub/helper/oauth_service_helper.rb +107 -0
- data/lib/xmpp4r/pubsub/helper/servicehelper.rb +456 -0
- data/lib/xmpp4r/pubsub/iq/pubsub.rb +19 -0
- data/lib/xmpp4r/pubsub.rb +8 -0
- data/lib/xmpp4r/query.rb +15 -0
- data/lib/xmpp4r/rexmladdons.rb +157 -0
- data/lib/xmpp4r/roster/helper/roster.rb +519 -0
- data/lib/xmpp4r/roster/iq/roster.rb +215 -0
- data/lib/xmpp4r/roster/x/roster.rb +138 -0
- data/lib/xmpp4r/roster.rb +7 -0
- data/lib/xmpp4r/rpc/helper/client.rb +123 -0
- data/lib/xmpp4r/rpc/helper/server.rb +74 -0
- data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +67 -0
- data/lib/xmpp4r/rpc/iq/rpc.rb +23 -0
- data/lib/xmpp4r/rpc.rb +2 -0
- data/lib/xmpp4r/sasl.rb +243 -0
- data/lib/xmpp4r/semaphore.rb +38 -0
- data/lib/xmpp4r/stream.rb +531 -0
- data/lib/xmpp4r/streamparser.rb +81 -0
- data/lib/xmpp4r/tune/helper/helper.rb +58 -0
- data/lib/xmpp4r/tune/tune.rb +113 -0
- data/lib/xmpp4r/tune.rb +2 -0
- data/lib/xmpp4r/vcard/helper/vcard.rb +84 -0
- data/lib/xmpp4r/vcard/iq/vcard.rb +109 -0
- data/lib/xmpp4r/vcard.rb +6 -0
- data/lib/xmpp4r/version/helper/responder.rb +72 -0
- data/lib/xmpp4r/version/helper/simpleresponder.rb +44 -0
- data/lib/xmpp4r/version/iq/version.rb +105 -0
- data/lib/xmpp4r/version.rb +7 -0
- data/lib/xmpp4r/x.rb +37 -0
- data/lib/xmpp4r/xhtml/html.rb +115 -0
- data/lib/xmpp4r/xhtml.rb +1 -0
- data/lib/xmpp4r/xmpp4r.rb +18 -0
- data/lib/xmpp4r/xmppelement.rb +168 -0
- data/lib/xmpp4r/xmppstanza.rb +162 -0
- data/lib/xmpp4r.rb +116 -0
- data/setup.rb +1586 -0
- data/test/bytestreams/tc_ibb.rb +186 -0
- data/test/bytestreams/tc_socks5bytestreams.rb +113 -0
- data/test/caps/tc_helper.rb +156 -0
- data/test/dataforms/tc_data.rb +81 -0
- data/test/delay/tc_xdelay.rb +51 -0
- data/test/discovery/tc_responder.rb +91 -0
- data/test/lib/assert_equal_xml.rb +14 -0
- data/test/lib/clienttester.rb +120 -0
- data/test/muc/tc_muc_mucclient.rb +830 -0
- data/test/muc/tc_muc_simplemucclient.rb +114 -0
- data/test/muc/tc_mucowner.rb +50 -0
- data/test/pubsub/tc_helper.rb +722 -0
- data/test/pubsub/tc_nodeconfig.rb +54 -0
- data/test/pubsub/tc_subscriptionconfig.rb +41 -0
- data/test/roster/tc_helper.rb +514 -0
- data/test/roster/tc_iqqueryroster.rb +173 -0
- data/test/roster/tc_xroster.rb +73 -0
- data/test/rpc/tc_helper.rb +96 -0
- data/test/tc_callbacks.rb +129 -0
- data/test/tc_class_names.rb +146 -0
- data/test/tc_client.rb +30 -0
- data/test/tc_errors.rb +146 -0
- data/test/tc_idgenerator.rb +30 -0
- data/test/tc_iq.rb +113 -0
- data/test/tc_iqquery.rb +31 -0
- data/test/tc_jid.rb +204 -0
- data/test/tc_message.rb +132 -0
- data/test/tc_presence.rb +150 -0
- data/test/tc_rexml.rb +139 -0
- data/test/tc_stream.rb +229 -0
- data/test/tc_streamComponent.rb +95 -0
- data/test/tc_streamError.rb +131 -0
- data/test/tc_streamSend.rb +59 -0
- data/test/tc_streamparser.rb +120 -0
- data/test/tc_xmppstanza.rb +135 -0
- data/test/ts_xmpp4r.rb +53 -0
- data/test/tune/tc_helper_recv.rb +84 -0
- data/test/tune/tc_helper_send.rb +74 -0
- data/test/tune/tc_tune.rb +79 -0
- data/test/vcard/tc_helper.rb +49 -0
- data/test/vcard/tc_iqvcard.rb +62 -0
- data/test/version/tc_helper.rb +60 -0
- data/test/version/tc_iqqueryversion.rb +97 -0
- data/test/xhtml/tc_html.rb +41 -0
- data/tools/gen_requires.bash +31 -0
- data/tools/xmpp4r-gemspec-test.rb +11 -0
- data/xmpp4r.gemspec +304 -0
- metadata +346 -0
data/Rakefile
ADDED
@@ -0,0 +1,252 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require "rake/clean"
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
|
6
|
+
$:.unshift 'lib'
|
7
|
+
require "xmpp4r"
|
8
|
+
|
9
|
+
##############################################################################
|
10
|
+
# OPTIONS
|
11
|
+
##############################################################################
|
12
|
+
|
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."
|
19
|
+
|
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
|
+
]
|
33
|
+
|
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 )
|
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}/**/*"]
|
39
|
+
|
40
|
+
##############################################################################
|
41
|
+
# DEFAULT TASK
|
42
|
+
##############################################################################
|
43
|
+
|
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
|
+
##############################################################################
|
52
|
+
|
53
|
+
Rake::TestTask.new do |t|
|
54
|
+
t.libs << "test"
|
55
|
+
t.test_files = ['test/ts_xmpp4r.rb']
|
56
|
+
end
|
57
|
+
|
58
|
+
##############################################################################
|
59
|
+
# DOCUMENTATION TASKS
|
60
|
+
##############################################################################
|
61
|
+
|
62
|
+
# RDOC
|
63
|
+
#######
|
64
|
+
Rake::RDocTask.new do |rd|
|
65
|
+
|
66
|
+
# which dir should rdoc files be installed in?
|
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
|
+
|
87
|
+
end
|
88
|
+
|
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 LoadError
|
102
|
+
end
|
103
|
+
|
104
|
+
# DOT GRAPH
|
105
|
+
############
|
106
|
+
desc "Generate requires graph"
|
107
|
+
task :gen_requires_graph do
|
108
|
+
sh %{cd tools; ./gen_requires.bash}
|
109
|
+
end
|
110
|
+
|
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"
|
127
|
+
end
|
128
|
+
|
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
|
+
begin
|
137
|
+
require 'rake/gempackagetask'
|
138
|
+
|
139
|
+
spec = Gem::Specification.new do |s|
|
140
|
+
s.name = PKG_NAME
|
141
|
+
s.version = PKG_VERSION
|
142
|
+
s.authors = AUTHORS
|
143
|
+
s.email = EMAIL
|
144
|
+
s.homepage = HOMEPAGE
|
145
|
+
s.rubyforge_project = PKG_NAME
|
146
|
+
s.summary = SUMMARY
|
147
|
+
s.description = s.summary
|
148
|
+
s.platform = Gem::Platform::RUBY
|
149
|
+
s.require_path = 'lib'
|
150
|
+
s.executables = []
|
151
|
+
s.files = PKG_FILES
|
152
|
+
s.test_files = []
|
153
|
+
s.has_rdoc = true
|
154
|
+
s.extra_rdoc_files = RDOC_FILES
|
155
|
+
s.rdoc_options = RDOC_OPTIONS
|
156
|
+
s.required_ruby_version = ">= 1.8.4"
|
157
|
+
end
|
158
|
+
|
159
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
160
|
+
pkg.gem_spec = spec
|
161
|
+
pkg.need_tar = true
|
162
|
+
pkg.need_zip = true
|
163
|
+
end
|
164
|
+
|
165
|
+
namespace :gem do
|
166
|
+
|
167
|
+
desc "Run :package and install the .gem locally"
|
168
|
+
task :install => [:update_gemspec, :package] do
|
169
|
+
sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem}
|
170
|
+
end
|
171
|
+
|
172
|
+
desc "Like gem:install but without ri or rdocs"
|
173
|
+
task :install_fast => [:update_gemspec, :package] do
|
174
|
+
sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem --no-rdoc --no-ri}
|
175
|
+
end
|
176
|
+
|
177
|
+
desc "Run :clean and uninstall the .gem"
|
178
|
+
task :uninstall => :clean do
|
179
|
+
sh %{sudo gem uninstall #{PKG_NAME}}
|
180
|
+
end
|
181
|
+
|
182
|
+
# Thanks to the Merb project for this code.
|
183
|
+
desc "Update Github Gemspec"
|
184
|
+
task :update_gemspec do
|
185
|
+
skip_fields = %w(new_platform original_platform date)
|
186
|
+
|
187
|
+
result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
|
188
|
+
result << "# RUN : 'rake gem:update_gemspec'\n\n"
|
189
|
+
result << "Gem::Specification.new do |s|\n"
|
190
|
+
spec.instance_variables.sort.each do |ivar|
|
191
|
+
value = spec.instance_variable_get(ivar)
|
192
|
+
name = ivar.split("@").last
|
193
|
+
next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
|
194
|
+
if name == "dependencies"
|
195
|
+
value.each do |d|
|
196
|
+
dep, *ver = d.to_s.split(" ")
|
197
|
+
result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "")}\n"
|
198
|
+
end
|
199
|
+
else
|
200
|
+
case value
|
201
|
+
when Array
|
202
|
+
value = name != "files" ? value.inspect : value.sort.uniq.inspect.split(",").join(",\n")
|
203
|
+
when String, Fixnum, true, false
|
204
|
+
value = value.inspect
|
205
|
+
else
|
206
|
+
value = value.to_s.inspect
|
207
|
+
end
|
208
|
+
result << " s.#{name} = #{value}\n"
|
209
|
+
end
|
210
|
+
end
|
211
|
+
result << "end"
|
212
|
+
File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
|
213
|
+
end
|
214
|
+
|
215
|
+
end # namespace :gem
|
216
|
+
|
217
|
+
# also keep the gemspec up to date each time we package a tarball or gem
|
218
|
+
task :package => ['gem:update_gemspec']
|
219
|
+
task :gem => ['gem:update_gemspec']
|
220
|
+
|
221
|
+
rescue LoadError
|
222
|
+
puts <<EOF
|
223
|
+
###
|
224
|
+
Packaging Warning : RubyGems is apparently not installed on this
|
225
|
+
system and any file add/remove/rename will not
|
226
|
+
be auto-updated in the 'xmpp4r.gemspec' when you run any
|
227
|
+
package tasks. All such file changes are recommended
|
228
|
+
to be packaged on a system with RubyGems installed
|
229
|
+
if you intend to push commits to the Git repo so the
|
230
|
+
gemspec will also stay in sync for others.
|
231
|
+
###
|
232
|
+
EOF
|
233
|
+
end
|
234
|
+
|
235
|
+
# we are apparently on a system that does not have RubyGems installed.
|
236
|
+
# Lets try to provide only the basic tarball package tasks as a fallback.
|
237
|
+
unless defined? Gem
|
238
|
+
begin
|
239
|
+
require 'rake/packagetask'
|
240
|
+
Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
|
241
|
+
p.package_files = PKG_FILES
|
242
|
+
p.need_tar = true
|
243
|
+
p.need_zip = true
|
244
|
+
end
|
245
|
+
rescue LoadError
|
246
|
+
puts <<EOF
|
247
|
+
###
|
248
|
+
Warning : Unable to require the 'rake/packagetask'. Is Rake installed?
|
249
|
+
###
|
250
|
+
EOF
|
251
|
+
end
|
252
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
What is this?
|
2
|
+
|
3
|
+
This is an example of what you can do with XMPP4R. It is a conferencing
|
4
|
+
component in which you can walk around, travel to various places, look
|
5
|
+
at things and talk to other visitors on the same places. If you like
|
6
|
+
Multi-User Dungeons (MUDs) this is for you!
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
How does it work?
|
11
|
+
|
12
|
+
The component loads a few worlds from a few XML files. Each world is a
|
13
|
+
component. Once joined the chat will tell you what you can do. Remember
|
14
|
+
that you can get a command listing anytime by saying '?'.
|
15
|
+
|
16
|
+
Reading 'You can go north, west' you may say 'go north' to go in the
|
17
|
+
northern direction and 'go west' to go in the western direction. You'll
|
18
|
+
then find yourself at some other place but still in the same MUC
|
19
|
+
conference. Your groupchat roster will change as you'll notice different
|
20
|
+
people and things that are just in the same place, not other places.
|
21
|
+
|
22
|
+
Before starting to hack the scripts you may want to take a look at
|
23
|
+
tower.xml. Note that users are <thing/>s, too and the whole world could
|
24
|
+
be serialized back to XML by just issuing "world.to_s".
|
25
|
+
|
26
|
+
Please note that the code, especially the error handling, is of extreme
|
27
|
+
poor quality and was mostly written in one afternoon. If I'm going to
|
28
|
+
develop this further everything should be rewritten...
|
29
|
+
|
30
|
+
---
|
31
|
+
|
32
|
+
How to try?
|
33
|
+
|
34
|
+
Because this is a component you are going to need your own Jabber
|
35
|
+
Daemon - which you'll need anyways if you're going to experiment with
|
36
|
+
XMPP4R. ;-)
|
37
|
+
|
38
|
+
Syntax:
|
39
|
+
./adventure.rb <JID> <Password> <Host>
|
40
|
+
|
41
|
+
Example:
|
42
|
+
./adventure.rb mud.example.com geheimnis localhost
|
43
|
+
|
44
|
+
---
|
45
|
+
|
46
|
+
Messages seem to have random order?
|
47
|
+
|
48
|
+
I don't know any solution for this. One may add short delays between
|
49
|
+
messages, but that would only be a very dirty hack.
|
50
|
+
|
51
|
+
RFC3920:
|
52
|
+
|
53
|
+
"10. Server Rules for Handling XML Stanzas
|
54
|
+
|
55
|
+
Compliant server implementations MUST ensure in-order processing of
|
56
|
+
XML stanzas between any two entities."
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift '../../lib'
|
4
|
+
|
5
|
+
require 'xmpp4r'
|
6
|
+
require 'xmpp4r/discovery'
|
7
|
+
require 'xmpp4r/muc/x/muc'
|
8
|
+
|
9
|
+
require 'adventuremuc'
|
10
|
+
|
11
|
+
|
12
|
+
#Jabber::debug = true
|
13
|
+
|
14
|
+
if ARGV.size != 3
|
15
|
+
puts "Syntax: ./adventure.rb <JID> <Password> <Host>"
|
16
|
+
puts "See README for further help"
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
|
20
|
+
muc = AdventureMUC.new(Jabber::JID.new(ARGV[0]), ARGV[1], ARGV[2])
|
21
|
+
muc.add_world('tower.xml')
|
22
|
+
muc.add_world('cube.xml')
|
23
|
+
Thread.stop
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'world'
|
2
|
+
|
3
|
+
class AdventureMUC
|
4
|
+
def initialize(jid, secret, addr, port=5347)
|
5
|
+
@worlds = {}
|
6
|
+
|
7
|
+
@component = Jabber::Component.new(jid)
|
8
|
+
@component.connect(addr, port)
|
9
|
+
@component.auth(secret)
|
10
|
+
@component.on_exception { |e,|
|
11
|
+
puts "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
|
12
|
+
}
|
13
|
+
|
14
|
+
@component.add_iq_callback { |iq|
|
15
|
+
handle_iq(iq)
|
16
|
+
}
|
17
|
+
@component.add_presence_callback { |pres|
|
18
|
+
handle_presence(pres)
|
19
|
+
}
|
20
|
+
@component.add_message_callback { |msg|
|
21
|
+
handle_message(msg)
|
22
|
+
}
|
23
|
+
|
24
|
+
puts "Adventure component up and running"
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_world(file)
|
28
|
+
print "Adding world from #{file}..."
|
29
|
+
begin
|
30
|
+
world = World.new_from_file(self, file)
|
31
|
+
rescue Exception => e
|
32
|
+
puts " #{e.to_s}"
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
@worlds[world.node] = world
|
36
|
+
puts " #{world.iname}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def send(worldnode, worldresource, stanza)
|
40
|
+
stanza.from = Jabber::JID.new(worldnode, @component.jid.domain, worldresource)
|
41
|
+
@component.send(stanza)
|
42
|
+
end
|
43
|
+
|
44
|
+
def handle_iq(iq)
|
45
|
+
puts "iq: from #{iq.from} type #{iq.type} to #{iq.to}: #{iq.queryns}"
|
46
|
+
|
47
|
+
if iq.query.kind_of?(Jabber::Discovery::IqQueryDiscoInfo)
|
48
|
+
handle_disco_info(iq)
|
49
|
+
true
|
50
|
+
elsif iq.query.kind_of?(Jabber::Discovery::IqQueryDiscoItems)
|
51
|
+
handle_disco_items(iq)
|
52
|
+
true
|
53
|
+
else
|
54
|
+
false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def handle_disco_info(iq)
|
59
|
+
if iq.type != :get
|
60
|
+
answer = iq.answer
|
61
|
+
answer.type = :error
|
62
|
+
answer.add(Jabber::ErrorResponse.new('bad-request'))
|
63
|
+
@component.send(answer) if iq.type != :error
|
64
|
+
return
|
65
|
+
end
|
66
|
+
answer = iq.answer
|
67
|
+
answer.type = :result
|
68
|
+
if iq.to.node == nil
|
69
|
+
answer.query.add(Jabber::Discovery::Identity.new('conference', 'Adventure component', 'text'))
|
70
|
+
answer.query.add(Jabber::Discovery::Feature.new(Jabber::Discovery::IqQueryDiscoInfo.new.namespace))
|
71
|
+
answer.query.add(Jabber::Discovery::Feature.new(Jabber::Discovery::IqQueryDiscoItems.new.namespace))
|
72
|
+
else
|
73
|
+
world = @worlds[iq.to.node]
|
74
|
+
if world.nil?
|
75
|
+
answer.type = :error
|
76
|
+
answer.query.add(Jabber::ErrorResponse.new('item-not-found', 'The world you are trying to reach is currently unavailable.'))
|
77
|
+
else
|
78
|
+
answer.query.add(Jabber::Discovery::Identity.new('conference', world.iname, 'text'))
|
79
|
+
answer.query.add(Jabber::Discovery::Feature.new(Jabber::Discovery::IqQueryDiscoInfo.new.namespace))
|
80
|
+
answer.query.add(Jabber::Discovery::Feature.new(Jabber::Discovery::IqQueryDiscoItems.new.namespace))
|
81
|
+
answer.query.add(Jabber::Discovery::Feature.new(Jabber::MUC::XMUC.new.namespace))
|
82
|
+
answer.query.add(Jabber::Discovery::Feature.new(Jabber::MUC::XMUCUser.new.namespace))
|
83
|
+
end
|
84
|
+
end
|
85
|
+
@component.send(answer)
|
86
|
+
end
|
87
|
+
|
88
|
+
def handle_disco_items(iq)
|
89
|
+
if iq.type != :get
|
90
|
+
answer = iq.answer
|
91
|
+
answer.add(Jabber::ErrorResponse.new('bad-request'))
|
92
|
+
@component.send(answer)
|
93
|
+
return
|
94
|
+
end
|
95
|
+
answer = iq.answer
|
96
|
+
answer.type = :result
|
97
|
+
if iq.to.node == nil
|
98
|
+
@worlds.each { |node,world|
|
99
|
+
answer.query.add(Jabber::Discovery::Item.new(Jabber::JID.new(node, @component.jid.domain), world.iname))
|
100
|
+
}
|
101
|
+
end
|
102
|
+
@component.send(answer)
|
103
|
+
end
|
104
|
+
|
105
|
+
def handle_presence(pres)
|
106
|
+
puts "presence: from #{pres.from} type #{pres.type} to #{pres.to}"
|
107
|
+
|
108
|
+
world = @worlds[pres.to.node]
|
109
|
+
if world.nil?
|
110
|
+
answer = pres.answer
|
111
|
+
answer.type = :error
|
112
|
+
answer.add(Jabber::ErrorResponse.new('item-not-found', 'The world you are trying to reach is currently unavailable.'))
|
113
|
+
@component.send(answer)
|
114
|
+
else
|
115
|
+
world.handle_presence(pres)
|
116
|
+
end
|
117
|
+
|
118
|
+
true
|
119
|
+
end
|
120
|
+
|
121
|
+
def handle_message(msg)
|
122
|
+
puts "message: from #{msg.from} type #{msg.type} to #{msg.to}: #{msg.body.inspect}"
|
123
|
+
|
124
|
+
world = @worlds[msg.to.node]
|
125
|
+
if world.nil?
|
126
|
+
answer = msg.answer
|
127
|
+
answer.type = :error
|
128
|
+
answer.add(Jabber::ErrorResponse.new('item-not-found', 'The world you are trying to reach is currently unavailable.'))
|
129
|
+
@component.send(answer)
|
130
|
+
else
|
131
|
+
world.handle_message(msg)
|
132
|
+
end
|
133
|
+
|
134
|
+
true
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<world node='cube' name='Cube - the movie' start='Room'>
|
2
|
+
|
3
|
+
<place name='Room'>
|
4
|
+
This is a big white room.
|
5
|
+
There are doors up, down, left, right, in the back and in front of you.
|
6
|
+
There's nothing else.
|
7
|
+
<go spec='up' place='Room'/>
|
8
|
+
<go spec='down' place='Room'/>
|
9
|
+
<go spec='left' place='Room'/>
|
10
|
+
<go spec='right' place='Room'/>
|
11
|
+
<go spec='back' place='Room'/>
|
12
|
+
<go spec='forward' place='Room'/>
|
13
|
+
</place>
|
14
|
+
|
15
|
+
</world>
|
@@ -0,0 +1,69 @@
|
|
1
|
+
<world node='tower' name='The mysterious tower' start='the garden'>
|
2
|
+
|
3
|
+
<place name='the garden'>
|
4
|
+
You are in a beautiful garden.
|
5
|
+
There's an impressive tower beneath. Its door is open.
|
6
|
+
<go spec='door' place='lower room'/>
|
7
|
+
<go spec='east' place='the well'/>
|
8
|
+
</place>
|
9
|
+
|
10
|
+
<place name='lower room'>
|
11
|
+
Welcome to the tower's lower room.
|
12
|
+
There's a ladder to upstairs.
|
13
|
+
<go spec='door' place='the garden'/>
|
14
|
+
<go spec='ladder' place='upper room'/>
|
15
|
+
</place>
|
16
|
+
|
17
|
+
<place name='upper room'>
|
18
|
+
This is the upper room.
|
19
|
+
There's only a bed here. A wizard is currently sleeping in it.
|
20
|
+
<go spec='ladder' place='lower room'/>
|
21
|
+
</place>
|
22
|
+
|
23
|
+
<place name='the well'>
|
24
|
+
There's a very beautiful well in the middle of this place.
|
25
|
+
A frog sits on the well's edge. It looks frightening happy.
|
26
|
+
<go spec='west' place='the garden'/>
|
27
|
+
</place>
|
28
|
+
|
29
|
+
|
30
|
+
<thing name='Frog' place='the well'>
|
31
|
+
<on-enter>
|
32
|
+
<say>Hello great hero!</say>
|
33
|
+
<say>Welcome to %place%</say>
|
34
|
+
</on-enter>
|
35
|
+
<on-leave>
|
36
|
+
<tell>The %self% waves towards %actor%</tell>
|
37
|
+
</on-leave>
|
38
|
+
<on-command command='talk'>
|
39
|
+
<say>I would love to come with you, great hero. But I'm immobile due to the simple nature of this game. Would *YOU* like to /code/ me movable? So we could enjoy great adventures together...</say>
|
40
|
+
</on-command>
|
41
|
+
<on-command command='touch'>
|
42
|
+
<tell to='all'>%actor% touches the %self%</tell>
|
43
|
+
<say to='all'>Quaaack! That feels good.</say>
|
44
|
+
</on-command>
|
45
|
+
<presence>
|
46
|
+
<show>chat</show>
|
47
|
+
<status>Happy</status>
|
48
|
+
</presence>
|
49
|
+
</thing>
|
50
|
+
|
51
|
+
<thing name='Sleeping Wizard' place='upper room'>
|
52
|
+
<on-enter>
|
53
|
+
<say>*snork*</say>
|
54
|
+
</on-enter>
|
55
|
+
<presence>
|
56
|
+
<show>dnd</show>
|
57
|
+
<status>Sleeping... go bother my assistant, the frog.</status>
|
58
|
+
</presence>
|
59
|
+
</thing>
|
60
|
+
|
61
|
+
<thing name='Tower window' command-name='window' place='upper room'>
|
62
|
+
<on-command command='look'>
|
63
|
+
<say>You see a beautiful garden. There's a well behind the garden. But a huge green monster is sitting on it's edge.</say>
|
64
|
+
</on-command>
|
65
|
+
<presence>
|
66
|
+
<status>There's a great view from up here</status>
|
67
|
+
</presence>
|
68
|
+
</thing>
|
69
|
+
</world>
|