Skip to content

Commit

Permalink
added bingbot support
Browse files Browse the repository at this point in the history
  • Loading branch information
SidOfc committed Jan 4, 2016
1 parent 093decf commit d233bb4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -138,7 +138,7 @@ Browsers can also accept a float / integer to check for a specific version.

### DEPRECATION NOTICE

**Methods that include a version number in their name (`agent.android4?`) are deprecated as of version 2.0.0. Supply the version as argument instead `agent.android?(4)`**
**Methods that include a version number in their name (`agent.android4?`) are deprecated as of version 2.0.0. Supply the version as argument instead `agent.android?(4)` or `agent.android('Ice Cream Sandwich')`**

##### Supported systems

Expand Down Expand Up @@ -214,6 +214,7 @@ agent.not.maxthon?
agent.msnbot?
agent.yahoo_slurp?
agent.googlebot?
agent.bingbot?

# or with the .not method (v1.4.0+)
agent.not.msnbot?
Expand Down Expand Up @@ -281,6 +282,7 @@ Valid browser names are defined by __/lib/browserino/patterns.rb__ (the keys are
'googlebot'
'yahoo_slurp'
'msnbot'
'bingbot'
```

#### system_name examples
Expand Down
8 changes: 4 additions & 4 deletions lib/browserino.rb
Expand Up @@ -41,11 +41,11 @@ def self.cleanse(ua)
end

def self.check_for_aliases(hash)
h = {}
hash.each do |prop, val|
h[prop] = ALIAS[prop].select { |k, m| true if m.include?(val) }.keys.first || val
hash.inject({}) do |memo, kv|
ls = ALIAS[kv.first].select { |k, m| true if m.include?(kv.last) }.keys.first || kv.last
memo[kv.first] = ls
memo
end
h
end

def self.agent_id(ua)
Expand Down
16 changes: 4 additions & 12 deletions lib/browserino/patterns.rb
Expand Up @@ -58,18 +58,10 @@ module Browserino
},

bot: {
googlebot: {
name: /(?<name>googlebot)/i,
version: /googlebot\/(?<version>[\d\.]+)/i
},
yahoo_slurp: {
name: /(?<name>yahoo\!\sslurp)/i,
version: /\/(?<version>[\d\.]+)/i
},
msnbot: {
name: /(?<name>msnbot)/i,
version: /msnbot\/(?<version>[\d\.]+)/i
}
googlebot: { name: /(?<name>googlebot)/i },
yahoo_slurp: { name: /(?<name>yahoo\!\sslurp)/i },
msnbot: { name: /(?<name>msnbot)/i },
bingbot: { name: /(?<name>bingbot)/i }
},

engine: {
Expand Down
9 changes: 8 additions & 1 deletion spec/user_agents_bots.rb
Expand Up @@ -29,7 +29,14 @@ module Bots
bot_name: 'msnbot',
bot?: true,
known?: true
},
}
}
BINGBOT = {
'Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)' => {
bot_name: 'bingbot',
bot?: true,
known?: true
}
}
end
end

0 comments on commit d233bb4

Please sign in to comment.