XMPP the Ruby Way
If you’ve ever tried to integrate Jabber into your app or just wanted to write a bot to respond with TWSS jokes, you’ve probably checked out XMPP4R or Switchboard. These libraries are great and have a really solid feature set, but if you find yourself writing a lot of boilerplate and really want a library with more of a Ruby feel to it, try out sprsquish’s gem, Blather.
It’s written as a DSL and leverages Eventmachine, which allows you to easily listen for messages and send a response. Checkout how simple it is to get up and running:
There are tons of ways to filter out messages by checking attribute values, matching a regular expression, or even passing in a custom Proc. You can also respond to most other events like presence notifications and even file transfer requests. The gem is also really well organized so you can easily work at the Eventmachine layer or just use their nicely defined DSL with command line options to get up and running as quick as possible.
There are instructions on how to get it installed in the README along with some example scripts in the repo. If you’re planning on using it with a web app here’s a quick example that we used in our tech demo of how to run it along side Sinatra using Foreman.