Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Otter Browser detection. #310

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added Otter Browser detection.
Signed-off-by: Marcin Mikołajczak <me@m4sk.in>
  • Loading branch information
Marcin Mikołajczak committed Jul 6, 2017
commit 02b61e4ec60b351c5adf663830029293eeaa6628
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ browser.name # readable browser name
browser.nokia?
browser.opera?
browser.opera_mini?
browser.otter_browser?
browser.phantom_js?
browser.quicktime?
browser.safari?
Expand Down
4 changes: 4 additions & 0 deletions lib/browser/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ def proxy?
# Detect if the browser is Electron.
def electron?(expected_version = nil)
Electron.new(ua).match? && detect_version?(full_version, expected_version)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

# Detect if browser is Otter Browser.
def otter_browser?(expected_version = nil)
ua =~ /Otter Browser/ && detect_version?(full_version, expected_version)
end
end
end
1 change: 1 addition & 0 deletions test/ua.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ OPERA_ANDROID: 'Mozill/5.0 (Linux; Android 4.4.2; A1-810 Build/KOT49H) Apple/Web
OPERA_MINI: 'Opera/9.80 (Android; Opera Mini/7.029952/28.2359;u; fr) Presto/2.8.119 Version/11.10'
OPERA_MOBI: 'Opera/9.8 (Android 2.3.5; Linux; Opera Mobi/ADR-1205181138; U; en) Presto/2.10.254 Version/12.00'
OPERA_NEXT: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.37 Safari/537.36 OPR/15.0.1147.44 (Edition Next)'
OTTER_BROWSER: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/602.1 (KHTML, like Gecko) Otter/0.9.91'
PHANTOM_JS: 'Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.0 Safari/534.34'
PLAYBOOK: 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536.2+'
PLAYSTATION3: 'Mozilla/5.0 (PLAYSTATION 3; 3.55)'
Expand Down
11 changes: 11 additions & 0 deletions test/unit/otter_browser_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require "test_helper"

class OtterBrowserTest < Minitest::Test
test "detects Otter Browser" do
browser = Browser.new(Browser["OTTER_BROWSER"])
assert browser.otter_browser?
assert_equal browser.name, "Otter Browser"
end
end