Module: CrawlerDetect

Defined in:
lib/crawler_detect.rb,
lib/crawler_detect/config.rb,
lib/crawler_detect/library.rb,
lib/crawler_detect/version.rb,
lib/crawler_detect/detector.rb,
lib/crawler_detect/library/loader.rb,
lib/crawler_detect/library/headers.rb,
lib/crawler_detect/library/crawlers.rb,
lib/crawler_detect/library/exclusions.rb

Overview

Since:

  • 0.1.0

Defined Under Namespace

Modules: Library Classes: Config, Detector

Constant Summary collapse

VERSION =

Since:

  • 0.1.0

"1.1.2"

Class Method Summary collapse

Class Method Details

.configCrawlerDetect::Config

Returns Instance of configuration class.

Returns:

Since:

  • 1.0.0


40
41
42
# File 'lib/crawler_detect.rb', line 40

def config
  @config ||= CrawlerDetect::Config.new
end

.is_crawler?(user_agent) ⇒ true, false

Returns Is User-agent a crawler?.

Parameters:

  • user_agent (String)

    User-agent string to detect

Returns:

  • (true, false)

    Is User-agent a crawler?

Since:

  • 0.1.0


27
28
29
# File 'lib/crawler_detect.rb', line 27

def is_crawler?(user_agent)
  detector(user_agent).is_crawler?
end

.new(user_agent) ⇒ CrawlerDetect::Detector

Returns Instance of detector class.

Parameters:

  • user_agent (String)

    User-agent string to detect

Returns:

Since:

  • 0.1.0


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

def new(user_agent)
  detector(user_agent)
end

.setup!(&config) ⇒ Object

Parameters:

  • config (Proc)

Since:

  • 1.0.0


33
34
35
36
# File 'lib/crawler_detect.rb', line 33

def setup!(&config)
  @config = CrawlerDetect::Config.new(&config)
  Library::DATA_CLASSES.each(&:reload_data)
end