-
-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: lichao <[email protected]>
- Loading branch information
1 parent
e28c9a1
commit 8576c7e
Showing
8 changed files
with
65 additions
and
6 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
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 MiuiBrowser < Base | ||
def id | ||
:miui_browser | ||
end | ||
|
||
def name | ||
"Miui Browser" | ||
end | ||
|
||
def full_version | ||
ua[%r{MiuiBrowser/([\d.]+)}, 1] || "0.0" | ||
end | ||
|
||
def match? | ||
ua =~ /MiuiBrowser/ | ||
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
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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class MiuiBrowserTest < Minitest::Test | ||
test "detects Miui Browser" do | ||
browser = Browser.new(Browser["MIUI_BROWSER"]) | ||
assert browser.miui_browser? | ||
refute browser.safari? | ||
refute browser.chrome? | ||
assert_equal "Miui Browser", browser.name | ||
assert_equal :miui_browser, browser.id | ||
end | ||
|
||
test "detects correct version" do | ||
browser = Browser.new(Browser["MIUI_BROWSER"]) | ||
assert_equal "12.3.3", browser.full_version | ||
assert_equal "12", browser.version | ||
end | ||
|
||
test "detects version by range" do | ||
browser = Browser.new(Browser["MIUI_BROWSER"]) | ||
assert browser.miui_browser?(%w[>=12 <13]) | ||
end | ||
end |