useragent 0.7.0 → 0.8.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.
- checksums.yaml +4 -4
- data/lib/user_agent/browsers.rb +2 -1
- data/lib/user_agent/browsers/all.rb +3 -9
- data/lib/user_agent/browsers/opera.rb +10 -6
- data/lib/user_agent/browsers/webkit.rb +3 -25
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2658435598c1604bdebca0e0d989073e2e01a788
|
4
|
+
data.tar.gz: 7a8ecbe3137b1c26dff955a319955e5ef47e2007
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 191b834bc118d29098f5b22b5c980d74fb8d5b63f41092804a16fe0c987d0bf00981a5db18153e3bc3b4afd220d8524097be4c8bed15206db511838c98df7546
|
7
|
+
data.tar.gz: 153c59ccf82db939f2215dd1df088fedf9d557767d2d3085504f3421ae2c1a94b651afa1a468cc9d7e346ed307d45bfd561198b860b0eb285fcaaeda46c78ac6
|
data/lib/user_agent/browsers.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'user_agent/browsers/all'
|
2
|
+
require 'user_agent/browsers/chrome'
|
2
3
|
require 'user_agent/browsers/gecko'
|
3
4
|
require 'user_agent/browsers/internet_explorer'
|
4
5
|
require 'user_agent/browsers/opera'
|
@@ -13,7 +14,7 @@ class UserAgent
|
|
13
14
|
}.freeze
|
14
15
|
|
15
16
|
def self.all
|
16
|
-
[InternetExplorer, Webkit, Opera, Gecko]
|
17
|
+
[InternetExplorer, Chrome, Webkit, Opera, Gecko]
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.extend(array)
|
@@ -52,16 +52,8 @@ class UserAgent
|
|
52
52
|
detect_product(method) || super
|
53
53
|
end
|
54
54
|
|
55
|
-
def webkit?
|
56
|
-
false
|
57
|
-
end
|
58
|
-
|
59
55
|
def mobile?
|
60
|
-
if
|
61
|
-
true
|
62
|
-
elsif platform == 'Symbian'
|
63
|
-
true
|
64
|
-
elsif detect_product('Mobile') || detect_comment('Mobile')
|
56
|
+
if detect_product('Mobile') || detect_comment('Mobile')
|
65
57
|
true
|
66
58
|
elsif os =~ /Android/
|
67
59
|
true
|
@@ -88,6 +80,8 @@ class UserAgent
|
|
88
80
|
# list will be rejected.
|
89
81
|
elsif comment = application.comment
|
90
82
|
comment.any? { |c| c =~ /bot/i }
|
83
|
+
elsif product = application.product
|
84
|
+
product.include?('bot')
|
91
85
|
else
|
92
86
|
false
|
93
87
|
end
|
@@ -2,11 +2,14 @@ class UserAgent
|
|
2
2
|
module Browsers
|
3
3
|
module Opera
|
4
4
|
def self.extend?(agent)
|
5
|
-
agent.
|
5
|
+
agent.first.product == 'Opera' ||
|
6
|
+
(agent.application && agent.application.product == 'Opera')
|
6
7
|
end
|
7
8
|
|
8
9
|
def version
|
9
|
-
if
|
10
|
+
if mini?
|
11
|
+
application.comment[1][/Opera Mini\/([\d\.]+)/, 1]
|
12
|
+
elsif product = detect_product('Version')
|
10
13
|
product.version
|
11
14
|
else
|
12
15
|
super
|
@@ -35,10 +38,6 @@ class UserAgent
|
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
38
|
-
def mini?
|
39
|
-
/Opera Mini/ === application
|
40
|
-
end
|
41
|
-
|
42
41
|
def mobile?
|
43
42
|
mini?
|
44
43
|
end
|
@@ -62,6 +61,11 @@ class UserAgent
|
|
62
61
|
application.comment[2]
|
63
62
|
end
|
64
63
|
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def mini?
|
67
|
+
/Opera Mini/ === application
|
68
|
+
end
|
65
69
|
end
|
66
70
|
end
|
67
71
|
end
|
@@ -5,16 +5,10 @@ class UserAgent
|
|
5
5
|
agent.detect { |useragent| useragent.product == 'AppleWebKit' }
|
6
6
|
end
|
7
7
|
|
8
|
-
def webkit?
|
9
|
-
true
|
10
|
-
end
|
11
|
-
|
12
8
|
def browser
|
13
|
-
if
|
14
|
-
'Chrome'
|
15
|
-
elsif os =~ /Android/
|
9
|
+
if os =~ /Android/
|
16
10
|
'Android'
|
17
|
-
elsif platform == '
|
11
|
+
elsif platform == 'BlackBerry'
|
18
12
|
platform
|
19
13
|
else
|
20
14
|
'Safari'
|
@@ -64,12 +58,6 @@ class UserAgent
|
|
64
58
|
$1.gsub(/_/, '.')
|
65
59
|
elsif product = detect_product('Version')
|
66
60
|
product.version
|
67
|
-
elsif browser == 'Chrome'
|
68
|
-
if detect_product("chrome")
|
69
|
-
chrome.version
|
70
|
-
elsif detect_product("crios")
|
71
|
-
crios.version
|
72
|
-
end
|
73
61
|
else
|
74
62
|
BuildVersions[build.to_s]
|
75
63
|
end
|
@@ -84,10 +72,6 @@ class UserAgent
|
|
84
72
|
def platform
|
85
73
|
if application.nil?
|
86
74
|
nil
|
87
|
-
elsif application.comment[0] =~ /Symbian/
|
88
|
-
'Symbian'
|
89
|
-
elsif application.comment[0] =~ /webOS/
|
90
|
-
'webOS'
|
91
75
|
elsif application.comment[0] =~ /Windows/
|
92
76
|
'Windows'
|
93
77
|
elsif application.comment[0] == 'BB10'
|
@@ -106,11 +90,7 @@ class UserAgent
|
|
106
90
|
end
|
107
91
|
|
108
92
|
def os
|
109
|
-
if
|
110
|
-
"Palm #{last.product} #{last.version}"
|
111
|
-
elsif platform == 'Symbian'
|
112
|
-
application.comment[0]
|
113
|
-
elsif application
|
93
|
+
if application
|
114
94
|
if application.comment[0] =~ /Windows NT/
|
115
95
|
OperatingSystems.normalize_os(application.comment[0])
|
116
96
|
elsif application.comment[2].nil?
|
@@ -128,8 +108,6 @@ class UserAgent
|
|
128
108
|
def localization
|
129
109
|
if application.nil?
|
130
110
|
nil
|
131
|
-
elsif platform == 'webOS'
|
132
|
-
application.comment[2]
|
133
111
|
else
|
134
112
|
application.comment[3]
|
135
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: useragent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Peek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -59,7 +59,8 @@ files:
|
|
59
59
|
- LICENSE
|
60
60
|
- README.rdoc
|
61
61
|
homepage: http://github.com/josh/useragent
|
62
|
-
licenses:
|
62
|
+
licenses:
|
63
|
+
- MIT
|
63
64
|
metadata: {}
|
64
65
|
post_install_message:
|
65
66
|
rdoc_options: []
|