Class: Rack::DetectRobots
- Inherits:
-
Object
- Object
- Rack::DetectRobots
- Defined in:
- lib/rack_detect_robots.rb
Constant Summary collapse
- KNOWN_CRAWLERS =
this is fast for upto ca. 200 crawlers then use something different (trieā¦)
[ 'yahoo! slurp', 'yahoo! de slurp', 'googlebot', 'bingbot', 'aol', 'scoutjet', 'ask jeeves', 'yanga worldsearch bot', 'gigaboti', 'ichiro', 'msnbot', 'crawler', 'ia_archiver', 'jobverifier', 'twiceler', 'eurobot', 'adsbot-google', 'speedy spider', 'yacybot', 'wget', 'findlinks', 'feedhub metadatafetcher', 'jobrobot.de', 'baiduspider']
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, crawler_regexp = nil) ⇒ DetectRobots
constructor
A new instance of DetectRobots.
Constructor Details
#initialize(app, crawler_regexp = nil) ⇒ DetectRobots
Returns a new instance of DetectRobots.
43 44 45 46 |
# File 'lib/rack_detect_robots.rb', line 43 def initialize(app, crawler_regexp=nil) @app=app @crawler_regexp = (crawler_regexp || Regexp.new(KNOWN_CRAWLERS.map{|bot| Regexp.escape(bot)}.join('|'),"i")) end |
Instance Method Details
#call(env) ⇒ Object
48 49 50 51 |
# File 'lib/rack_detect_robots.rb', line 48 def call(env) env['rack_detect_robots']=test_for_robots(env) @app.call(env) end |