modern-user-agent 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +12 -0
- data/Manifest +16 -0
- data/README.rdoc +49 -0
- data/Rakefile +15 -0
- data/lib/user-agent/agent.rb +166 -0
- data/lib/user-agent/version.rb +4 -0
- data/lib/user-agent.rb +25 -0
- data/spec/agent_spec.rb +64 -0
- data/spec/agents_spec.rb +53 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +3 -0
- data/tasks/docs.rake +13 -0
- data/tasks/gemspec.rake +3 -0
- data/tasks/spec.rake +25 -0
- data/user-agent.gemspec +30 -0
- metadata +74 -0
data/History.rdoc
ADDED
data/Manifest
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Gemfile
|
2
|
+
History.rdoc
|
3
|
+
Manifest
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
lib/user-agent.rb
|
7
|
+
lib/user-agent/agent.rb
|
8
|
+
lib/user-agent/version.rb
|
9
|
+
spec/agent_spec.rb
|
10
|
+
spec/agents_spec.rb
|
11
|
+
spec/spec.opts
|
12
|
+
spec/spec_helper.rb
|
13
|
+
tasks/docs.rake
|
14
|
+
tasks/gemspec.rake
|
15
|
+
tasks/spec.rake
|
16
|
+
user-agent.gemspec
|
data/README.rdoc
ADDED
@@ -0,0 +1,49 @@
|
|
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.engine_version # => '531.9'
|
14
|
+
|
15
|
+
== Supported Agents
|
16
|
+
|
17
|
+
* Safari
|
18
|
+
* Chrome
|
19
|
+
* Opera
|
20
|
+
* IE
|
21
|
+
* Konqueror
|
22
|
+
* PS3
|
23
|
+
* PSP
|
24
|
+
* Wii
|
25
|
+
|
26
|
+
== License:
|
27
|
+
|
28
|
+
(The MIT License)
|
29
|
+
|
30
|
+
Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
|
31
|
+
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
33
|
+
a copy of this software and associated documentation files (the
|
34
|
+
'Software'), to deal in the Software without restriction, including
|
35
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
36
|
+
distribute, sublicense, an d/or sell copies of the Software, and to
|
37
|
+
permit persons to whom the Software is furnished to do so, subject to
|
38
|
+
the following conditions:
|
39
|
+
|
40
|
+
The above copyright notice and this permission notice shall be
|
41
|
+
included in all copies or substantial portions of the Software.
|
42
|
+
|
43
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
44
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
45
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
46
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
47
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
48
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
49
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
$:.unshift 'lib'
|
3
|
+
require 'user-agent'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rake'
|
6
|
+
require 'echoe'
|
7
|
+
|
8
|
+
Echoe.new "user-agent", Agent::VERSION do |p|
|
9
|
+
p.author = "TJ Holowaychuk"
|
10
|
+
p.email = "tj@vision-media.ca"
|
11
|
+
p.summary = "User agent parser"
|
12
|
+
p.runtime_dependencies = []
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir['tasks/**/*.rake'].sort.each { |f| load f }
|
@@ -0,0 +1,166 @@
|
|
1
|
+
|
2
|
+
class Agent
|
3
|
+
|
4
|
+
##
|
5
|
+
# User agent string.
|
6
|
+
|
7
|
+
attr_reader :string
|
8
|
+
|
9
|
+
##
|
10
|
+
# Initialize with user agent _string_.
|
11
|
+
|
12
|
+
def initialize string
|
13
|
+
@string = string.strip
|
14
|
+
end
|
15
|
+
|
16
|
+
#--
|
17
|
+
# Instance methods
|
18
|
+
#++
|
19
|
+
|
20
|
+
##
|
21
|
+
# User agent name symbol.
|
22
|
+
|
23
|
+
def name
|
24
|
+
Agent.name_for_user_agent string
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# User agent version.
|
29
|
+
|
30
|
+
def version
|
31
|
+
Agent.version_for_user_agent string
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# User agent engine symbol.
|
36
|
+
|
37
|
+
def engine
|
38
|
+
Agent.engine_for_user_agent string
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# User agent engine version string.
|
43
|
+
|
44
|
+
def engine_version
|
45
|
+
Agent.engine_version_for_user_agent string
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# User agent os symbol.
|
50
|
+
|
51
|
+
def os
|
52
|
+
Agent.os_for_user_agent string
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# User agent string.
|
57
|
+
|
58
|
+
def to_s
|
59
|
+
string
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Inspect.
|
64
|
+
|
65
|
+
def inspect
|
66
|
+
"#<Agent:#{name} version:#{version.inspect} engine:\"#{engine.to_s}:#{engine_version}\" os:#{os.to_s.inspect}>"
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Check if the agent is the same as _other_ agent.
|
71
|
+
|
72
|
+
def == other
|
73
|
+
string == other.string
|
74
|
+
end
|
75
|
+
|
76
|
+
#--
|
77
|
+
# Class methods
|
78
|
+
#++
|
79
|
+
|
80
|
+
##
|
81
|
+
# Return engine version for user agent _string_.
|
82
|
+
|
83
|
+
def self.engine_version_for_user_agent string
|
84
|
+
$1 if string =~ /#{engine_for_user_agent(string)}[\/ ]([\d\w\.\-]+)/i
|
85
|
+
end
|
86
|
+
|
87
|
+
##
|
88
|
+
# Return version for user agent _string_.
|
89
|
+
|
90
|
+
def self.version_for_user_agent string
|
91
|
+
case name = name_for_user_agent(string)
|
92
|
+
when :Chrome ; $1 if string =~ /chrome\/([\d\w\.\-]+)/i
|
93
|
+
when :Safari ; $1 if string =~ /version\/([\d\w\.\-]+)/i
|
94
|
+
when :PS3 ; $1 if string =~ /([\d\w\.\-]+)\)\s*$/i
|
95
|
+
when :'Internet Explorer' ; "#{$1}.#{$2}" if string =~ /rv:(\d+).(\d+)/i
|
96
|
+
when :PSP ; $1 if string =~ /([\d\w\.\-]+)\)?\s*$/i
|
97
|
+
else $1 if string =~ /#{name}[\/ ]([\d\w\.\-]+)/i
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# Return engine symbol for user agent _string_.
|
103
|
+
|
104
|
+
def self.engine_for_user_agent string
|
105
|
+
case string
|
106
|
+
when /webkit/i ; :webkit
|
107
|
+
when /khtml/i ; :khtml
|
108
|
+
when /konqueror/i ; :konqueror
|
109
|
+
when /chrome/i ; :chrome
|
110
|
+
when /presto/i ; :presto
|
111
|
+
when /trident\/(\d+).(\d+)/i ; :trident
|
112
|
+
when /gecko/i ; :gecko
|
113
|
+
when /msie/i ; :msie
|
114
|
+
else :unknown
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Return the os for user agent _string_.
|
120
|
+
|
121
|
+
def self.os_for_user_agent string
|
122
|
+
case string
|
123
|
+
when /windows nt 6\.3/i ; :'Windows 8.1'
|
124
|
+
when /windows nt 6\.2/i ; :'Windows 8'
|
125
|
+
when /windows nt 6\.1/i ; :'Windows 7'
|
126
|
+
when /windows nt 6\.0/i ; :'Windows Vista'
|
127
|
+
when /windows nt 5\.2/i ; :'Windows 2003'
|
128
|
+
when /windows nt 5\.1/i ; :'Windows XP'
|
129
|
+
when /windows nt 5\.0/i ; :'Windows 2000'
|
130
|
+
when /os x (\d+)[._](\d+)/i ; :"OS X #{$1}.#{$2}"
|
131
|
+
when /linux/i ; :Linux
|
132
|
+
when /wii/i ; :Wii
|
133
|
+
when /playstation 3/i ; :Playstation
|
134
|
+
when /playstation portable/i ; :'Playstation Portable'
|
135
|
+
else ; :Unknown
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
##
|
140
|
+
# Return name for user agent _string_.
|
141
|
+
|
142
|
+
def self.name_for_user_agent string
|
143
|
+
case string
|
144
|
+
when /konqueror/i ; :Konqueror
|
145
|
+
when /chrome/i ; :Chrome
|
146
|
+
when /safari/i ; :Safari
|
147
|
+
when /trident\/(\d+).(\d+)/i ; :'Internet Explorer'
|
148
|
+
when /msie/i ; :IE
|
149
|
+
when /opera/i ; :Opera
|
150
|
+
when /playstation 3/i ; :PS3
|
151
|
+
when /playstation portable/i ; :PSP
|
152
|
+
when /firefox/i ; :Firefox
|
153
|
+
else ; :Unknown
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
@agents = []
|
158
|
+
|
159
|
+
##
|
160
|
+
# Map agent _name_ to _options_.
|
161
|
+
|
162
|
+
def self.map name, options = {}
|
163
|
+
@agents << [name, options]
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
data/lib/user-agent.rb
ADDED
@@ -0,0 +1,25 @@
|
|
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'
|
data/spec/agent_spec.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe Agent do
|
5
|
+
before :each do
|
6
|
+
@agent = Agent.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
|
+
Agent.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 == '#<Agent: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 = Agent.new 'foo'
|
54
|
+
b = Agent.new 'foo'
|
55
|
+
a.should == b
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should not be equal when user agent strings are different" do
|
59
|
+
a = Agent.new 'foo'
|
60
|
+
b = Agent.new 'bar'
|
61
|
+
a.should_not == b
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/spec/agents_spec.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
def test name, version, os, engine, engine_version, string
|
5
|
+
it "should parse #{name} #{version} on #{os} with engine #{engine} #{engine_version}" do
|
6
|
+
agent = Agent.new string
|
7
|
+
agent.name.should == name
|
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 Agent do
|
16
|
+
|
17
|
+
test :Safari, '4.0dp1', :'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 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 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', :'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 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 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 :IE, '8.0', :'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)'
|
25
|
+
test :IE, '7.0b', :'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)'
|
26
|
+
test :IE, '6.0b', :'Windows XP', :msie, '6.0b', 'Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)'
|
27
|
+
test :IE, '6.0', :'Windows XP', :msie, '6.0', 'Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)'
|
28
|
+
|
29
|
+
test :Opera, '9.99', :'Windows XP', :presto, '9.9.9', 'Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9'
|
30
|
+
test :Opera, '9.70', :Linux, :gecko, '20061208', 'Mozilla/5.0 (Linux i686 ; U; en; rv:1.8.1) Gecko/20061208 Firefox/2.0.0 Opera 9.70'
|
31
|
+
test :Opera, '9.64', :Linux, :presto, '2.1.1', 'Opera/9.64 (X11; Linux i686; U; Linux Mint; it) Presto/2.1.1'
|
32
|
+
test :Opera, '9.00', :Wii, :unknown, nil, 'Opera/9.00 (Nintindo Wii; U; ; 103858; Wii Shop Channel/1.0; en)'
|
33
|
+
|
34
|
+
test :Chrome, '4.0.202.2', :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'
|
35
|
+
test :Chrome, '0.2.149.27', :'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'
|
36
|
+
test :Chrome, '0.2.149.30', :'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'
|
37
|
+
|
38
|
+
test :Konqueror, '4.2', :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'
|
39
|
+
test :Konqueror, '3.1-rc6', :Linux, :konqueror, '3.1-rc6', 'Mozilla/5.0 (compatible; Konqueror/3.1-rc6; i686 Linux; 20021105)'
|
40
|
+
|
41
|
+
test :PS3, '2.00', :Playstation, :unknown, nil, 'Mozilla/5.0 (PLAYSTATION 3; 2.00)'
|
42
|
+
test :PS3, '1.10', :Playstation, :unknown, nil, 'Mozilla/5.0 (PLAYSTATION 3; 1.10)'
|
43
|
+
|
44
|
+
test :PSP, '2.00', :Playstation, :unknown, nil, 'PSP (PlayStation Portable); 2.00'
|
45
|
+
test :PSP, '2.00', :Playstation, :unknown, nil, 'Mozilla/4.0 (PSP (PlayStation Portable); 2.00)'
|
46
|
+
|
47
|
+
test :Firefox, '3.5', :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'
|
48
|
+
test :Firefox, '3.5', :'Windows 7', :gecko, '20090612', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1) Gecko/20090612 Firefox/3.5'
|
49
|
+
test :Firefox, '3.1', :'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'
|
50
|
+
test :Firefox, '3.0', :Linux, :gecko, '2008062315', 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9) Gecko/2008062315 (Gentoo) Firefox/3.0'
|
51
|
+
test :Firefox, '2.0', :Linux, :gecko, '20061202', 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1) Gecko/20061202 Firefox/2.0'
|
52
|
+
|
53
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
data/tasks/docs.rake
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
namespace :docs do
|
3
|
+
|
4
|
+
desc 'Remove rdoc products'
|
5
|
+
task :remove => [:clobber_docs]
|
6
|
+
|
7
|
+
desc 'Build docs, and open in browser for viewing (specify BROWSER)'
|
8
|
+
task :open do
|
9
|
+
browser = ENV["BROWSER"] || "safari"
|
10
|
+
sh "open -a #{browser} doc/index.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/tasks/gemspec.rake
ADDED
data/tasks/spec.rake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
desc "Run all specifications"
|
5
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
6
|
+
t.libs << "lib"
|
7
|
+
t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :spec do
|
11
|
+
|
12
|
+
desc "Run all specifications verbosely"
|
13
|
+
Spec::Rake::SpecTask.new(:verbose) do |t|
|
14
|
+
t.libs << "lib"
|
15
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run specific specification verbosely (specify SPEC)"
|
19
|
+
Spec::Rake::SpecTask.new(:select) do |t|
|
20
|
+
t.libs << "lib"
|
21
|
+
t.spec_files = [ENV["SPEC"]]
|
22
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/user-agent.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "modern-user-agent"
|
5
|
+
s.version = "1.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = [ "TJ Holowaychuk", "Alex Reed" ]
|
9
|
+
s.date = "2013-10-08"
|
10
|
+
s.description = "Fixed User agent parser, works on new version of Windows an Internet Explorer"
|
11
|
+
s.email = "tj@vision-media.ca"
|
12
|
+
s.extra_rdoc_files = [ "README.rdoc", "lib/user-agent.rb", "lib/user-agent/agent.rb", "lib/user-agent/version.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake" ]
|
13
|
+
s.files = [ "History.rdoc", "Manifest", "README.rdoc", "Rakefile", "lib/user-agent.rb", "lib/user-agent/agent.rb", "lib/user-agent/version.rb", "spec/agent_spec.rb", "spec/agents_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "user-agent.gemspec" ]
|
14
|
+
s.homepage = ""
|
15
|
+
s.rdoc_options = [ "--line-numbers", "--inline-source", "--title", "User-agent", "--main", "README.rdoc" ]
|
16
|
+
s.require_paths = [ "lib" ]
|
17
|
+
s.rubyforge_project = "user-agent"
|
18
|
+
s.rubygems_version = "1.3.5"
|
19
|
+
s.summary = "User agent parser"
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: modern-user-agent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- TJ Holowaychuk
|
9
|
+
- Alex Reed
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-10-08 00:00:00.000000000 Z
|
14
|
+
dependencies: []
|
15
|
+
description: Fixed User agent parser, works on new version of Windows an Internet
|
16
|
+
Explorer
|
17
|
+
email: tj@vision-media.ca
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files:
|
21
|
+
- README.rdoc
|
22
|
+
- lib/user-agent.rb
|
23
|
+
- lib/user-agent/agent.rb
|
24
|
+
- lib/user-agent/version.rb
|
25
|
+
- tasks/docs.rake
|
26
|
+
- tasks/gemspec.rake
|
27
|
+
- tasks/spec.rake
|
28
|
+
files:
|
29
|
+
- History.rdoc
|
30
|
+
- Manifest
|
31
|
+
- README.rdoc
|
32
|
+
- Rakefile
|
33
|
+
- lib/user-agent.rb
|
34
|
+
- lib/user-agent/agent.rb
|
35
|
+
- lib/user-agent/version.rb
|
36
|
+
- spec/agent_spec.rb
|
37
|
+
- spec/agents_spec.rb
|
38
|
+
- spec/spec.opts
|
39
|
+
- spec/spec_helper.rb
|
40
|
+
- tasks/docs.rake
|
41
|
+
- tasks/gemspec.rake
|
42
|
+
- tasks/spec.rake
|
43
|
+
- user-agent.gemspec
|
44
|
+
homepage: ''
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options:
|
48
|
+
- --line-numbers
|
49
|
+
- --inline-source
|
50
|
+
- --title
|
51
|
+
- User-agent
|
52
|
+
- --main
|
53
|
+
- README.rdoc
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.2'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project: user-agent
|
70
|
+
rubygems_version: 1.8.24
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: User agent parser
|
74
|
+
test_files: []
|