Babylon

DESCRIPTION:

Babylon is a framework to build XMPP Applications in Ruby. The framework uses EventMachine to handle network connections.

This framework can use both an XMPP Component (XEP-0114) and an XMPP Client (and XMPP Servers should come soon). However, we strongly discourage any production application using a regular client.

FEATURES/PROBLEMS:

Please link “report/request here.”:github.com/julien51/babylon/issues

The current version is a good candidate for version 0.1. We will probably not add any important features before that release, but we need some help with the tests and documentation.

ROADMAP :

  • Implement the ServerConnection for S2S

  • Implement templates for disco-info… and common XEPs

  • Delete route priorities? And rely on the order only? (As Rails does)

  • Review doc

  • Write tests

  • Evangelize!

You can help with at least one of these points, don’t turn your back on Babylon!

DOCUMENTATION :

You can find it on our “Rubyforge page”:babylon.rubyforge.org/ Feel free to fork the “github”:github.com/julien51/babylon/tree/master repo and add some documentation if you think anything is missing.

__You can’t be a bad coder, a bad tester and a bad documenter at the same time ;)__

SYNOPSIS :

You can build applications directly with Babylon, or you can use the Babylon::ClientConnection and Babylon::ComponentConnection to create simple apps, but you will then have to handle stanza routing and creation yourself. You can also use these classes in external gems.

To create an Application with Babylon:

  1. Install the gem

  2. The app contains a generator that will “build” a scaffold for your application.

    $> babylon application __myapp__
    
  3. Use the generator or write your own controllers :

    $> babylon controller __messages__ __echo__:__10__:__//stream:message[@type='chat']/body__,__subscribed__:__0__:__//stream:presence[@type='subscribe']__
    

This will generate a __MessagesController__ class with 2 methods : __echo__ and __subscribed__.

- "echo" will be called when the component receives message stanzas of type 'chat', 
- "subscribed" will be called for presence stanzas of type 'subscribe'.

10 and 0 are the priority : useful when a stanza matches 2 XPath.

Each of these actions will be called with stanza objects. You have to define your own objects in stanzas/echo.rb and stanzas/subscribed.rb By implementing them, you can choose which elements and attributes you want to have access to. These attributes will be populated upon instantiation of the Stanza objects.

This will also generate 2 ‘views’ used to build your responses stanzas.

And finally, this will write 2 routes in the config/routes.rb

  1. Customize your controllers, stanzas and views!

  2. Make sure that the XMPP settings are correct in config/config.yaml.

  3. And finally start the component :

    script/component
    

To use the Connection Classes only (Client or Component), you can just call the following :

Babylon::ClientConnection.connect(params, handler) or, Babylon::ComponentConnection.connect(params, handler)

where params is a hash for all the necessary information to connect, and handler is an object that will receive the callbacks. Right now 3 callbacks are supported:

on_connected(connection), on_disconnected and on_stanza(stanza)

ADDITIONAL INFORMATION :

Feel free to pull, branch, improve and commit the code|specs|tests|docs : we will merge it if it’s a step ahead!

Babylon’s edge versions are located at Github : github.com/julien51/babylon/tree/master

REQUIREMENTS :

Gems : Eventmachine, nokogiri (please, use build from the guthub repo, since 1.2.3 is not supported by Babylon), YAML, log4r, sax-machine, templater, daemons

LICENSE:

(The MIT License)

Copyright © 2009 Julien Genestoux notifixio.us

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.