0.0
No commit activity in last 3 years
No release in over 3 years
Inspects the user agent for you and allows you to take action based on the users browser, if it is a detectable bot with one-line-helpers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Build Status Code Climate Test Coverage

AgentHelpers

Detect if the client is a bot, which bot and which version. Also tells if it is a human, which browser, version and much more in Rails.

Installation

First bundle it in your Gemfile:

gem 'agent_helpers'

Run bundle install.

Include it in your ApplicationHelper:

module ApplicationHelper
  include AgentHelpers::DetectorHelper
end

Usage

In a view:

<% if agent_robot? %>
  You are a robot.
<% elsif agent_human? %>
  Welcome human!
<% end %>

In a controller:

if view_context.agent_robot?
  redirect_to not_allowed_path
end

List of helpers

agent_robot? #=> true, false
agent_human? #=> true, false
agent_browser #=> :ie, :firefox, :chrome, :ie, :opera etc.
agent_title #=> "Firefox", "Chrome", "Opera" etc.
agent_version #=> "23.0" etc.
agent_device #=> :iphone, :ipad, :android etc.
agent_os #=> :windows, :linux, :osx etc.
agent_os_title #=> "Windows XP", "Windows 7" etc.
agent_chrome? #=> true, false
agent_firefox? #=> true, false
agent_ie? #=> true, false, maybe it crashes?
agent_safari? #=> true, false
agent_opera? #=> true, false
agent_mobile? #=> true, false
agent_windows? #=> true, false
agent_linux? #=> true, false
agent_osx? #=> true, false
agent_os_version #=> "NT 5.1", "10.6.1" etc.