Class: Rack::CrawlerDetect

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/crawler_detect.rb

Overview

Rack-based interface to detect crawlers

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ CrawlerDetect

Returns a new instance of CrawlerDetect.

Since:

  • 0.1.0


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rack/crawler_detect.rb', line 8

def initialize(app, options = {})
  Rack::Request::Helpers.module_eval do
    def is_crawler?
      env["rack.crawler_detect"][:is_crawler]
    end

    def crawler_name
      env["rack.crawler_detect"][:crawler_name]
    end
  end
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Since:

  • 0.1.0


21
22
23
24
# File 'lib/rack/crawler_detect.rb', line 21

def call(env)
  set_env_variables!(env)
  @app.call(env)
end