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! @detect_empty_ua = true end |
.detect_empty_ua? ⇒ Boolean
11 12 13 |
# File 'lib/browser/methods/bots.rb', line 11 def self.detect_empty_ua? !!@detect_empty_ua end |
Instance Method Details
#bot? ⇒ Boolean
15 16 17 |
# File 'lib/browser/methods/bots.rb', line 15 def bot? bot_with_empty_ua? || BOTS.any? {|key, _| ua.include?(key) } end |
#bot_name ⇒ Object
19 20 21 22 23 |
# File 'lib/browser/methods/bots.rb', line 19 def bot_name return unless bot? return "Generic Bot" if bot_with_empty_ua? BOTS.find {|key, _| ua.include?(key) }.first end |
#search_engine? ⇒ Boolean
25 26 27 |
# File 'lib/browser/methods/bots.rb', line 25 def search_engine? SEARCH_ENGINES.any? {|key, _| ua.include?(key) } end |