Sha256: eef1a655f06544893c61082f0c885d80955c1e71c98357b7fb3a9eb1f40a1bc3

Contents?: true

Size: 980 Bytes

Versions: 6

Compression:

Stored size: 980 Bytes

Contents

module Aua::Agents::SearchBot
  PATTERN_BING = /bingbot\/([\d\.]+)/
  PATTERN_BAIDU = /Baiduspider\/?([\d\.]+)?/
  PATTERN_GOOGLE = /Googlebot(-Mobile)?\/?([\d\.]+)?/

  def self.extend?(agent)
    agent.raw =~ PATTERN_BING ||
    agent.app_comments[1] == "Yahoo! Slurp" ||
    agent.raw =~ PATTERN_BAIDU ||
    agent.raw =~ PATTERN_GOOGLE ||
    agent.app == "msnbot" ||
    agent.app == "FLUX-Toolchain"
  end

  def type
    :SearchBot
  end

  def name
    @name ||= begin
      return :Bingbot if raw =~ PATTERN_BING
      return :YahooSlurp if app_comments[1] == "Yahoo! Slurp"
      return :Baiduspider if raw =~ PATTERN_BAIDU
      return $1 ? :GooglebotMobile : :Googlebot if raw =~ PATTERN_GOOGLE
      return :DWDSCrawler if app == "FLUX-Toolchain"
      app.to_sym
    end
  end

  def version
    @version ||= begin
      return $1 if raw =~ PATTERN_BING
      return $1  if raw =~ PATTERN_BAIDU
      return $2  if raw =~ PATTERN_GOOGLE
      super
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aua-0.3.2 lib/aua/agents/search_bot.rb
aua-0.3.1 lib/aua/agents/search_bot.rb
aua-0.3.0 lib/aua/agents/search_bot.rb
aua-0.2.6 lib/aua/agents/search_bot.rb
aua-0.2.5 lib/aua/agents/search_bot.rb
aua-0.2.4 lib/aua/agents/search_bot.rb