Module: Rack::TuringTest
- Included in:
- Request
- Defined in:
- lib/rack-turing-test.rb,
lib/rack-turing-test/version.rb
Constant Summary collapse
- PATTERN =
Regexp.union(*[ /googlebot/i, /mediapartners-google/i, /slurp/i, /ask.com/i, /crawler/i, /nutch/i, /msnbot/i, /bingbot/i, /baidu/i, /yetibot/i, /teoma/i, /spider/i, ]).freeze
- VERSION =
"0.2.1"
Instance Method Summary collapse
-
#bot? ⇒ Boolean
Returns true if the request came from bot.
Instance Method Details
#bot? ⇒ Boolean
Returns true if the request came from bot. Sometimes, there’s a case that the HTTP_USERAGENT is nil. It’s very rare for ordinary browsers. So, simply we observe it as a bot.
23 24 25 |
# File 'lib/rack-turing-test.rb', line 23 def bot? @__bot ||= (user_agent.nil? || !!user_agent.match(PATTERN)) end |