Skip to content

Commit

Permalink
All platform detection methods can now compare versions.
Browse files Browse the repository at this point in the history
The exceptions are `#linux?` and `#firefox_os?`.
  • Loading branch information
fnando committed Apr 16, 2017
1 parent e808ab8 commit 53231c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Add Proximic Spider, NewRelic pinger and SocialRank bots.
- Add Pinboard in-app browser to the bot exception list.
- All browser detection methods can now compare versions.
- All platform detection methods can now compare versions (except `#linux?` and `#firefox_os?`).

## v2.3.0

Expand Down
8 changes: 4 additions & 4 deletions lib/browser/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ def subject
.find(&:match?)
end

def adobe_air?
id == :adobe_air
def adobe_air?(expected_version = nil)
id == :adobe_air && detect_version?(version, expected_version)
end

def chrome_os?
id == :chrome_os
def chrome_os?(expected_version = nil)
id == :chrome_os && detect_version?(version, expected_version)
end

def android?(expected_version = nil)
Expand Down
2 changes: 2 additions & 0 deletions test/unit/platform_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,14 @@ def id
assert_equal "Chrome OS", platform.name
assert_equal :chrome_os, platform.id
assert platform.chrome_os?
assert platform.chrome_os?(%w[>=3701 <3702])
assert_equal "3701.81.0", platform.version
end

test "detect adobe air" do
platform = Browser::Platform.new(Browser["ADOBE_AIR"])

assert platform.adobe_air?
assert platform.adobe_air?(%w[>=13 <14])
end
end

0 comments on commit 53231c8

Please sign in to comment.