1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
class UserAgent
module Browsers
class Gecko < Base
def self.extend?(agent)
agent.application && agent.application.product == "Mozilla"
end
GeckoBrowsers = %w(
PaleMoon
Firefox
Camino
Iceweasel
Seamonkey
).freeze
def browser
GeckoBrowsers.detect { |browser| respond_to?(browser) } || super
end
def version
v = send(browser).version
v.nil? ? super : v
end
def platform
if comment = application.comment
if comment[0] == 'compatible' || comment[0] == 'Mobile'
nil
elsif /^Windows / =~ comment[0]
'Windows'
else
comment[0]
end
end
end
def security
Security[application.comment[1]] || :strong
end
def os
if comment = application.comment
i = if comment[1] == 'U'
2
elsif /^Windows / =~ comment[0] || /^Android/ =~ comment[0]
0
elsif comment[0] == 'Mobile'
nil
else
1
end
return nil if i.nil?
OperatingSystems.normalize_os(comment[i])
end
end
def localization
if comment = application.comment
comment[3]
end
end
end
end
end
|