Module: UserAgent::Browsers::Webkit

Defined in:
lib/user_agent/browsers/webkit.rb

Constant Summary collapse

BuildVersions =
{
  "85.7" => "1.0",
  "85.8.5" => "1.0.3",
  "85.8.2" => "1.0.3",
  "124" => "1.2",
  "125.2" => "1.2.2",
  "125.4" => "1.2.3",
  "125.5.5" => "1.2.4",
  "125.5.6" => "1.2.4",
  "125.5.7" => "1.2.4",
  "312.1.1" => "1.3",
  "312.1" => "1.3",
  "312.5" => "1.3.1",
  "312.5.1" => "1.3.1",
  "312.5.2" => "1.3.1",
  "312.8" => "1.3.2",
  "312.8.1" => "1.3.2",
  "412" => "2.0",
  "412.6" => "2.0",
  "412.6.2" => "2.0",
  "412.7" => "2.0.1",
  "416.11" => "2.0.2",
  "416.12" => "2.0.2",
  "417.9" => "2.0.3",
  "418" => "2.0.3",
  "418.8" => "2.0.4",
  "418.9" => "2.0.4",
  "418.9.1" => "2.0.4",
  "419" => "2.0.4",
  "425.13" => "2.2"
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extend?(agent) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/user_agent/browsers/webkit.rb', line 4

def self.extend?(agent)
  agent.detect { |useragent| useragent.product == 'AppleWebKit' }
end

Instance Method Details

#applicationObject



75
76
77
78
# File 'lib/user_agent/browsers/webkit.rb', line 75

def application
   apps = self.reject{|agent| agent.comment.nil? || agent.comment.empty?} 
   apps.first 
end

#browserObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/user_agent/browsers/webkit.rb', line 12

def browser
  if os =~ /Android/
    'Android'
  elsif detect_product('Chrome')
    'Chrome'
  elsif platform == 'webOS' || platform == 'BlackBerry'  || platform == 'Symbian'
    platform 
  else
    'Safari'
  end
end

#buildObject



24
25
26
# File 'lib/user_agent/browsers/webkit.rb', line 24

def build
  webkit.version
end

#localizationObject



112
113
114
115
116
117
118
119
# File 'lib/user_agent/browsers/webkit.rb', line 112

def localization
  # TODO: Ensure that this is common to all webOS UserAgent
  if platform == 'webOS'
    application.comment[2]
  else
    application.comment[3]
  end
end

#osObject



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/user_agent/browsers/webkit.rb', line 100

def os
  if platform == 'webOS'
    "Palm #{last.product} #{last.version}"
  elsif platform == 'Symbian'
    application.comment[0]
  elsif application.comment[0] =~ /Windows NT/
    OperatingSystems.normalize_os(application.comment[0])
  else
    OperatingSystems.normalize_os(application.comment[2] || application.comment[1] || application.comment[0])
  end
end

#platformObject



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/user_agent/browsers/webkit.rb', line 80

def platform                                                                                                       
  if application.comment[0] =~ /Symbian/
  'Symbian'             
  elsif application.comment[0] =~ /webOS/
    'webOS'
  elsif application.comment[0] =~ /Windows/
    "Windows"
  else
    application.comment[0]
  end
end

#securityObject



96
97
98
# File 'lib/user_agent/browsers/webkit.rb', line 96

def security
  Security[application.comment[1]]
end

#versionObject

Prior to Safari 3, the user agent did not include a version number



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/user_agent/browsers/webkit.rb', line 61

def version
  str = if os =~ /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/
    $1.gsub(/_/, '.')
  elsif product = detect_product('Version')
    product.version
  elsif browser == 'Chrome'
    chrome.version
  else
    BuildVersions[build.to_s]
  end

  Version.new(str) if str
end

#webkitObject



92
93
94
# File 'lib/user_agent/browsers/webkit.rb', line 92

def webkit
  detect { |useragent| useragent.product == "AppleWebKit" }
end

#webkit?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/user_agent/browsers/webkit.rb', line 8

def webkit?
  true
end