useragent 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/user_agent/browsers/all.rb +14 -0
- data/lib/user_agent/browsers/webkit.rb +25 -9
- metadata +4 -4
@@ -44,6 +44,20 @@ class UserAgent
|
|
44
44
|
detect_product(method) || super
|
45
45
|
end
|
46
46
|
|
47
|
+
def webkit?
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
def mobile?
|
52
|
+
if browser == 'webOS'
|
53
|
+
true
|
54
|
+
elsif detect_product('Mobile')
|
55
|
+
true
|
56
|
+
else
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
47
61
|
private
|
48
62
|
def detect_product(product)
|
49
63
|
detect { |useragent| useragent.product.to_s.downcase == product.to_s.downcase }
|
@@ -5,11 +5,19 @@ class UserAgent
|
|
5
5
|
agent.detect { |useragent| useragent.product == "Safari" || useragent.product == "Chrome" }
|
6
6
|
end
|
7
7
|
|
8
|
+
def webkit?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
8
12
|
def browser
|
9
|
-
if
|
10
|
-
|
13
|
+
if os =~ /Android/
|
14
|
+
'Android'
|
15
|
+
elsif detect_product('Chrome')
|
16
|
+
'Chrome'
|
17
|
+
elsif platform == 'webOS'
|
18
|
+
'webOS'
|
11
19
|
else
|
12
|
-
|
20
|
+
'Safari'
|
13
21
|
end
|
14
22
|
end
|
15
23
|
|
@@ -51,19 +59,23 @@ class UserAgent
|
|
51
59
|
|
52
60
|
# Prior to Safari 3, the user agent did not include a version number
|
53
61
|
def version
|
54
|
-
if
|
55
|
-
chrome.version
|
56
|
-
elsif os =~ /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/
|
62
|
+
if os =~ /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/
|
57
63
|
$1.gsub(/_/, '.')
|
58
|
-
elsif product = detect_product(
|
64
|
+
elsif product = detect_product('Version')
|
59
65
|
product.version
|
66
|
+
elsif browser == 'Chrome'
|
67
|
+
chrome.version
|
60
68
|
else
|
61
69
|
BuildVersions[build]
|
62
70
|
end
|
63
71
|
end
|
64
72
|
|
65
73
|
def platform
|
66
|
-
application.comment[0]
|
74
|
+
if application.comment[0] =~ /webOS/
|
75
|
+
'webOS'
|
76
|
+
else
|
77
|
+
application.comment[0]
|
78
|
+
end
|
67
79
|
end
|
68
80
|
|
69
81
|
def webkit
|
@@ -75,7 +87,11 @@ class UserAgent
|
|
75
87
|
end
|
76
88
|
|
77
89
|
def os
|
78
|
-
|
90
|
+
if platform == 'webOS'
|
91
|
+
"Palm #{last.product} #{last.version}"
|
92
|
+
else
|
93
|
+
OperatingSystems.normalize_os(application.comment[2])
|
94
|
+
end
|
79
95
|
end
|
80
96
|
|
81
97
|
def localization
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Peek
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-04 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|