forked from fnando/browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Facebook in-app browser. Close fnando#296.
- Loading branch information
Showing
6 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Browser | ||
class Facebook < Base | ||
def id | ||
end | ||
|
||
def name | ||
"Facebook" | ||
end | ||
|
||
def full_version | ||
ua[%r[FBAV/([\d.]+)], 1] | ||
end | ||
|
||
def match? | ||
ua =~ /FBAV/ | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class FacebookTest < Minitest::Test | ||
test "detects facebook" do | ||
browser = Browser.new(Browser["FACEBOOK"]) | ||
|
||
assert_equal "Facebook", browser.name | ||
assert browser.facebook? | ||
assert_equal "135.0.0.45.90", browser.full_version | ||
assert_equal "135", browser.version | ||
end | ||
|
||
test "detects version by range" do | ||
browser = Browser.new(Browser["FACEBOOK"]) | ||
assert browser.facebook?(%w[>=135]) | ||
end | ||
end |