Skip to content

Commit

Permalink
Added IE support
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Aug 28, 2009
1 parent edb9708 commit 83825f4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
1 change: 0 additions & 1 deletion lib/user-agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@
#++

require 'user-agent/agent'
require 'user-agent/map'
require 'user-agent/version'
2 changes: 2 additions & 0 deletions lib/user-agent/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def self.engine_version_for_user_agent string
def self.version_for_user_agent string
case string
when /safari/i ; $1 if string =~ /Version\/([\d\w\.]+)/i
when /msie/i ; $1 if string =~ /MSIE\s*([\d\w\.]+)/i
end
end

Expand Down Expand Up @@ -131,6 +132,7 @@ def self.name_for_user_agent string
case string
when /chrome/i ; :Chrome
when /safari/i ; :Safari
when /msie/i ; :IE
else ; :Unknown
end
end
Expand Down
10 changes: 0 additions & 10 deletions lib/user-agent/map.rb

This file was deleted.

19 changes: 18 additions & 1 deletion spec/agents_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
describe "Safari" do
[
['4.0dp1', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8'],
['4.0dp1', 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20081212 Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8'],
['4.0.3', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9'],
['4.0.2', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532+ (KHTML, like Gecko) Version/4.0.2 Safari/530.19.1'],
['4.0.1', 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/4.0.1 Safari/530.18'],
Expand All @@ -18,4 +17,22 @@
end
end
end

describe "IE" do
[
['8.0', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)'],
['7.0b', 'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30)'],
['7.0', 'Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; c .NET CLR 3.0.04506; .NET CLR 3.5.30707; InfoPath.1; el-GR)'],
['6.1', 'Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)'],
['6.0b', 'Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)'],
['6.0', 'Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)'],
].each do |version, string|
unless version.empty?
it "should parse version '#{version}'" do
Agent.new(string).name.should == :IE
Agent.new(string).version.should == version
end
end
end
end
end

0 comments on commit 83825f4

Please sign in to comment.