Module: Browser::Bots

Included in:
Browser
Defined in:
lib/browser/methods/bots.rb

Constant Summary collapse

BOTS =
YAML.load_file(root.join("bots.yml"))
SEARCH_ENGINES =
YAML.load_file(root.join("search_engines.yml"))

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.detect_empty_ua!Object



7
8
9
# File 'lib/browser/methods/bots.rb', line 7

def self.detect_empty_ua!
  Browser::Bots::BOTS[''] = 'Generic bot'
end

Instance Method Details

#bot?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/browser/methods/bots.rb', line 11

def bot?
  BOTS.any? {|key, _| ua.include?(key) }
end

#search_engine?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/browser/methods/bots.rb', line 15

def search_engine?
  SEARCH_ENGINES.any? {|key, _| ua.include?(key) }
end