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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7beed7c3e58f48ae8eafe07647b5a697dda925e2
4
- data.tar.gz: 849a89b1d719abca31f254653e12de26dc77ea85
3
+ metadata.gz: 93997836a30bc37117159c86a311f712ee84ff89
4
+ data.tar.gz: e53d51405082ca07154a69c1ef87d255e8ff3289
5
5
  SHA512:
6
- metadata.gz: c90119ee052cc6b902fa4560c7e0282ddb06b597672d1280eb6ab9cd2f65783df79a56ed63e27a8b85319047c8c4f7823c038586d0eaaef0faa3c36de80faedd
7
- data.tar.gz: d3754eb53dd810b258085a5afeaf108a6ee6de076b1cb0ab8a50a8c1ef5f241d5dc5be99993496fe6ad0efc95aa85f43c0cc487a2366ccac37cafc0bfeee69e7
6
+ metadata.gz: 785ed3e80709b62585e0a8e677346dae0ee862cecfb768ab30e39aa89e8f6ebe0c6f11d88e88784b6f75dbe5d8a6c5b09a73248bdf5f027d1d50385bbdfe4287
7
+ data.tar.gz: 6a1b843c8ec68301bfe840d9df7d91261bb7ea74360e108a97cc7e0a1c5f84633a80e709a986ad46793dc24b4a9c6ec7df1974dcd200d6739cf4a2df2f2571e5
@@ -36,6 +36,8 @@ class UserAgent
36
36
  nil
37
37
  elsif application.comment[0] =~ /Windows/
38
38
  'Windows'
39
+ elsif application.comment.any? { |c| c =~ /CrOS/ }
40
+ 'ChromeOS'
39
41
  else
40
42
  application.comment[0]
41
43
  end
@@ -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 == 'AppleWebKit' }
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 os =~ /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/ && browser == "Safari"
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 == "AppleWebKit" }
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 =~ /CPU OS\s*([0-9_\.]+)?\slike Mac OS X/
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.13.3
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-03-21 00:00:00.000000000 Z
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.5
87
+ rubygems_version: 2.4.8
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: HTTP User Agent parser