RDefensio A Framework Agnostic Ruby Library For Defensio
Yesterday, I posted about switching this blog over to Defensio. Today I'd like to look briefly at how I went about integrating it.
Defensio provides an API against which you can make HTTP posts. This is a pretty straightforward thing. I simply wrote a library that makes it a little less low-level.
The code is on GitHub, here.
The library is designed to be framework agnostic and to have as few dependencies as possible. The specs rely on RSpec, but that's about all that it requires.
Configuration
For any app, the first thing that needs to be done to use RDefensio is to configure it. You must have an API key from Defensio. This site is built with Sinatra, so I configure RDefensio within a Sinatra configure block:
The owner url is simply the url you registered with Defensio when you signed up. In my case, it's http://mattpayne.ca/blog
If you're using Rails, this could be done in an initializer.
That's all it takes to configure it.
Usage
Well, Defensio exposes several API methods that can be called. RDefensio mirrors them.
All of these methods return an OpenStruct object that represents the result of the post to Defensio.
The get_stats method is particularly useful if you want to display information about your Defensio interactions. It will return values for # of spam comments, # of false positives, # of false negatives and several other nice informational items
That's it for my post about RDefensio. It seems to be working well for me over the past few days.


No comments have been posted.