Code Monkey home page Code Monkey logo

voight-kampff's Introduction

Voight-Kampff

Build Status

Voight-Kampff relies on 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

gem install voight_kampff

Configuration

A YAML file is used to match user agent strings to their types.

If you'd like to use an updated list or make your own customizations, run rake voight_kampff:import_user_agents. This will download a user_agents.yml file into your Rails /config directory.

To use Regular Expression matching, just set string_match: regex in your user_agent entry. The first match will be used so you should probably put your Regular Expression entries toward the bottom of the file.

Usage

There are three ways to use Voight-Kampff

  1. In your Ruby on Rails controllers:
    request.bot?

  2. Through the VoightKampff module:
    VoightKampff.bot? 'your user agent string'

  3. Through a VoightKampff::Test instance:
    VoightKampff::Test.new('your user agent string').bot?

All of the above examples accept human?, bot?, browser?, checker?, downloader?, proxy?, crawler? and spam? methods. All of these methods will return true, false, or nil (if it doesn't recognize the user agent).

FAQ

Q: What's with the name?
A: It's the machine in Blade Runner that is used to test whether someone is a human or a replicant.

Q: My browser isn't being matched
A: The list is being pulled from user-agents.org. If you'd like to have entries added to the list please create a new issue or send me a pull request. And if you know of a better source for this sort of data, please let me know.

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?

  • bundle install
  • rake
  • rake test #code tests
  • rake spec #app tests

AUTOMATE TESTS? Fear not

  • gem install autotest-standalone
  • autotest
  • that's it
  • wq

voight-kampff's People

Contributors

acnalesso avatar adamcrown avatar simonhildebrandt avatar spyderdfx avatar vamereh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.