user_agent 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/Gemfile +8 -0
- data/LICENSE +22 -0
- data/README.rdoc +52 -0
- data/Rakefile +7 -0
- data/lib/user_agent.rb +187 -0
- data/lib/user_agent/version.rb +3 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/user_agent_spec.rb +95 -0
- data/spec/user_agents_spec.rb +58 -0
- data/user_agent.gemspec +19 -0
- metadata +83 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
+
#++
|
data/README.rdoc
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
= User Agent
|
2
|
+
|
3
|
+
User agent parser.
|
4
|
+
|
5
|
+
== Example
|
6
|
+
|
7
|
+
agent = UserAgent.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')
|
8
|
+
agent.name # => :safari
|
9
|
+
agent.version # => '4.0.3'
|
10
|
+
agent.engine # => :webkit
|
11
|
+
agent.engine_version # => '531.9'
|
12
|
+
agent.platform # => :windows
|
13
|
+
agent.os # => 'Windows Vista'
|
14
|
+
|
15
|
+
== Supported Agents
|
16
|
+
|
17
|
+
* Safari
|
18
|
+
* Chrome
|
19
|
+
* Firefox
|
20
|
+
* Opera
|
21
|
+
* IE
|
22
|
+
* Konqueror
|
23
|
+
* PS3
|
24
|
+
* PSP
|
25
|
+
* Wii
|
26
|
+
|
27
|
+
== Install
|
28
|
+
|
29
|
+
$ gem install user_agent
|
30
|
+
|
31
|
+
== Note on Patches/Pull Requests
|
32
|
+
|
33
|
+
* Fork the project.
|
34
|
+
* Make your feature addition or bug fix.
|
35
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
36
|
+
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
37
|
+
* Send me a pull request. Bonus points for topic branches.
|
38
|
+
|
39
|
+
== Copyright
|
40
|
+
|
41
|
+
See LICENSE for details.
|
42
|
+
|
43
|
+
== Maintenance
|
44
|
+
|
45
|
+
Originally written by TJ Holowaychuk, but I (John Nunemaker) will be maintaining this fork of it for the forseeable future.
|
46
|
+
|
47
|
+
== Verified Ruby Versions
|
48
|
+
|
49
|
+
* REE 1.8.7
|
50
|
+
* MRI 1.9.2
|
51
|
+
|
52
|
+
Should work on all, but these are the ones I will for sure be checking against.
|
data/Rakefile
ADDED
data/lib/user_agent.rb
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
class UserAgent
|
2
|
+
|
3
|
+
AttributesForInspect = [:name, :version, :os, :platform, :engine, :engine_version]
|
4
|
+
|
5
|
+
module Engines
|
6
|
+
Webkit = /webkit/i
|
7
|
+
Khtml = /khtml/i
|
8
|
+
Konqueror = /konqueror/i
|
9
|
+
Chrome = /chrome/i
|
10
|
+
Presto = /presto/i
|
11
|
+
Gecko = /gecko/i
|
12
|
+
Msie = /msie/i
|
13
|
+
end
|
14
|
+
|
15
|
+
module Versions
|
16
|
+
Chrome = /chrome\/([\d\w\.\-]+)/i
|
17
|
+
Safari = /version\/([\d\w\.\-]+)/i
|
18
|
+
Ps3 = /([\d\w\.\-]+)\)\s*$/i
|
19
|
+
Psp = /([\d\w\.\-]+)\)?\s*$/i
|
20
|
+
end
|
21
|
+
|
22
|
+
module Browsers
|
23
|
+
Konqueror = /konqueror/i
|
24
|
+
Chrome = /chrome/i
|
25
|
+
Safari = /safari/i
|
26
|
+
IE = /msie/i
|
27
|
+
Opera = /opera/i
|
28
|
+
PS3 = /playstation 3/i
|
29
|
+
PSP = /playstation portable/i
|
30
|
+
Firefox = /firefox/i
|
31
|
+
end
|
32
|
+
|
33
|
+
module OS
|
34
|
+
WindowsVista = /windows nt 6\.0/i
|
35
|
+
Windows7 = /windows nt 6\.\d+/i
|
36
|
+
Windows2003 = /windows nt 5\.2/i
|
37
|
+
WindowsXP = /windows nt 5\.1/i
|
38
|
+
Windows2000 = /windows nt 5\.0/i
|
39
|
+
OSX = /os x (\d+)[._](\d+)/i
|
40
|
+
Linux = /linux/i
|
41
|
+
Wii = /wii/i
|
42
|
+
PS3 = /playstation 3/i
|
43
|
+
PSP = /playstation portable/i
|
44
|
+
Ipad = /\(iPad.*os (\d+)[._](\d+)/i
|
45
|
+
Iphone = /\(iPhone.*os (\d+)[._](\d+)/i
|
46
|
+
end
|
47
|
+
|
48
|
+
module Platform
|
49
|
+
Windows = /windows/i
|
50
|
+
Mac = /macintosh/i
|
51
|
+
Linux = /linux/i
|
52
|
+
Wii = /wii/i
|
53
|
+
Playstation = /playstation/i
|
54
|
+
Ipad = /ipad/i
|
55
|
+
Iphone = /iphone/i
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.engine(string)
|
59
|
+
case string
|
60
|
+
when Engines::Webkit then :webkit
|
61
|
+
when Engines::Khtml then :khtml
|
62
|
+
when Engines::Konqueror then :konqueror
|
63
|
+
when Engines::Chrome then :chrome
|
64
|
+
when Engines::Presto then :presto
|
65
|
+
when Engines::Gecko then :gecko
|
66
|
+
when Engines::Msie then :msie
|
67
|
+
else
|
68
|
+
:unknown
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.engine_version(string)
|
73
|
+
if string =~ /#{engine(string)}[\/ ]([\d\w\.\-]+)/i
|
74
|
+
$1
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.browser_name(string)
|
79
|
+
case string
|
80
|
+
when Browsers::Konqueror then :konqueror
|
81
|
+
when Browsers::Chrome then :chrome
|
82
|
+
when Browsers::Safari then :safari
|
83
|
+
when Browsers::IE then :ie
|
84
|
+
when Browsers::Opera then :opera
|
85
|
+
when Browsers::PS3 then :ps3
|
86
|
+
when Browsers::PSP then :psp
|
87
|
+
when Browsers::Firefox then :firefox
|
88
|
+
else
|
89
|
+
:unknown
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.browser_version(string)
|
94
|
+
case name = browser_name(string)
|
95
|
+
when :chrome
|
96
|
+
$1 if string =~ Versions::Chrome
|
97
|
+
when :safari
|
98
|
+
$1 if string =~ Versions::Safari
|
99
|
+
when :ps3
|
100
|
+
$1 if string =~ Versions::Ps3
|
101
|
+
when :psp
|
102
|
+
$1 if string =~ Versions::Psp
|
103
|
+
else
|
104
|
+
$1 if string =~ /#{name}[\/ ]([\d\w\.\-]+)/i
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.os(string)
|
109
|
+
case string
|
110
|
+
when OS::WindowsVista then 'Windows Vista'
|
111
|
+
when OS::Windows7 then 'Windows 7'
|
112
|
+
when OS::Windows2003 then 'Windows 2003'
|
113
|
+
when OS::WindowsXP then 'Windows XP'
|
114
|
+
when OS::Windows2000 then 'Windows 2000'
|
115
|
+
when OS::OSX then "OS X #{$1}.#{$2}"
|
116
|
+
when OS::Linux then 'Linux'
|
117
|
+
when OS::Wii then 'Wii'
|
118
|
+
when OS::PS3 then 'Playstation'
|
119
|
+
when OS::PSP then 'Playstation'
|
120
|
+
when OS::Ipad then "iPad OS #{$1}.#{$2}"
|
121
|
+
when OS::Iphone then "iPhone OS #{$1}.#{$2}"
|
122
|
+
else
|
123
|
+
'Unknown'
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.platform(string)
|
128
|
+
case string
|
129
|
+
when Platform::Windows then :windows
|
130
|
+
when Platform::Mac then :macintosh
|
131
|
+
when Platform::Linux then :linux
|
132
|
+
when Platform::Wii then :wii
|
133
|
+
when Platform::Playstation then :playstation
|
134
|
+
when Platform::Ipad then :ipad
|
135
|
+
when Platform::Iphone then :iphone
|
136
|
+
else
|
137
|
+
:unknown
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
attr_reader :source
|
142
|
+
|
143
|
+
def initialize(source)
|
144
|
+
@source = source.strip
|
145
|
+
end
|
146
|
+
|
147
|
+
def name
|
148
|
+
@name ||= self.class.browser_name(source)
|
149
|
+
end
|
150
|
+
|
151
|
+
def version
|
152
|
+
@version ||= self.class.browser_version(source)
|
153
|
+
end
|
154
|
+
|
155
|
+
def engine
|
156
|
+
@engine ||= self.class.engine(source)
|
157
|
+
end
|
158
|
+
|
159
|
+
def engine_version
|
160
|
+
@engine_version ||= self.class.engine_version(source)
|
161
|
+
end
|
162
|
+
|
163
|
+
def os
|
164
|
+
@os ||= self.class.os(source)
|
165
|
+
end
|
166
|
+
|
167
|
+
def platform
|
168
|
+
@platform ||= self.class.platform(source)
|
169
|
+
end
|
170
|
+
|
171
|
+
def to_s
|
172
|
+
@source
|
173
|
+
end
|
174
|
+
|
175
|
+
def inspect
|
176
|
+
attributes_as_nice_string = AttributesForInspect.map do |name|
|
177
|
+
"#{name}: #{send(name).inspect}"
|
178
|
+
end.join(', ')
|
179
|
+
|
180
|
+
"#<#{self.class}: #{attributes_as_nice_string}>"
|
181
|
+
end
|
182
|
+
|
183
|
+
def eql?(other)
|
184
|
+
self.class.eql?(other.class) && source == other.source
|
185
|
+
end
|
186
|
+
alias :== :eql?
|
187
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift(File.expand_path('../../lib', __FILE__))
|
2
|
+
|
3
|
+
require 'user_agent'
|
4
|
+
require 'pathname'
|
5
|
+
require 'logger'
|
6
|
+
|
7
|
+
root_path = Pathname(__FILE__).dirname.join('..').expand_path
|
8
|
+
lib_path = root_path.join('lib')
|
9
|
+
log_path = root_path.join('log')
|
10
|
+
log_path.mkpath
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'bundler'
|
14
|
+
|
15
|
+
Bundler.require(:development)
|
16
|
+
|
17
|
+
logger = Logger.new(log_path.join('test.log'))
|
18
|
+
LogBuddy.init(:logger => logger)
|
19
|
+
|
20
|
+
Rspec.configure do |c|
|
21
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe UserAgent do
|
4
|
+
before(:each) do
|
5
|
+
@agent = UserAgent.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'
|
6
|
+
end
|
7
|
+
|
8
|
+
describe ".engine_version" do
|
9
|
+
it "can detect webkit" do
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#initialize" do
|
15
|
+
it "should allow a user agent string to be passed" do
|
16
|
+
UserAgent.new('foo').source.should == 'foo'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#os" do
|
21
|
+
it "should return operating system symbol" do
|
22
|
+
@agent.os.should == 'OS X 10.5'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#engine" do
|
27
|
+
it "should return engine symbol" do
|
28
|
+
@agent.engine.should == :webkit
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#engine_version" do
|
33
|
+
it "should return engine version" do
|
34
|
+
@agent.engine_version.should == '528.4'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#to_s" do
|
39
|
+
it "should return the user agent string" do
|
40
|
+
@agent.to_s.should == @agent.source
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#inspect" do
|
45
|
+
it "should return string presenting the engine, os, version, etc" do
|
46
|
+
@agent.inspect.should == '#<UserAgent: name: :safari, version: "4.0dp1", os: "OS X 10.5", platform: :macintosh, engine: :webkit, engine_version: "528.4">'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#name" do
|
51
|
+
it "should return the agent name symbol" do
|
52
|
+
@agent.name.should == :safari
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#eql?" do
|
57
|
+
it "returns true for same source" do
|
58
|
+
a = UserAgent.new('foo')
|
59
|
+
b = UserAgent.new('foo')
|
60
|
+
a.should eql(b)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns false for different source" do
|
64
|
+
a = UserAgent.new('foo')
|
65
|
+
b = UserAgent.new('bar')
|
66
|
+
a.should_not eql(b)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "returns false for different classes" do
|
70
|
+
a = UserAgent.new('foo')
|
71
|
+
b = Class.new.new
|
72
|
+
a.should_not eql(b)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#==" do
|
77
|
+
it "returns true for same source" do
|
78
|
+
a = UserAgent.new('foo')
|
79
|
+
b = UserAgent.new('foo')
|
80
|
+
a.should == b
|
81
|
+
end
|
82
|
+
|
83
|
+
it "returns false for different source" do
|
84
|
+
a = UserAgent.new('foo')
|
85
|
+
b = UserAgent.new('bar')
|
86
|
+
a.should_not == b
|
87
|
+
end
|
88
|
+
|
89
|
+
it "returns false for different classes" do
|
90
|
+
a = UserAgent.new('foo')
|
91
|
+
b = Class.new.new
|
92
|
+
a.should_not == b
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
def test(name, version, platform, os, engine, engine_version, source)
|
4
|
+
it "should parse #{name} #{version} on #{os} with engine #{engine} #{engine_version}" do
|
5
|
+
agent = UserAgent.new(source)
|
6
|
+
agent.name.should == name
|
7
|
+
agent.platform.should == platform
|
8
|
+
agent.os.should == os
|
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
|
+
test :safari, '4.0.4', :ipad, 'iPad OS 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'
|
24
|
+
test :safari, '4.0.4', :ipad, 'iPad OS 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'
|
25
|
+
test :safari, '4.0', :iphone, 'iPhone OS 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'
|
26
|
+
test :ie, '8.0', :windows, 'Windows 7', :msie, '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)'
|
27
|
+
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)'
|
28
|
+
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)'
|
29
|
+
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)'
|
30
|
+
test :ie, '6.0b', :windows, 'Windows XP', :msie, '6.0b', 'Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)'
|
31
|
+
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)'
|
32
|
+
test :opera, '9.99', :windows, 'Windows XP', :presto, '9.9.9', 'Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9'
|
33
|
+
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'
|
34
|
+
test :opera, '9.64', :linux, 'Linux', :presto, '2.1.1', 'Opera/9.64 (X11; Linux i686; U; Linux Mint; it) Presto/2.1.1'
|
35
|
+
test :opera, '9.00', :wii, 'Wii', :unknown, nil, 'Opera/9.00 (Nintindo Wii; U; ; 103858; Wii Shop Channel/1.0; en)'
|
36
|
+
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'
|
37
|
+
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'
|
38
|
+
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'
|
39
|
+
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'
|
40
|
+
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'
|
41
|
+
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'
|
42
|
+
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'
|
43
|
+
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 '
|
44
|
+
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 '
|
45
|
+
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'
|
46
|
+
test :konqueror, '3.1-rc6', :linux, 'Linux', :konqueror, '3.1-rc6', 'Mozilla/5.0 (compatible; Konqueror/3.1-rc6; i686 Linux; 20021105)'
|
47
|
+
test :ps3, '2.00', :playstation, 'Playstation', :unknown, nil, 'Mozilla/5.0 (PLAYSTATION 3; 2.00)'
|
48
|
+
test :ps3, '1.10', :playstation, 'Playstation', :unknown, nil, 'Mozilla/5.0 (PLAYSTATION 3; 1.10)'
|
49
|
+
test :psp, '2.00', :playstation, 'Playstation', :unknown, nil, 'PSP (PlayStation Portable); 2.00'
|
50
|
+
test :psp, '2.00', :playstation, 'Playstation', :unknown, nil, 'Mozilla/4.0 (PSP (PlayStation Portable); 2.00)'
|
51
|
+
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)'
|
52
|
+
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'
|
53
|
+
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)'
|
54
|
+
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'
|
55
|
+
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'
|
56
|
+
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'
|
57
|
+
|
58
|
+
end
|
data/user_agent.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "user_agent/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'user_agent'
|
7
|
+
s.version = UserAgent::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['TJ Holowaychuk', 'John Nunemaker']
|
10
|
+
s.email = ['tj@vision-media.ca', 'nunemaker@gmail.com']
|
11
|
+
s.homepage = ''
|
12
|
+
s.summary = 'User agent parser'
|
13
|
+
s.description = 'User agent parser'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n") - ['specs.watchr']
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: user_agent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- TJ Holowaychuk
|
14
|
+
- John Nunemaker
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2011-06-22 00:00:00 Z
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: User agent parser
|
23
|
+
email:
|
24
|
+
- tj@vision-media.ca
|
25
|
+
- nunemaker@gmail.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
- Rakefile
|
38
|
+
- lib/user_agent.rb
|
39
|
+
- lib/user_agent/version.rb
|
40
|
+
- spec/spec.opts
|
41
|
+
- spec/spec_helper.rb
|
42
|
+
- spec/user_agent_spec.rb
|
43
|
+
- spec/user_agents_spec.rb
|
44
|
+
- user_agent.gemspec
|
45
|
+
homepage: ""
|
46
|
+
licenses: []
|
47
|
+
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.7.2
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: User agent parser
|
78
|
+
test_files:
|
79
|
+
- spec/spec.opts
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
- spec/user_agent_spec.rb
|
82
|
+
- spec/user_agents_spec.rb
|
83
|
+
has_rdoc:
|