Home

Awesome

Robocop Build Status

Robocop is a simple Rack middleware that inserts the X-Robots-Tag into the headers of all your responses.

The X-Robots-Tag can be used in place of a robots.txt file or meta tags to tell crawlers what they're allowed to do with your content. See this article for more information.

Tested against Ruby 1.8.7, 1.9.2, 1.9.3, and Rubinius & JRuby in both 1.8 and 1.9 mode.

Installation

The simplest way to install Robocop is to use Bundler.

Add Robocop to your Gemfile:

gem 'robocop'

Basic Usage

Rails

To use Robocop in your Rails application, add the following line to your application config file (config/application.rb for Rails 3, config/environment.rb for Rails 2):

config.middleware.use Robocop::Middleware do
  directives :all
end

Other Rack Applications (Sinatra, Padrino, etc.)

Simple add the following to your config.ru:

use Robocop::Middleware do
  directives :all
end

Options

The following directives can be passed in to Robocop's configuration:

Directives (useragent agnostic)

If you just want to specify a list of directives for all useragents to follow, simply pass in a list of directives with the directive method:

config.middleware.use Robocop::Middleware do
  directives :noindex, :nofollow
end

Useragents

If you want to give specific user agents unique sets of directives, you can do so by using the useragent method:

config.middleware.use Robocop::Middleware do
  useragent :googlebot do
    directive :all
  end

  directives :noindex, :nofollow
end

It should be noted that if both the useragents and directives options are passed in, the useragents are output first in the header, followed by the generic directives.

TODO

Note on Patches / Pull Requests

Copyright

Copyright (c) 2012 PJ Kelly. See LICENSE for details.