Ruby bindings for Loudmouth
Last week I sat down and wrote bindings for Loudmouth. This means that anyone who want to write an XMPP enabled application with GTK+/Ruby now have an asynchronous library that integrates perfectly with the GLib mainloop.
It also gives me access to testing and writing small scripts using Loudmouth with the beauty of Ruby.
Here is a small example showing the bindings in the current state:
require 'loudmouth'
conn = LM::Connection.new
conn.jid = 'myjid@mydomain.com'
conn.open do |open_result|
if open_result
conn.authenticate('username', 'password', 'resource') do |auth_result|
if result
puts "Authenticated, do your stuff"
end
end
end
end
GLib::MainLoop.new.run
So far I have only bound the asynchronous calls and I am not sure whether I will bind synchronous ones in the future.
If you want to try them out or even better, help out by improving them or write example code. Create an account at Github and watch/clone the repository. It’s named loudmouth-ruby.
I’m actually writing a ruby gobject bindings generator to allow for easy binding of gobject C code in ruby. It’s not completely ready yet, but if you’re interested, give it a look (any ideas/pointers are welcome)
Jesse, that sounds really nice. Unfortunately I’m not sure it would help me much as Loudmouth doesn’t use GObject now.
I have some plans of GObject-ifying though but that would be for 2.0 or beyond.
Okay, wasn’t sure if it was GObject based or not, but decided to post a comment anyway since I saw some other post doing Gtk subclassing in ruby. I really think ruby is an underappreciated language, and I hope by providing tools to make binding-making easier, it will be more readily used.
Jesse, I definitely agree and having a bindings generator for GObject based libraries would be of great benefit to anyone who enjoys developing with Ruby.
Do you have a link to the project somewhere?
Yes, the link is the website link of the comment: https://trac.novowork.com/rbgtool
I haven’t finished the information on the wiki (it’s on my todo for 0.2), and I’m currently working towards successfully generating bindings for gtksourceview2, adding features as they are needed.
Did you know XMPP4R? Perhaps we can share helper code on top of any XMPP client?
Stephan, hi there, I do indeed and also been playing around with it some. It seems like a really nice library!
The reason I decided to create bindings for Loudmouth anyway was due to the GLib mainloop integration which makes life much easier for a Ruby/GTK user.
Sharing helper code sounds interesting though I know too little of XMPP4R today to be able to compare the libraries to see where things can be shared. Maybe you have some ideas in this area?
Jesse, silly of me to not look at your post URL first. Looks great and will definitely keep an eye on the progress there!