useragent 0.13.3 → 0.14.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/chrome.rb +2 -0
- data/lib/user_agent/browsers/webkit.rb +9 -5
- data/lib/user_agent/operating_systems.rb +15 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93997836a30bc37117159c86a311f712ee84ff89
|
4
|
+
data.tar.gz: e53d51405082ca07154a69c1ef87d255e8ff3289
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 785ed3e80709b62585e0a8e677346dae0ee862cecfb768ab30e39aa89e8f6ebe0c6f11d88e88784b6f75dbe5d8a6c5b09a73248bdf5f027d1d50385bbdfe4287
|
7
|
+
data.tar.gz: 6a1b843c8ec68301bfe840d9df7d91261bb7ea74360e108a97cc7e0a1c5f84633a80e709a986ad46793dc24b4a9c6ec7df1974dcd200d6739cf4a2df2f2571e5
|
@@ -2,7 +2,7 @@ class UserAgent
|
|
2
2
|
module Browsers
|
3
3
|
class Webkit < Base
|
4
4
|
def self.extend?(agent)
|
5
|
-
agent.detect { |useragent| useragent.product
|
5
|
+
agent.detect { |useragent| useragent.product =~ /\AAppleWebKit\z/i }
|
6
6
|
end
|
7
7
|
|
8
8
|
def browser
|
@@ -54,10 +54,10 @@ class UserAgent
|
|
54
54
|
|
55
55
|
# Prior to Safari 3, the user agent did not include a version number
|
56
56
|
def version
|
57
|
-
str = if
|
58
|
-
$1.gsub(/_/, '.')
|
59
|
-
elsif product = detect_product('Version')
|
57
|
+
str = if product = detect_product('Version')
|
60
58
|
product.version
|
59
|
+
elsif os =~ /iOS ([\d\.]+)/ && browser == "Safari"
|
60
|
+
$1.gsub(/_/, '.')
|
61
61
|
else
|
62
62
|
BuildVersions[build.to_s]
|
63
63
|
end
|
@@ -76,13 +76,15 @@ class UserAgent
|
|
76
76
|
'Windows'
|
77
77
|
elsif application.comment[0] == 'BB10'
|
78
78
|
'BlackBerry'
|
79
|
+
elsif application.comment.any? { |c| c =~ /Android/ }
|
80
|
+
'Android'
|
79
81
|
else
|
80
82
|
application.comment[0]
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
84
86
|
def webkit
|
85
|
-
detect { |useragent| useragent.product
|
87
|
+
detect { |useragent| useragent.product =~ /\AAppleWebKit\z/i }
|
86
88
|
end
|
87
89
|
|
88
90
|
def security
|
@@ -97,6 +99,8 @@ class UserAgent
|
|
97
99
|
OperatingSystems.normalize_os(application.comment[1])
|
98
100
|
elsif application.comment[1] =~ /Android/
|
99
101
|
OperatingSystems.normalize_os(application.comment[1])
|
102
|
+
elsif (os_string = application.comment.detect { |c| c =~ OperatingSystems::IOS_VERSION_REGEX })
|
103
|
+
OperatingSystems.normalize_os(os_string)
|
100
104
|
else
|
101
105
|
OperatingSystems.normalize_os(application.comment[2])
|
102
106
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class UserAgent
|
2
2
|
module OperatingSystems
|
3
|
+
IOS_VERSION_REGEX = /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/
|
4
|
+
|
3
5
|
Windows = {
|
4
6
|
"Windows NT 6.3" => "Windows 8.1",
|
5
7
|
"Windows NT 6.2" => "Windows 8",
|
@@ -16,12 +18,23 @@ class UserAgent
|
|
16
18
|
}.freeze
|
17
19
|
|
18
20
|
def self.normalize_os(os)
|
19
|
-
Windows[os] || normalize_mac_os_x(os) || normalize_ios(os) || os
|
21
|
+
Windows[os] || normalize_mac_os_x(os) || normalize_ios(os) || normalize_chrome_os(os) || os
|
20
22
|
end
|
21
23
|
|
22
24
|
private
|
25
|
+
def self.normalize_chrome_os(os)
|
26
|
+
if os =~ /CrOS\s([^\s]+)\s(\d+(\.\d+)*)/
|
27
|
+
if $2.nil?
|
28
|
+
"ChromeOS"
|
29
|
+
else
|
30
|
+
version = $2
|
31
|
+
"ChromeOS #{version}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
23
36
|
def self.normalize_ios(os)
|
24
|
-
if os =~
|
37
|
+
if os =~ IOS_VERSION_REGEX
|
25
38
|
if $1.nil?
|
26
39
|
"iOS"
|
27
40
|
else
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: useragent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Peek
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project:
|
87
|
-
rubygems_version: 2.4.
|
87
|
+
rubygems_version: 2.4.8
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: HTTP User Agent parser
|