-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests and support for consoles [xbox, playstation, nintendo ds,…
… wii]
- Loading branch information
Showing
10 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Browserino | ||
module Console | ||
def self.name(ua) | ||
Browserino.extract_match( | ||
ua.match(Core::PATTERNS[:console][:name]), | ||
:name | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
require 'user_agents' | ||
require 'user_agents_consoles' | ||
|
||
describe 'Browserino console identification' do | ||
UserAgents::Consoles.constants(true).each do |console| | ||
agents = UserAgents::Consoles.const_get(console) | ||
agents.each do |ua, criteria| | ||
agent = Browserino.parse(ua) | ||
criteria.each do |prop, val| | ||
case prop | ||
when :console_name | ||
it "Expects agent.#{prop} to be #{val} for #{console.downcase}" do | ||
expect(agent.send(prop).downcase).to eq val.downcase | ||
end | ||
when :console? | ||
it "Expects agent.#{prop} to be #{val} for #{console.downcase}" do | ||
expect(agent.send(prop)).to eq val | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module UserAgents | ||
module Consoles | ||
XBOX = { | ||
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Xbox)' => { | ||
console_name: 'xbox', | ||
console?: true | ||
} | ||
} | ||
|
||
PLAYSTATION = { | ||
'Mozilla/5.0 (PLAYSTATION 3; 3.55)' => { | ||
console_name: 'playstation', | ||
console?: true | ||
}, | ||
'Mozilla/4.0 (PS3 (PlayStation 3); 1.00)' => { | ||
console_name: 'playstation', | ||
console?: true | ||
} | ||
} | ||
|
||
NINTENDO_DS = { | ||
'Bunjalloo/0.7.6(Nintendo DS;U;en)' => { | ||
console_name: 'nintendo_ds', | ||
console?: true | ||
} | ||
} | ||
|
||
WII = { | ||
'Opera/9.30 (Nintendo Wii; U; ; 2047-7; de)' => { | ||
console_name: 'wii', | ||
console?: true | ||
} | ||
} | ||
end | ||
end |