Module: CrawlerDetect::Library

Defined in:
lib/crawler_detect/library.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: Crawlers, Exclusions, Headers, Loader

Constant Summary collapse

DATA_CLASSES =

Since:

  • 0.1.0

[Library::Headers, Library::Exclusions, Library::Crawlers].freeze

Class Method Summary collapse

Class Method Details

.get_array(param) ⇒ Array

Parameters:

  • param (String)

    Name of raw data

Returns:

  • (Array)

Since:

  • 0.1.0



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

def get_array(param)
  const_get("CrawlerDetect::Library::#{param.capitalize}").send(:data)
end

.get_regexp(param) ⇒ Regexp

Parameters:

  • param (String)

    Name of raw data

Returns:

  • (Regexp)

Since:

  • 0.1.0



13
14
15
16
17
18
# File 'lib/crawler_detect/library.rb', line 13

def get_regexp(param)
  @regexp_cache[param] ||= begin
    data = get_array(param)
    %r{#{data.join('|')}}i
  end
end

.reset_cachevoid

This method returns an undefined value.

Since:

  • 0.1.0



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

def reset_cache
  DATA_CLASSES.each(&:reload_data)
  @regexp_cache = {}
end