Skip to content

Commit ce613de

Browse files
author
Aaron Vegh
committed
Adding distinction between Outlook 2007 and 2010
1 parent e8b4b8b commit ce613de

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

lib/browser.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class Browser
2626
:psp => "PlayStation Portable",
2727
:quicktime => "QuickTime",
2828
:core_media => "Apple CoreMedia",
29-
:outlook => "Microsoft Outlook",
29+
:outlook2010 => "Microsoft Outlook 2010",
30+
:outlook2007 => "Microsoft Outlook 2007",
3031
:thunderbird => "Thunderbird",
3132
:applemail => "Apple Mail",
3233
:sparrow => "Sparrow",
@@ -195,7 +196,8 @@ def id
195196
when psp? then :psp
196197
when quicktime? then :quicktime
197198
when core_media? then :core_media
198-
when outlook? then :outlook
199+
when outlook2010? then :outlook2010
200+
when outlook2007? then :outlook2007
199201
when thunderbird? then :thunderbird
200202
when applemail? then :applemail
201203
when sparrow? then :sparrow
@@ -219,7 +221,7 @@ def version
219221

220222
# Return the full version.
221223
def full_version
222-
if self.outlook?
224+
if self.outlook2007? or self.outlook2010?
223225
_, v = *ua.match(/(?:Version|MSOffice|Firefox|Chrome|QuickTime|BlackBerry[^\/]+|CoreMedia v)[\/ ]?([a-z0-9.]+)/i)
224226
else
225227
_, v = *ua.match(VERSIONS.fetch(id, VERSIONS[:default]))
@@ -356,8 +358,12 @@ def tablet?
356358
ipad? || (android? && !mobile?)
357359
end
358360

359-
def outlook?
360-
!!(ua =~ /MSOffice/)
361+
def outlook2010?
362+
!!(ua =~ /MSOffice 14/)
363+
end
364+
365+
def outlook2007?
366+
!!(ua =~ /MSOffice 12/)
361367
end
362368

363369
def thunderbird?

test/browser_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,17 @@ def test_detect_psp
294294
def test_detect_outlook_2007
295295
@browser.ua = OUTLOOK2007
296296

297-
assert_equal "Microsoft Outlook", @browser.name
298-
assert @browser.outlook?
297+
assert_equal "Microsoft Outlook 2007", @browser.name
298+
assert @browser.outlook2007?
299299
assert @browser.windows?
300300
assert_equal "12", @browser.version
301301
end
302302

303303
def test_detect_outlook_2010
304304
@browser.ua = OUTLOOK2010
305305

306-
assert_equal "Microsoft Outlook", @browser.name
307-
assert @browser.outlook?
306+
assert_equal "Microsoft Outlook 2010", @browser.name
307+
assert @browser.outlook2010?
308308
assert @browser.windows?
309309
assert_equal "14", @browser.version
310310
end

0 commit comments

Comments
 (0)