Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Sep 12, 2024
1 parent 487153b commit a9af1ff
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Voight-Kampff
=============
[![Build Status](https://travis-ci.org/biola/Voight-Kampff.svg?branch=master)](https://travis-ci.org/biola/Voight-Kampff)
[![Code Climate](https://codeclimate.com/github/biola/Voight-Kampff/badges/gpa.svg)](https://codeclimate.com/github/biola/Voight-Kampff)
[![Gem Version](https://badge.fury.io/rb/voight_kampff.svg)](https://badge.fury.io/rb/voight_kampff)
# Voight-Kampff

[![GitHub license](https://img.shields.io/github/license/jbox-web/voight-kampff.svg)](https://github.com/jbox-web/voight-kampff/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/jbox-web/voight-kampff.svg)](https://github.com/jbox-web/voight-kampff/releases/latest)
[![CI](https://github.com/jbox-web/voight-kampff/workflows/CI/badge.svg)](https://github.com/jbox-web/voight-kampff/actions)
[![Code Climate](https://codeclimate.com/github/jbox-web/voight-kampff/badges/gpa.svg)](https://codeclimate.com/github/jbox-web/voight-kampff)
[![Test Coverage](https://codeclimate.com/github/jbox-web/voight-kampff/badges/coverage.svg)](https://codeclimate.com/github/jbox-web/voight-kampff/coverage)

Voight-Kampff relies on a [user agent](http://en.wikipedia.org/wiki/User_agent) list for its detection. It can easily tell you if a request is coming from a crawler, spider or bot. This can be especially helpful in analytics such as page hit tracking.

Installation
------------
## Installation

`gem install voight_kampff`

Expand All @@ -23,17 +24,16 @@ if you're using pure Rack, require it the following way:
gem 'voight_kampff', require: 'voight_kampff/rack'
```

Configuration
-------------
## Configuration

A JSON file is used to match [user agent strings](http://simplyfast.info/browser) to a list of known bots.

If you'd like to use an [updated list](https://github.com/monperrus/crawler-user-agents) or make your own customizations, run `rake voight_kampff:import_user_agents`. This will download a `crawler-user-agents.json` file into the `./config` directory.

__Note:__ The pattern entries in the JSON file are evaluated as [regular expressions](http://en.wikipedia.org/wiki/Regular_expression).

Usage
-----
## Usage

There are three ways to use Voight-Kampff

1. Through Rack::Request such as in your [Ruby on Rails](http://rubyonrails.org) controllers:
Expand All @@ -47,10 +47,10 @@ There are three ways to use Voight-Kampff

All of the above examples accept `human?` and `bot?` methods. All of these methods will return `true` or `false`.

Upgrading to version 1.0
------------------------
## Upgrading to version 1.0

Version 1.0 uses a new source for a list of bot user agent strings since the old source was no longer maintained. This new source, unfortuately, does not include as much detail. Therefore the following methods have been deprecated:

- `#browser?`
- `#checker?`
- `#downloader?`
Expand All @@ -62,8 +62,7 @@ In general the `#bot?` command tends to include all of these and I'm sure it's u

Also, the gem no longer extends `ActionDispatch::Request` instead it extends `Rack::Request` which `ActionDispatch::Request` inherits from. This allows the same functionality for Rails while opening the gem up to other rack-based projects.

Upgrading to version 2.0
------------------------
## Upgrading to version 2.0

If you use Rails and `ActionDispatch::Request#bot?` and `ActionDispatch::Request#human?` methods, change your gemfile:

Expand All @@ -79,29 +78,28 @@ If you use Rack, change your gemfile:
+gem 'voight_kampff', require: 'voight_kampff/rack'
```

FAQ
---
## FAQ

__Q:__ __What's with the name?__
__A:__ It's the [machine in Blade Runner](https://en.wikipedia.org/wiki/Blade_Runner#Voight-Kampff_machine) that is used to test whether someone is a human or a replicant.

__Q:__ __I've found a bot that isn't being matched__
__A:__ The list is being pulled from [github.com/monperrus/crawler-user-agents](https://github.com/monperrus/crawler-user-agents).
If you'd like to have entries added to the list, please create a pull request with that project. Once that pull request is merged, feel free to create an issue here and I'll release a new gem version with the updated list. In the meantime you can always run `rake voight_kampff:import_user_agents` on your project to get that updated list.

__Q:__ __Why don't you use the user agent list from ______________
If you know of a better source for a list of bot user agent strings, please create an issue and let me know. I'm open to switching to a better source or supporting multiple sources. There are others out there but I like the openness of monperrus' list.
__Q:__ __Why don't you use the user agent list from "my fancy project"?__
__A:__ If you know of a better source for a list of bot user agent strings, please create an issue and let me know. I'm open to switching to a better source or supporting multiple sources. There are others out there but I like the openness of monperrus' list.

## Thanks

Thanks
------
Thanks to [github.com/monperrus/crawler-user-agents](https://github.com/monperrus/crawler-user-agents) for providing an open and easily updatable list of bot user agents.

Contributing
------------
## Contributing

PR without tests will not get merged, Make sure you write tests for api and rails app.
Feel free to ask for help, if you do not know how to write a determined test.

Running Tests?
--------------
## Running Tests?

- `bundle install`
- `bundle exec rspec`
- `bundle install`
- `bundle exec rspec`

0 comments on commit a9af1ff

Please sign in to comment.