Class: SearchBot
Constant Summary collapse
- KNOWN_SEARCH_BOTS =
Feedfetcher-Google; (+www.google.com/feedfetcher.html; feed-id=17168503030479467473) Mozilla/5.0 (compatible; Googlebot/2.1; www.google.com/bot.html) Googlebot-Image/1.0 msnbot/2.0b (search.msn.com/msnbot.htm) msnbot/2.0b (+search.msn.com/msnbot.htm). msnbot/2.0b (+search.msn.com/msnbot.htm)._ Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; help.yahoo.com/help/us/ysearch/slurp) Pingdom.com_bot_version_1.4_(www.pingdom.com/) ia_archiver (+www.alexa.com/site/help/webmasters; [email protected]) Mozilla/5.0 (compatible; YandexBot/3.0; yandex.com/bots) Mozilla/5.0 (compatible; bingbot/2.0; www.bing.com/bingbot.htm) ClickTale bot “Mozilla/5.0 (compatible; MSIE 7.0; MSIE 6.0; ScanAlert; +www.scanalert.com/bot.jsp) Firefox/2.0.0.3” “HTTP-Monitor/1.1” “Simply Business Nagios v0.1” “CopperEgg/RevealUptime/LondonUK”
[ GOOGLE_RSS = Regexp.compile('Feedfetcher-Google.*\/'), GOOGLE_BOT = Regexp.compile('Googlebot.*\/'), MSN_BOT = Regexp.compile('msnbot\/'), YAHOO_BOT = Regexp.compile('Yahoo! Slurp\/?'), PINGDOM_BOT = Regexp.compile('Pingdom.com_bot_version_'), ALEXA_BOT = Regexp.compile('ia_archiver'), YANDEX_BOT = Regexp.compile('YandexBot\/'), BING_BOT = Regexp.compile('bingbot\/'), CLICKTALE_BOT = Regexp.compile('ClickTale bot'), SCANALERT_BOT = Regexp.compile('ScanAlert; '), STINGRAY_BOT = Regexp.compile('HTTP-Monitor\/'), SB_NAGIOS_BOT = Regexp.compile('Simply Business Nagios v'), COPPEREGG_BOT = Regexp.compile('CopperEgg/RevealUptime/LondonUK'), ]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#os ⇒ Object
Returns the value of attribute os.
Class Method Summary collapse
- .name_for_user_agent(string) ⇒ Object
- .os_for_user_agent(string) ⇒ Object
- .search_bot?(http_user_agent) ⇒ Boolean
Instance Method Summary collapse
-
#initialize(string) ⇒ SearchBot
constructor
A new instance of SearchBot.
- #search_bot? ⇒ Boolean
Constructor Details
#initialize(string) ⇒ SearchBot
Returns a new instance of SearchBot.
60 61 62 63 64 |
# File 'lib/ntail/http_user_agent.rb', line 60 def initialize(string) super string @name = self.class.name_for_user_agent(string) @os = self.class.os_for_user_agent(string) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
57 58 59 |
# File 'lib/ntail/http_user_agent.rb', line 57 def name @name end |
#os ⇒ Object
Returns the value of attribute os.
58 59 60 |
# File 'lib/ntail/http_user_agent.rb', line 58 def os @os end |
Class Method Details
.name_for_user_agent(string) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ntail/http_user_agent.rb', line 66 def self.name_for_user_agent string case string when GOOGLE_BOT then :googlebot when MSN_BOT then :msnbot when YAHOO_BOT then :yahoo_slurp when ALEXA_BOT then :ia_archiver when PINGDOM_BOT then :pingdom_bot when YANDEX_BOT then :yandex_bot when BING_BOT then :bingbot when CLICKTALE_BOT then :clicktale_bot when SCANALERT_BOT then :scanalert_bot when STINGRAY_BOT then :stingray_bot when SB_NAGIOS_BOT then :sb_nagios_bot when COPPEREGG_BOT then :copperegg_bot else super(string) end end |
.os_for_user_agent(string) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ntail/http_user_agent.rb', line 84 def self.os_for_user_agent string case string when GOOGLE_BOT then :"google.com" when MSN_BOT then :"msn.com" when YAHOO_BOT then :"yahoo.com" when ALEXA_BOT then :"alexa.com" when PINGDOM_BOT then :"pingdom.com" when YANDEX_BOT then :"yandex.com" when BING_BOT then :"bing.com" when CLICKTALE_BOT then :"clicktale.com" when SCANALERT_BOT then :"mcafeesecure.com" when STINGRAY_BOT then :"riverbed.com" when SB_NAGIOS_BOT then :"nagios.org" when COPPEREGG_BOT then :"copperegg.com" else super(string) end end |
.search_bot?(http_user_agent) ⇒ Boolean
53 54 55 |
# File 'lib/ntail/http_user_agent.rb', line 53 def self.search_bot?(http_user_agent) !KNOWN_SEARCH_BOTS.detect { |bot| bot.match(http_user_agent) }.nil? end |
Instance Method Details
#search_bot? ⇒ Boolean
14 15 16 |
# File 'lib/ntail/http_user_agent.rb', line 14 def search_bot? true end |