Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added IE support

  • Loading branch information...
commit 83825f46502f311577076eff71ac264b7a392db6 1 parent edb9708
@tj authored
View
1  lib/user-agent.rb
@@ -22,5 +22,4 @@
#++
require 'user-agent/agent'
-require 'user-agent/map'
require 'user-agent/version'
View
2  lib/user-agent/agent.rb
@@ -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
@@ -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
View
10 lib/user-agent/map.rb
@@ -1,10 +0,0 @@
-
-class Agent
-
- #--
- # Safari
- #++
-
- map :'Safari 3', :engine => :webkit, :version => /^52/, :popular => true
-
-end
View
19 spec/agents_spec.rb
@@ -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'],
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.