lib/user_agent/operating_systems.rb in useragent-0.13.3 vs lib/user_agent/operating_systems.rb in useragent-0.14.0
- old
+ new
@@ -1,7 +1,9 @@
class UserAgent
module OperatingSystems
+ IOS_VERSION_REGEX = /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/
+
Windows = {
"Windows NT 6.3" => "Windows 8.1",
"Windows NT 6.2" => "Windows 8",
"Windows NT 6.1" => "Windows 7",
"Windows NT 6.0" => "Windows Vista",
@@ -14,15 +16,26 @@
"Windows 95" => "Windows 95",
"Windows CE" => "Windows CE"
}.freeze
def self.normalize_os(os)
- Windows[os] || normalize_mac_os_x(os) || normalize_ios(os) || os
+ Windows[os] || normalize_mac_os_x(os) || normalize_ios(os) || normalize_chrome_os(os) || os
end
private
+ def self.normalize_chrome_os(os)
+ if os =~ /CrOS\s([^\s]+)\s(\d+(\.\d+)*)/
+ if $2.nil?
+ "ChromeOS"
+ else
+ version = $2
+ "ChromeOS #{version}"
+ end
+ end
+ end
+
def self.normalize_ios(os)
- if os =~ /CPU OS\s*([0-9_\.]+)?\slike Mac OS X/
+ if os =~ IOS_VERSION_REGEX
if $1.nil?
"iOS"
else
version = $1.gsub('_', '.')
"iOS #{version}"