Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
a Ruby class for easy interfacing with the mollom.com open API for spam detection and content quality assesment.
Ruby
branch: master

This branch is 2 commits ahead, 13 commits behind openminds:master

Failed to load latest commit information.
lib Added global config setter.
pkg Version numbers are stupid, but gems need them.. Also a small update …
test Added global config setter.
.gitignore .gitignore
MIT-LICENSE Added README, MIT-License
README.rdoc
Rakefile Do releasing of the gem with Jeweler
VERSION
mollom.gemspec Updated gemspec

README.rdoc

Mollom

This is a Ruby class for easy interfacing with the mollom.com open API for spam detection and content quality assessment.

Installation

You can either install the library as a gem

gem install mollom

Or you can get the latest development version from GitHub:

git clone git://github.com/DefV/ruby-mollom.git

You can also just add it on your Gemfile:

gem 'mollom'

Usage

After you have requested a public/private key-pair from Mollom (on www.mollom.com), you can start using this class.

require 'rubygems'
require 'mollom'

m = Mollom.new(:private_key => 'your-private-key', :public_key => 'your-public-key')

content = m.check_content(:post_title => 'Mollem is an open API',

:post_body => “Lorem Ipsum dolor…”, :author_name => 'Jan De Poorter', :author_url => 'workswithruby.com')

if content.spam?

puts “You, sir, are a spammer.. Goodbye!”

elsif content.unsure?
  # possible spam, possible ham, show CAPTCHA
  puts "CAPTCHA: " + m.image_captcha(:session_id => content.session_id)["url"]

  captcha_correct = m.check_captcha(:session_id => content.session_id, :solution => STDIN.gets.chomp)
else
  puts "The post is perfect! No spam!"
end

Usage in a class with attributes (an ActiveRecord, Mongoid, etc model):

class Comment < ActiveRecord::Base
  include Mollom::Model
end

c = Comment.new(:title => 'A title', :name => 'Author name', :url => 'http://example.com', :body => 'Lorem Ipsum...')
c.spam?
c.ham?
c.unsure?

If you need different attribute names, then you can do this:

class Comment < ActiveRecord::Base
  include Mollom::Model
  mollom :post_title => :topic, :author_name => :user_name, :author_url => :website, :post_body => :text
end

Copyright © 2008 Jan De Poorter - Openminds BVBA, released under the MIT license

Something went wrong with that request. Please try again.