browser 5.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +57 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/README.md +3 -3
- data/browser.gemspec +3 -3
- data/lib/browser/accept_language.rb +4 -4
- data/lib/browser/alipay.rb +1 -1
- data/lib/browser/base.rb +12 -8
- data/lib/browser/blackberry.rb +1 -1
- data/lib/browser/bot/keyword_matcher.rb +1 -1
- data/lib/browser/browser.rb +1 -2
- data/lib/browser/chrome.rb +2 -2
- data/lib/browser/device.rb +4 -4
- data/lib/browser/device/android.rb +1 -1
- data/lib/browser/device/blackberry_playbook.rb +1 -1
- data/lib/browser/device/ipad.rb +1 -1
- data/lib/browser/device/iphone.rb +1 -1
- data/lib/browser/device/ipod_touch.rb +1 -1
- data/lib/browser/device/kindle.rb +1 -1
- data/lib/browser/device/kindle_fire.rb +1 -1
- data/lib/browser/device/playstation3.rb +1 -1
- data/lib/browser/device/playstation4.rb +1 -1
- data/lib/browser/device/psp.rb +1 -1
- data/lib/browser/device/psvita.rb +1 -1
- data/lib/browser/device/surface.rb +1 -1
- data/lib/browser/device/switch.rb +1 -1
- data/lib/browser/device/tv.rb +1 -1
- data/lib/browser/device/wii.rb +1 -1
- data/lib/browser/device/wiiu.rb +1 -1
- data/lib/browser/device/xbox_360.rb +1 -1
- data/lib/browser/device/xbox_one.rb +1 -1
- data/lib/browser/duck_duck_go.rb +1 -1
- data/lib/browser/edge.rb +2 -2
- data/lib/browser/electron.rb +1 -1
- data/lib/browser/facebook.rb +1 -1
- data/lib/browser/firefox.rb +1 -1
- data/lib/browser/google_search_app.rb +1 -1
- data/lib/browser/huawei_browser.rb +1 -1
- data/lib/browser/instagram.rb +1 -1
- data/lib/browser/internet_explorer.rb +2 -2
- data/lib/browser/maxthon.rb +1 -1
- data/lib/browser/micro_messenger.rb +1 -1
- data/lib/browser/miui_browser.rb +1 -1
- data/lib/browser/nokia.rb +1 -1
- data/lib/browser/opera.rb +1 -1
- data/lib/browser/otter.rb +1 -1
- data/lib/browser/phantom_js.rb +1 -1
- data/lib/browser/platform.rb +17 -11
- data/lib/browser/platform/adobe_air.rb +1 -1
- data/lib/browser/platform/android.rb +1 -1
- data/lib/browser/platform/blackberry.rb +1 -1
- data/lib/browser/platform/chrome_os.rb +1 -1
- data/lib/browser/platform/firefox_os.rb +1 -1
- data/lib/browser/platform/ios.rb +1 -1
- data/lib/browser/platform/kai_os.rb +23 -0
- data/lib/browser/platform/linux.rb +1 -1
- data/lib/browser/platform/mac.rb +1 -1
- data/lib/browser/platform/windows.rb +1 -1
- data/lib/browser/platform/windows_mobile.rb +1 -1
- data/lib/browser/platform/windows_phone.rb +1 -1
- data/lib/browser/qq.rb +1 -1
- data/lib/browser/safari.rb +2 -2
- data/lib/browser/samsung_browser.rb +1 -1
- data/lib/browser/snapchat.rb +1 -1
- data/lib/browser/sougou_browser.rb +1 -1
- data/lib/browser/sputnik.rb +1 -1
- data/lib/browser/uc_browser.rb +1 -1
- data/lib/browser/version.rb +1 -1
- data/lib/browser/weibo.rb +1 -1
- data/lib/browser/yandex.rb +1 -1
- data/test/ua.yml +2 -0
- data/test/unit/bots_test.rb +1 -1
- data/test/unit/device_test.rb +1 -1
- data/test/unit/kai_os_test.rb +31 -0
- data/test/unit/meta_test.rb +1 -1
- data/test/unit/platform_test.rb +1 -1
- metadata +12 -9
- data/.travis.yml +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e96d048b4f2fa2c1c6abe602294dbfef45fff3fc2d12aee75081d55ecced4e2f
|
4
|
+
data.tar.gz: 48f5cd0b90d5f65420306ec63da2d5484a0176abc9f8ab57f6b13c1610d79eb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a9d718a2306e5216b9f706cba1894fe6d0940863336a648e3d0781158b2f1f5ef3a33bceeaf6d1a8727b6980b801859f48c3e95fa13763d738c9d97d31f4944
|
7
|
+
data.tar.gz: 48ba58451e08e138c2b73a0cab7f320f9e1eeb2ff907b9eaf9cff01370e70e6a3e11995880fddb456e87cff0e23bab9c93e09438dce0ebd990510b10029707cc
|
@@ -0,0 +1,57 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- main
|
10
|
+
|
11
|
+
schedule:
|
12
|
+
- cron: "0 10 * * *"
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
build:
|
16
|
+
name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
|
17
|
+
runs-on: "ubuntu-latest"
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
ruby: ["2.7.x", "2.6.x", "2.5.x"]
|
22
|
+
gemfile:
|
23
|
+
- Gemfile
|
24
|
+
- gemfiles/rails5.gemfile
|
25
|
+
- gemfiles/rails6.gemfile
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v1
|
29
|
+
|
30
|
+
- uses: actions/cache@v2
|
31
|
+
with:
|
32
|
+
path: vendor/bundle
|
33
|
+
key: >
|
34
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles(matrix.gemfile) }}
|
35
|
+
restore-keys: >
|
36
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles(matrix.gemfile) }}
|
37
|
+
|
38
|
+
- name: Set up Ruby
|
39
|
+
uses: actions/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: ${{ matrix.ruby }}
|
42
|
+
|
43
|
+
- name: Install gem dependencies
|
44
|
+
env:
|
45
|
+
RAILS_ENV: test
|
46
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
47
|
+
run: |
|
48
|
+
gem install bundler
|
49
|
+
bundle config path vendor/bundle
|
50
|
+
bundle update --jobs 4 --retry 3
|
51
|
+
|
52
|
+
- name: Run Tests
|
53
|
+
env:
|
54
|
+
RAILS_ENV: test
|
55
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
56
|
+
run: |
|
57
|
+
bundle exec rake
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Browser
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Tests](https://github.com/fnando/browser/workflows/Tests/badge.svg)](https://github.com/fnando/browser)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/fnando/browser/badges/gpa.svg)](https://codeclimate.com/github/fnando/browser)
|
5
|
-
[![Test Coverage](https://codeclimate.com/github/fnando/browser/badges/coverage.svg)](https://codeclimate.com/github/fnando/browser/coverage)
|
6
5
|
[![Gem](https://img.shields.io/gem/v/browser.svg)](https://rubygems.org/gems/browser)
|
7
6
|
[![Gem](https://img.shields.io/gem/dt/browser.svg)](https://rubygems.org/gems/browser)
|
8
7
|
|
@@ -131,6 +130,7 @@ browser.platform.windows_wow64?
|
|
131
130
|
browser.platform.windows_x64?
|
132
131
|
browser.platform.windows_x64_inclusive?
|
133
132
|
browser.platform.windows_xp?
|
133
|
+
browser.platform.kai_os?
|
134
134
|
```
|
135
135
|
|
136
136
|
### Aliases
|
@@ -305,7 +305,7 @@ To add custom matchers, you can add a callable object to
|
|
305
305
|
`externalhit` substring on it. The bot name will always be `General Bot`.
|
306
306
|
|
307
307
|
```ruby
|
308
|
-
Browser::Bot.matchers << ->(ua, _browser) { ua
|
308
|
+
Browser::Bot.matchers << ->(ua, _browser) { ua.match?(/externalhit/i) }
|
309
309
|
```
|
310
310
|
|
311
311
|
To clear all matchers, including the ones that are bundled, use
|
data/browser.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = s.summary
|
14
14
|
s.license = "MIT"
|
15
15
|
|
16
|
-
s.metadata["changelog_uri"] = "https://github.com/fnando/browser/blob/
|
17
|
-
|
16
|
+
s.metadata["changelog_uri"] = "https://github.com/fnando/browser/blob/main/CHANGELOG.md"
|
17
|
+
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
20
|
s.executables = `git ls-files -- exe/*`
|
@@ -31,6 +31,6 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_development_dependency "rails"
|
32
32
|
s.add_development_dependency "rake"
|
33
33
|
s.add_development_dependency "rubocop"
|
34
|
-
s.add_development_dependency "rubocop-fnando"
|
34
|
+
s.add_development_dependency "rubocop-fnando"
|
35
35
|
s.add_development_dependency "simplecov"
|
36
36
|
end
|
@@ -48,15 +48,15 @@ module Browser
|
|
48
48
|
def quality
|
49
49
|
@quality ||= begin
|
50
50
|
Float(quality_value || 1.0)
|
51
|
-
|
52
|
-
|
51
|
+
rescue ArgumentError
|
52
|
+
0.1
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
private def quality_value
|
57
57
|
qvalue = part[/;q=([\d.]+)/, 1]
|
58
|
-
qvalue =
|
59
|
-
qvalue = qvalue.
|
58
|
+
qvalue = /\A0\.0?\z/.match?(qvalue) ? "0.0" : qvalue
|
59
|
+
qvalue = qvalue.squeeze(".") if qvalue
|
60
60
|
qvalue
|
61
61
|
end
|
62
62
|
end
|
data/lib/browser/alipay.rb
CHANGED
data/lib/browser/base.rb
CHANGED
@@ -106,19 +106,20 @@ module Browser
|
|
106
106
|
|
107
107
|
# Detect if browser is WebKit-based.
|
108
108
|
def webkit?(expected_version = nil)
|
109
|
-
ua
|
109
|
+
ua.match?(/AppleWebKit/i) &&
|
110
110
|
(!edge? || Edge.new(ua).chrome_based?) &&
|
111
111
|
detect_version?(webkit_full_version, expected_version)
|
112
112
|
end
|
113
113
|
|
114
114
|
# Detect if browser is QuickTime
|
115
115
|
def quicktime?(expected_version = nil)
|
116
|
-
ua
|
116
|
+
ua.match?(/QuickTime/i) && detect_version?(full_version, expected_version)
|
117
117
|
end
|
118
118
|
|
119
119
|
# Detect if browser is Apple CoreMedia.
|
120
120
|
def core_media?(expected_version = nil)
|
121
|
-
ua
|
121
|
+
ua.include?("CoreMedia") && detect_version?(full_version,
|
122
|
+
expected_version)
|
122
123
|
end
|
123
124
|
|
124
125
|
# Detect if browser is PhantomJS
|
@@ -133,7 +134,7 @@ module Browser
|
|
133
134
|
end
|
134
135
|
|
135
136
|
def safari_webapp_mode?
|
136
|
-
(device.ipad? || device.iphone?) && ua
|
137
|
+
(device.ipad? || device.iphone?) && ua.include?("AppleWebKit")
|
137
138
|
end
|
138
139
|
|
139
140
|
# Detect if browser is Firefox.
|
@@ -191,17 +192,20 @@ module Browser
|
|
191
192
|
|
192
193
|
# Detect if browser is Opera Mini.
|
193
194
|
def opera_mini?(expected_version = nil)
|
194
|
-
ua
|
195
|
+
ua.include?("Opera Mini") && detect_version?(full_version,
|
196
|
+
expected_version)
|
195
197
|
end
|
196
198
|
|
197
199
|
# Detect if browser is DuckDuckGo.
|
198
200
|
def duck_duck_go?(expected_version = nil)
|
199
|
-
ua
|
201
|
+
ua.include?("DuckDuckGo") && detect_version?(full_version,
|
202
|
+
expected_version)
|
200
203
|
end
|
201
204
|
|
202
205
|
# Detect if browser is Samsung.
|
203
206
|
def samsung_browser?(expected_version = nil)
|
204
|
-
ua
|
207
|
+
ua.include?("SamsungBrowser") && detect_version?(full_version,
|
208
|
+
expected_version)
|
205
209
|
end
|
206
210
|
|
207
211
|
# Detect if browser is Huawei.
|
@@ -234,7 +238,7 @@ module Browser
|
|
234
238
|
|
235
239
|
# Detect if browser is Google Search App
|
236
240
|
def google_search_app?(expected_version = nil)
|
237
|
-
ua
|
241
|
+
ua.include?("GSA") && detect_version?(full_version, expected_version)
|
238
242
|
end
|
239
243
|
|
240
244
|
def webkit_full_version
|
data/lib/browser/blackberry.rb
CHANGED
data/lib/browser/browser.rb
CHANGED
data/lib/browser/chrome.rb
CHANGED
data/lib/browser/device.rb
CHANGED
@@ -160,12 +160,12 @@ module Browser
|
|
160
160
|
|
161
161
|
# Detect if browser is Silk.
|
162
162
|
def silk?
|
163
|
-
ua
|
163
|
+
ua.include?("Silk")
|
164
164
|
end
|
165
165
|
|
166
166
|
# Detect if browser is running under Xbox.
|
167
167
|
def xbox?
|
168
|
-
ua
|
168
|
+
ua.include?("Xbox")
|
169
169
|
end
|
170
170
|
|
171
171
|
# Detect if browser is running under Xbox 360.
|
@@ -202,9 +202,9 @@ module Browser
|
|
202
202
|
# rubocop:disable Layout/LineLength
|
203
203
|
private def detect_mobile?
|
204
204
|
psp? ||
|
205
|
-
/zunewp7/i.match(ua) ||
|
205
|
+
/zunewp7/i.match?(ua) ||
|
206
206
|
%r{(android|bb\d+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino}i.match(ua) ||
|
207
|
-
%r{1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-}i.match(ua[0..3])
|
207
|
+
%r{1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-}i.match?(ua[0..3])
|
208
208
|
end
|
209
209
|
# rubocop:enable Layout/LineLength
|
210
210
|
|
data/lib/browser/device/ipad.rb
CHANGED
data/lib/browser/device/psp.rb
CHANGED
data/lib/browser/device/tv.rb
CHANGED