babu3009-user-agent 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4b6955b1a8d49c80641fe63c1bd834c79013f97
4
+ data.tar.gz: 8b599343210578d5cc643162a1bf3b16823248e2
5
+ SHA512:
6
+ metadata.gz: 42e6ba2840bd46e1a1472562f5c73cd56b790e1402fdf729cd905ed0e75142c6a53c14101cfba2dbc77c991b7f15f5984042413fc79c3b1a577fd45c19f92a43
7
+ data.tar.gz: babb77069eec26c183271dda0d8cae559ec43224e24944fb52e30bb4c1d7aedfa9eb8e19e39effaf5229c6664d3f02594d59e1481f9d9965d1cdb6c265d116fe
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ *.gem
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create 1.9.2@user-agent
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/README.rdoc ADDED
@@ -0,0 +1,52 @@
1
+
2
+ = User Agent
3
+
4
+ User agent parser.
5
+
6
+ == Example
7
+
8
+ agent = Agent.new 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9'
9
+ agent.name # => :Safari
10
+ agent.version # => '4.0.3'
11
+ agent.engine # => :webkit
12
+ agent.os # => :'Windows Vista'
13
+ agent.platform # => :Windows
14
+ agent.engine_version # => '531.9'
15
+
16
+ == Supported Agents
17
+
18
+ * Safari
19
+ * Chrome
20
+ * Opera
21
+ * IE
22
+ * Konqueror
23
+ * PS3
24
+ * PSP
25
+ * Wii
26
+ * iPad
27
+ * iPhone
28
+
29
+ == License:
30
+
31
+ (The MIT License)
32
+
33
+ Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining
36
+ a copy of this software and associated documentation files (the
37
+ 'Software'), to deal in the Software without restriction, including
38
+ without limitation the rights to use, copy, modify, merge, publish,
39
+ distribute, sublicense, an d/or sell copies of the Software, and to
40
+ permit persons to whom the Software is furnished to do so, subject to
41
+ the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be
44
+ included in all copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
47
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
49
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
50
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
51
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
52
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir['tasks/**/*.rake'].sort.each { |f| load f }
4
+
5
+ task :default => :spec
@@ -0,0 +1,23 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ require 'user-agent/version'
3
+
4
+ Gem::Specification.new do |s|
5
+
6
+ s.name = 'babu3009-user-agent'
7
+ s.version = UserAgent::VERSION
8
+ s.authors = ['babu3009, original dev: TJ Holowaychuk']
9
+ s.email = 'babu3009@gmail.com'
10
+ s.homepage = 'http://github.com/babu3009/user-agent'
11
+ s.summary = 'User agent parser'
12
+ s.description = 'user-agent is a user agent parser support most of the commonly used browsers today.'
13
+ s.rubyforge_project = 'babu3009-user-agent'
14
+ s.require_paths = ['lib']
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- spec/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
+
20
+ s.add_development_dependency 'rake'
21
+ s.add_development_dependency 'rspec'
22
+
23
+ end
@@ -0,0 +1,266 @@
1
+ module UserAgent
2
+
3
+ class ParsedUserAgent
4
+
5
+ attr_reader :string
6
+
7
+ def initialize string
8
+ @string = string.strip
9
+ end
10
+
11
+ def name
12
+ ParsedUserAgent.name_for_user_agent string
13
+ end
14
+
15
+ def version
16
+ ParsedUserAgent.version_for_user_agent string
17
+ end
18
+
19
+ def engine
20
+ ParsedUserAgent.engine_for_user_agent string
21
+ end
22
+
23
+ def engine_version
24
+ ParsedUserAgent.engine_version_for_user_agent string
25
+ end
26
+
27
+ def os
28
+ ParsedUserAgent.os_for_user_agent string
29
+ end
30
+
31
+ def system_type
32
+ ParsedUserAgent.system_type_for_user_agent string
33
+ end
34
+
35
+ def platform
36
+ ParsedUserAgent.platform_for_user_agent string
37
+ end
38
+
39
+ def device
40
+ ParsedUserAgent.device_for_user_agent string
41
+ end
42
+
43
+ def to_s
44
+ string
45
+ end
46
+
47
+ def inspect
48
+ "#<ParsedUserAgent:#{name} version:#{version.inspect} engine:\"#{engine.to_s}:#{engine_version}\" os:#{os.to_s.inspect}>"
49
+ end
50
+
51
+ def == other
52
+ string == other.string
53
+ end
54
+
55
+ def self.engine_version_for_user_agent string
56
+ $1 if string =~ /#{engine_for_user_agent(string)}[\/ ]([\d\w\.\-]+)/i
57
+ end
58
+
59
+ def self.version_for_user_agent string
60
+ case name = name_for_user_agent(string)
61
+ when :ChromeFrame;
62
+ $1 if string =~ /chromeframe\/([\d\s\.\-]+)/i
63
+ when :Chrome;
64
+ $1 if string =~ /chrome\/([\d\w\.\-]+)/i
65
+ when :Safari;
66
+ $1 if string =~ /version\/([\d\w\.\-]+)/i
67
+ when :PS3;
68
+ $1 if string =~ /([\d\w\.\-]+)\)\s*$/i
69
+ when :PSP;
70
+ $1 if string =~ /([\d\w\.\-]+)\)?\s*$/i
71
+ when :"IE Mobile";
72
+ $1 if string =~ /iemobile\/([\d\.]+)/i
73
+ else
74
+ $1 if string =~ /#{name}[\/ ]([\d\w\.\-]+)/i || string =~ /rv\:([\d\.]+)/i
75
+ end
76
+ end
77
+
78
+ def self.engine_for_user_agent string
79
+ case string
80
+ when /webkit/i;
81
+ :webkit
82
+ when /khtml/i;
83
+ :khtml
84
+ when /konqueror/i;
85
+ :konqueror
86
+ when /chrome/i;
87
+ :chrome
88
+ when /presto/i;
89
+ :presto
90
+ when /trident.*like gecko/i;
91
+ :msie
92
+ when /gecko/i;
93
+ :gecko
94
+ when /msie/i;
95
+ :msie
96
+ else
97
+ :Unknown
98
+ end
99
+ end
100
+
101
+ def self.os_for_user_agent string
102
+ case string
103
+ when /windows nt 6\.0/i;
104
+ :'Windows Vista'
105
+ when /windows nt 6\.3/i;
106
+ :'Windows 8.1'
107
+ when /windows nt 6\.2/i;
108
+ :'Windows 8'
109
+ when /windows nt 6\.1/i;
110
+ :'Windows 7'
111
+ when /windows nt 5\.2/i;
112
+ :'Windows 2003'
113
+ when /windows nt 5\.1/i;
114
+ :'Windows XP'
115
+ when /windows nt 5\.0/i;
116
+ :'Windows 2000'
117
+ when /windows phone os ([^;]+);/i;
118
+ :"Windows Phone OS #{$1}"
119
+ when /os x (\d+)[._](\d+)/i;
120
+ :"OS X #{$1}.#{$2}"
121
+ when /android ([^;]+);/i;
122
+ :"Android #{$1}"
123
+ when /linux/i;
124
+ :Linux
125
+ when /wii/i;
126
+ :Wii
127
+ when /playstation 3/i;
128
+ :Playstation
129
+ when /playstation portable/i;
130
+ :Playstation
131
+ when /ipad.*os (\d+)[._](\d+)[._](\d+)/i;
132
+ :"iOS #{$1}.#{$2}.#{$3}"
133
+ when /\(ipad.*os (\d+)[._](\d+)/i;
134
+ :"iOS #{$1}.#{$2}"
135
+ when /iphone.*os (\d+)[._](\d+)[._](\d+)/i;
136
+ :"iOS #{$1}.#{$2}.#{$3}"
137
+ when /iphone.*os (\d+)[._](\d+)/i;
138
+ :"iOS #{$1}.#{$2}"
139
+ when /webos\/([^;]+);/i;
140
+ :"webOS #{$1}"
141
+ when /os x/i;
142
+ :"OS X"
143
+ when /cros i\d{3} ([^\)]+)\)/i;
144
+ :"ChromeOS #{$1}"
145
+ when /rim tablet os ([^;]+);/i;
146
+ :"RIM Tablet OS #{$1}"
147
+ when /blackberry(\d+)\/([^\s]+)\s/i;
148
+ :"RIM OS #{$2}"
149
+ when /blackberry ([^;]+);/i;
150
+ :"RIM OS"
151
+ else
152
+ ; :Unknown
153
+ end
154
+ end
155
+
156
+ #x86_64
157
+ def self.system_type_for_user_agent string
158
+ case string
159
+ when /wow64/i;
160
+ :"64-bit"
161
+ when /win64/i;
162
+ :"64-bit"
163
+ when /x64/i;
164
+ :"64-bit"
165
+ when /x86_64/i;
166
+ :"64-bit"
167
+ when /ARM/i;
168
+ :RT_ARM
169
+ when /arm/i;
170
+ :RT_ARM
171
+ else
172
+ :"32-bit"
173
+ end
174
+ end
175
+
176
+ def self.platform_for_user_agent string
177
+ case string
178
+ when /windows phone/i;
179
+ :"Windows Phone"
180
+ when /windows/i;
181
+ :Windows
182
+ when /macintosh/i;
183
+ :Macintosh
184
+ when /android/i;
185
+ :Android
186
+ when /linux/i;
187
+ :Linux
188
+ when /wii/i;
189
+ :Wii
190
+ when /playstation/i;
191
+ :Playstation
192
+ when /ipod/i;
193
+ :iPod
194
+ when /ipad/i;
195
+ :iPad
196
+ when /iphone/i;
197
+ :iPhone
198
+ when /blackberry/i;
199
+ :BlackBerry
200
+ when /playbook/i;
201
+ :PlayBook
202
+ when /webos/i;
203
+ :webOS
204
+ when /cros/i;
205
+ :ChromeOS
206
+ else
207
+ :Unknown
208
+ end
209
+ end
210
+
211
+ def self.name_for_user_agent string
212
+ case string
213
+ when /konqueror/i;
214
+ :Konqueror
215
+ when /chromeframe/i;
216
+ :ChromeFrame
217
+ when /chrome/i;
218
+ :Chrome
219
+ when /mobile safari/i;
220
+ :"Mobile Safari"
221
+ when /safari/i;
222
+ :Safari
223
+ when /iemobile/i;
224
+ :"IE Mobile"
225
+ when /msie/i;
226
+ :IE
227
+ when /trident.*rv\:11/i;
228
+ :IE # "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"
229
+ when /opera/i;
230
+ :Opera
231
+ when /playstation 3/i;
232
+ :PS3
233
+ when /playstation portable/i;
234
+ :PSP
235
+ when /firefox/i;
236
+ :Firefox
237
+ when /ipad|iphone|ipod/i;
238
+ :"Mobile Safari"
239
+ when /blackberry/i;
240
+ :"BlackBerrry"
241
+ else
242
+ ; :Unknown
243
+ end
244
+ end
245
+
246
+ def self.device_for_user_agent string
247
+ case platform = platform_for_user_agent(string)
248
+ when :Windows, :Macintosh, :Linux, :ChromeOS;
249
+ :Desktop
250
+ when :iPod, :iPad, :iPhone, :BlackBerry, :PlayBook, :Android, :webOS, :"Windows Phone";
251
+ :Mobile
252
+ when :Wii, :Playstation;
253
+ :"Game Console"
254
+ else
255
+ ; :Unknown
256
+ end
257
+ end
258
+
259
+ @agents = []
260
+
261
+ def self.map name, options = {}
262
+ @agents << [name, options]
263
+ end
264
+
265
+ end
266
+ end
@@ -0,0 +1,3 @@
1
+ module UserAgent
2
+ VERSION = '1.2.3'
3
+ end
data/lib/user-agent.rb ADDED
@@ -0,0 +1,33 @@
1
+ #--
2
+ # Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ require 'user-agent/agent'
25
+ require 'user-agent/version'
26
+
27
+ module UserAgent
28
+
29
+ def self.parse string
30
+ ParsedUserAgent.new string
31
+ end
32
+
33
+ end
@@ -0,0 +1,64 @@
1
+
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe UserAgent::ParsedUserAgent do
5
+ before :each do
6
+ @agent = UserAgent::ParsedUserAgent.new 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/528.4+ (KHTML, like Gecko) Version/4.0dp1 Safari/526.11.2'
7
+ end
8
+
9
+ describe "#initialize" do
10
+ it "should allow a user agent string to be passed" do
11
+ UserAgent::ParsedUserAgent.new('foo').string.should == 'foo'
12
+ end
13
+ end
14
+
15
+ describe "#os" do
16
+ it "should return operating system symbol" do
17
+ @agent.os.should == :'OS X 10.5'
18
+ end
19
+ end
20
+
21
+ describe "#engine" do
22
+ it "should return engine symbol" do
23
+ @agent.engine.should == :webkit
24
+ end
25
+ end
26
+
27
+ describe "#engine_version" do
28
+ it "should return engine version" do
29
+ @agent.engine_version.should == '528.4'
30
+ end
31
+ end
32
+
33
+ describe "#to_s" do
34
+ it "should return the user agent string" do
35
+ @agent.to_s.should == @agent.string
36
+ end
37
+ end
38
+
39
+ describe "#inspect" do
40
+ it "should return string presenting the engine, os, version, etc" do
41
+ @agent.inspect.should == '#<ParsedUserAgent:Safari version:"4.0dp1" engine:"webkit:528.4" os:"OS X 10.5">'
42
+ end
43
+ end
44
+
45
+ describe "#name" do
46
+ it "should return the agent name symbol" do
47
+ @agent.name.should == :'Safari'
48
+ end
49
+ end
50
+
51
+ describe "#==" do
52
+ it "should be equal when the user agent strings are the same" do
53
+ a = UserAgent::ParsedUserAgent.new 'foo'
54
+ b = UserAgent::ParsedUserAgent.new 'foo'
55
+ a.should == b
56
+ end
57
+
58
+ it "should not be equal when user agent strings are different" do
59
+ a = UserAgent::ParsedUserAgent.new 'foo'
60
+ b = UserAgent::ParsedUserAgent.new 'bar'
61
+ a.should_not == b
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,80 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ def test name, version, platform, os, engine, engine_version, string
4
+ it "should parse #{name} #{version} on #{os} with engine #{engine} #{engine_version}" do
5
+ agent = UserAgent.parse string
6
+ agent.name.should == name
7
+ agent.os.should == os
8
+ agent.platform.should == platform
9
+ agent.engine.should == engine
10
+ agent.version.should == version
11
+ agent.engine_version.should == engine_version
12
+ end
13
+ end
14
+
15
+ describe UserAgent do
16
+
17
+ test :Safari, '4.0dp1', :Windows, :'Windows XP', :webkit, '526.9', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8'
18
+ test :Safari, '4.0.3', :Windows, :'Windows Vista', :webkit, '531.9', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9'
19
+ test :Safari, '4.0.2', :Windows, :'Windows 7', :webkit, '532', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532+ (KHTML, like Gecko) Version/4.0.2 Safari/530.19.1'
20
+ test :Safari, '4.0.1', :Macintosh, :'OS X 10.5', :webkit, '531.2', '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'
21
+ test :Safari, '4.0', :Windows, :'Windows Vista', :webkit, '528.16', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; ru-RU) AppleWebKit/528.16 (KHTML, like Gecko) Version/4.0 Safari/528.16'
22
+ test :Safari, '3.2.3', :Windows, :'Windows XP', :webkit, '525.28.3', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.29'
23
+
24
+ test :Safari, '4.0.4', :iPad, :'iOS 3.2', :webkit, '531.21.10', 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10'
25
+ test :Safari, '4.0.4', :iPad, :'iOS 3.2', :webkit, '531.21.10', 'Mozilla/5.0 (iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10'
26
+
27
+ test :Safari, '4.0', :iPhone, :'iOS 3.0', :webkit, '528.18', 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'
28
+
29
+ test :IE, '11.0', :Windows, :'Windows 8', :msie, nil, 'Mozilla/5.0 (Windows NT 6.2; Trident/7.0; rv:11.0) like Gecko'
30
+ test :IE, '11.0', :Windows, :'Windows 7', :msie, nil, 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
31
+ test :IE, '10.0', :Windows, :'Windows 8', :msie, '10.0', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)'
32
+ test :IE, '10.0', :Windows, :'Windows 7', :msie, '10.0', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)'
33
+ test :IE, '9.0', :Windows, :'Windows 7', :msie, '9.0', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)'
34
+ test :IE, '8.0', :Windows, :'Windows 7', :msie, '8.0', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)'
35
+ test :IE, '7.0b', :Windows, :'Windows 2003', :msie, '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)'
36
+ test :IE, '7.0', :Windows, :'Windows XP', :msie, '7.0', "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2)"
37
+ test :IE, '7.0', :Windows, :'Windows XP', :msie, '7.0', "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; MSOffice 12)"
38
+ test :IE, '6.0b', :Windows, :'Windows XP', :msie, '6.0b', 'Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)'
39
+ test :IE, '6.0', :Windows, :'Windows XP', :msie, '6.0', 'Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)'
40
+
41
+ test :Opera, '9.99', :Windows, :'Windows XP', :presto, '9.9.9', 'Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9'
42
+ test :Opera, '9.70', :Linux, :Linux, :gecko, '20061208', 'Mozilla/5.0 (Linux i686 ; U; en; rv:1.8.1) Gecko/20061208 Firefox/2.0.0 Opera 9.70'
43
+ test :Opera, '9.64', :Linux, :Linux, :presto, '2.1.1', 'Opera/9.64 (X11; Linux i686; U; Linux Mint; it) Presto/2.1.1'
44
+ test :Opera, '9.00', :Wii, :Wii, :Unknown, nil, 'Opera/9.00 (Nintindo Wii; U; ; 103858; Wii Shop Channel/1.0; en)'
45
+
46
+ test :Chrome, '4.0.202.2', :Linux, :Linux, :webkit, '532.0', 'Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/4.0.202.2 Safari/532.0'
47
+ test :Chrome, '0.2.149.27', :Windows, :'Windows 2003', :webkit, '525.13', 'Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13'
48
+ test :Chrome, '0.2.149.30', :Windows, :'Windows Vista', :webkit, '525.13', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.30 Safari/525.13'
49
+
50
+ test :Konqueror, '4.2', :Linux, :Linux, :khtml, '4.2.4', 'Mozilla/5.0 (compatible; Konqueror/4.2; Linux; X11; x86_64) KHTML/4.2.4 (like Gecko) Fedora/4.2.4-2.fc11'
51
+ test :Konqueror, '3.1-rc6', :Linux, :Linux, :konqueror, '3.1-rc6', 'Mozilla/5.0 (compatible; Konqueror/3.1-rc6; i686 Linux; 20021105)'
52
+
53
+ test :PS3, '2.00', :Playstation, :Playstation, :Unknown, nil, 'Mozilla/5.0 (PLAYSTATION 3; 2.00)'
54
+ test :PS3, '1.10', :Playstation, :Playstation, :Unknown, nil, 'Mozilla/5.0 (PLAYSTATION 3; 1.10)'
55
+
56
+ test :PSP, '2.00', :Playstation, :Playstation, :Unknown, nil, 'PSP (PlayStation Portable); 2.00'
57
+ test :PSP, '2.00', :Playstation, :Playstation, :Unknown, nil, 'Mozilla/4.0 (PSP (PlayStation Portable); 2.00)'
58
+
59
+ test :Firefox, '3.5', :Linux, :Linux, :gecko, '20090624', 'Mozilla/5.0 (X11;U; Linux i686; en-GB; rv:1.9.1) Gecko/20090624 Ubuntu/9.04 (jaunty) Firefox/3.5'
60
+ test :Firefox, '3.5', :Windows, :'Windows 7', :gecko, '20090612', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1) Gecko/20090612 Firefox/3.5'
61
+ test :Firefox, '3.1', :Windows, :'Windows XP', :gecko, '2009011606', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6pre) Gecko/2009011606 Firefox/3.1'
62
+ test :Firefox, '3.0', :Linux, :Linux, :gecko, '2008062315', 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9) Gecko/2008062315 (Gentoo) Firefox/3.0'
63
+ test :Firefox, '2.0', :Linux, :Linux, :gecko, '20061202', 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1) Gecko/20061202 Firefox/2.0'
64
+
65
+ test :Chrome, '6.0.472.62', :Macintosh, :'OS X 10.6', :webkit, '534.3', "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.62 Safari/534.3"
66
+ test :Chrome, '6.0.472.63', :Macintosh, :'OS X 10.6', :webkit, '534.3', "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3"
67
+ test :Chrome, '6.0.472.55', :Linux, :Linux, :webkit, '534.3', "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.55 Safari/534.3"
68
+ test :Chrome, '5.0.375.127', :Windows, :'Windows XP', :webkit, '533.4', "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4"
69
+ test :Chrome, '6.0.472.59', :Windows, :'Windows XP', :webkit, '534.3', "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.59 Safari/534.3"
70
+ test :Chrome, '6.0.472.53', :Linux, :Linux, :webkit, '534.3', "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.53 Safari/534.3"
71
+
72
+ test :Firefox, '3.5.13', :Windows, :'Windows XP', :gecko, '20100914', "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.13) Gecko/20100914 Firefox/3.5.13 (.NET CLR 3.5.30729)"
73
+ test :Firefox, '3.6.10', :Windows, :'Windows XP', :gecko, '20100914', "Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-BR; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10 GTB7.1"
74
+ test :Firefox, '3.6.10', :Windows, :'Windows Vista', :gecko, '20100914', "Mozilla/5.0 (Windows; U; Windows NT 6.0; pt-BR; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10 GTB7.1 ( .NET CLR 3.5.30729)"
75
+
76
+ test :Firefox, '3.6.8', :Linux, :Linux, :gecko, '20100723', "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/9.10 (karmic) Firefox/3.6.8"
77
+ test :Firefox, '3.6.9', :Linux, :Linux, :gecko, '20100824', "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.9) Gecko/20100824 Firefox/3.6.9"
78
+ test :Firefox, '3.6.9', :Linux, :Linux, :gecko, '20100825', "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100825 Ubuntu/10.04 (lucid) Firefox/3.6.9"
79
+
80
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format specdoc
@@ -0,0 +1,3 @@
1
+
2
+ $:.unshift File.dirname(__FILE__) + '/../lib'
3
+ require 'user-agent'
data/tasks/spec.rake ADDED
@@ -0,0 +1,4 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc 'Run all specifications'
4
+ RSpec::Core::RakeTask.new(:spec)
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: babu3009-user-agent
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.3
5
+ platform: ruby
6
+ authors:
7
+ - 'babu3009, original dev: TJ Holowaychuk'
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: user-agent is a user agent parser support most of the commonly used browsers
42
+ today.
43
+ email: babu3009@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .rvmrc
50
+ - Gemfile
51
+ - README.rdoc
52
+ - Rakefile
53
+ - cv-user-agent.gemspec
54
+ - lib/user-agent.rb
55
+ - lib/user-agent/agent.rb
56
+ - lib/user-agent/version.rb
57
+ - spec/agent_spec.rb
58
+ - spec/agents_spec.rb
59
+ - spec/spec.opts
60
+ - spec/spec_helper.rb
61
+ - tasks/spec.rake
62
+ homepage: http://github.com/babu3009/user-agent
63
+ licenses: []
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project: babu3009-user-agent
81
+ rubygems_version: 2.2.2
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: User agent parser
85
+ test_files:
86
+ - spec/agent_spec.rb
87
+ - spec/agents_spec.rb
88
+ - spec/spec.opts
89
+ - spec/spec_helper.rb
90
+ has_rdoc: