browser 5.3.1 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{FUNDING.yml → .github/FUNDING.yml} +2 -1
- data/.github/workflows/{tests.yml → ruby-tests.yml} +17 -17
- data/.rubocop.yml +3 -23
- data/CHANGELOG.md +6 -0
- data/LICENSE.md +20 -0
- data/README.md +10 -3
- data/browser.gemspec +4 -5
- data/gemfiles/{rails6_0.gemfile → 7_0.gemfile} +1 -1
- data/gemfiles/{rails6_1.gemfile → 7_1.gemfile} +1 -1
- data/lib/browser/accept_language.rb +1 -1
- data/lib/browser/base.rb +34 -29
- data/lib/browser/browser.rb +4 -3
- data/lib/browser/chrome.rb +4 -0
- data/lib/browser/device.rb +9 -9
- data/lib/browser/edge.rb +1 -1
- data/lib/browser/meta/base.rb +1 -1
- data/lib/browser/platform.rb +1 -1
- data/lib/browser/testing.rb +3 -3
- data/lib/browser/version.rb +1 -1
- data/lib/browser.rb +1 -1
- data/search_engines.yml +1 -0
- data/test/browser_test.rb +3 -3
- data/test/rails_test.rb +1 -1
- data/test/test_helper.rb +4 -2
- data/test/ua.yml +5 -0
- data/test/unit/accept_language_test.rb +1 -1
- data/test/unit/android_app_test.rb +3 -3
- data/test/unit/android_test.rb +17 -17
- data/test/unit/blackberry_test.rb +1 -1
- data/test/unit/bots_test.rb +15 -4
- data/test/unit/chrome_test.rb +1 -0
- data/test/unit/device_test.rb +25 -25
- data/test/unit/edge_test.rb +6 -0
- data/test/unit/electron_test.rb +1 -1
- data/test/unit/facebook_test.rb +3 -3
- data/test/unit/generic_test.rb +3 -3
- data/test/unit/instagram_test.rb +2 -2
- data/test/unit/internet_explorer_test.rb +18 -18
- data/test/unit/ios_app_test.rb +3 -3
- data/test/unit/ios_test.rb +12 -12
- data/test/unit/kindle_test.rb +15 -0
- data/test/unit/meta_test.rb +13 -13
- data/test/unit/platform_test.rb +33 -25
- data/test/unit/proxy_test.rb +2 -2
- data/test/unit/safari_test.rb +14 -9
- data/test/unit/snapchat_test.rb +3 -3
- data/test/unit/uc_browser_test.rb +1 -1
- data/test/unit/windows_test.rb +11 -11
- metadata +12 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 955928c52746af052fa9e4acb5555ba3d438326670ee5b587f7a66eff89193f5
|
4
|
+
data.tar.gz: a9a9a822b3dcac0fa8b5a1f946e60c1c4eef3bc2801c41b990b33c496bb635ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b35967db554e9dc880c4998418fde96e2fd8c75283ebc9549c948754ce9b9b383fc5977cfe1008ae176e4e00c7ecf1318d0ed8bc31f987ed19aaef294cbb669b
|
7
|
+
data.tar.gz: 845a5a586f88a402f967a1c5ce43cdb3f736c33aa78288e23972f4ee14e07d81fa805bef169000979d14dcb9d24299ef008d452c29c04b88b50e3516f76b3baf
|
@@ -1,48 +1,47 @@
|
|
1
|
-
|
1
|
+
---
|
2
|
+
name: ruby-tests
|
2
3
|
|
3
4
|
on:
|
4
|
-
|
5
|
-
branches:
|
6
|
-
- main
|
5
|
+
pull_request_target:
|
7
6
|
push:
|
8
7
|
branches:
|
9
8
|
- main
|
10
|
-
|
11
|
-
|
12
|
-
- cron: "0 10 * * *"
|
9
|
+
workflow_dispatch:
|
10
|
+
inputs: {}
|
13
11
|
|
14
12
|
jobs:
|
15
13
|
build:
|
16
14
|
name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
|
17
15
|
runs-on: "ubuntu-latest"
|
16
|
+
if: |
|
17
|
+
github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target' ||
|
18
|
+
github.actor != 'dependabot[bot]'
|
18
19
|
strategy:
|
19
20
|
fail-fast: false
|
20
21
|
matrix:
|
21
|
-
ruby: ["3.
|
22
|
+
ruby: ["3.2", "3.3"]
|
22
23
|
gemfile:
|
23
24
|
- Gemfile
|
24
|
-
- gemfiles/
|
25
|
-
- gemfiles/
|
25
|
+
- gemfiles/7_1.gemfile
|
26
|
+
- gemfiles/6_1.gemfile
|
26
27
|
|
27
28
|
steps:
|
28
|
-
- uses: actions/checkout@
|
29
|
+
- uses: actions/checkout@v2.4.0
|
29
30
|
|
30
31
|
- uses: actions/cache@v2
|
31
32
|
with:
|
32
33
|
path: vendor/bundle
|
33
34
|
key: >
|
34
|
-
${{ runner.os }}-${{ matrix.ruby }}-gems-${{
|
35
|
-
|
36
|
-
${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles(matrix.gemfile) }}
|
35
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-${{
|
36
|
+
hashFiles(matrix.gemfile) }}
|
37
37
|
|
38
38
|
- name: Set up Ruby
|
39
|
-
uses:
|
39
|
+
uses: ruby/setup-ruby@v1
|
40
40
|
with:
|
41
41
|
ruby-version: ${{ matrix.ruby }}
|
42
42
|
|
43
43
|
- name: Install gem dependencies
|
44
44
|
env:
|
45
|
-
RAILS_ENV: test
|
46
45
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
47
46
|
run: |
|
48
47
|
gem install bundler
|
@@ -51,7 +50,8 @@ jobs:
|
|
51
50
|
|
52
51
|
- name: Run Tests
|
53
52
|
env:
|
54
|
-
|
53
|
+
PGHOST: localhost
|
54
|
+
PGUSER: postgres
|
55
55
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
56
56
|
run: |
|
57
57
|
bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -4,6 +4,7 @@ inherit_gem:
|
|
4
4
|
|
5
5
|
AllCops:
|
6
6
|
TargetRubyVersion: 2.5
|
7
|
+
NewCops: enable
|
7
8
|
Exclude:
|
8
9
|
- bin/**/*
|
9
10
|
- gemfiles/**/*
|
@@ -13,29 +14,8 @@ AllCops:
|
|
13
14
|
- "*.gemspec"
|
14
15
|
- config.ru
|
15
16
|
|
16
|
-
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Layout/LineLength:
|
20
|
-
Max: 80
|
21
|
-
|
22
|
-
Metrics/MethodLength:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
Style/Alias:
|
26
|
-
EnforcedStyle: prefer_alias_method
|
27
|
-
|
28
|
-
Lint/RedundantCopDisableDirective:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
Metrics/AbcSize:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
Metrics/CyclomaticComplexity:
|
35
|
-
Enabled: false
|
36
|
-
|
37
|
-
Metrics/PerceivedComplexity:
|
17
|
+
Naming/VariableNumber:
|
38
18
|
Enabled: false
|
39
19
|
|
40
|
-
|
20
|
+
Minitest/EmptyLineBeforeAssertionMethods:
|
41
21
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2010 Nando Vieira
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Browser
|
2
2
|
|
3
|
-
[![Tests](https://github.com/fnando/browser/workflows/
|
4
|
-
[![Code Climate](https://codeclimate.com/github/fnando/browser/badges/gpa.svg)](https://codeclimate.com/github/fnando/browser)
|
3
|
+
[![Tests](https://github.com/fnando/browser/workflows/ruby-tests/badge.svg)](https://github.com/fnando/browser)
|
5
4
|
[![Gem](https://img.shields.io/gem/v/browser.svg)](https://rubygems.org/gems/browser)
|
6
5
|
[![Gem](https://img.shields.io/gem/dt/browser.svg)](https://rubygems.org/gems/browser)
|
7
6
|
|
@@ -23,6 +22,7 @@ browser = Browser.new("Some User Agent", accept_language: "en-us")
|
|
23
22
|
# General info
|
24
23
|
browser.bot?
|
25
24
|
browser.chrome?
|
25
|
+
browser.chromium_based?
|
26
26
|
browser.core_media?
|
27
27
|
browser.duck_duck_go?
|
28
28
|
browser.edge? # Newest MS browser
|
@@ -53,7 +53,6 @@ browser.yandex?
|
|
53
53
|
browser.wechat?
|
54
54
|
browser.qq?
|
55
55
|
browser.weibo?
|
56
|
-
browser.yandex?
|
57
56
|
browser.sputnik?
|
58
57
|
browser.sougou_browser?
|
59
58
|
|
@@ -323,6 +322,14 @@ Browser::Bot.matchers.delete(Browser::Bot::KeywordMatcher)
|
|
323
322
|
Browser::Bot.matchers.delete(Browser::Bot::EmptyUserAgentMatcher)
|
324
323
|
```
|
325
324
|
|
325
|
+
To extend the bot list, you can manipulate the methods below:
|
326
|
+
|
327
|
+
```ruby
|
328
|
+
Browser::Bot.bots.merge!(new_bots_hash)
|
329
|
+
Browser::Bot.bot_exceptions += new_exceptions
|
330
|
+
Browser::Bot.search_engines.merge!(new_search_engines_hash)
|
331
|
+
```
|
332
|
+
|
326
333
|
### Middleware
|
327
334
|
|
328
335
|
You can use the `Browser::Middleware` to redirect user agents.
|
data/browser.gemspec
CHANGED
@@ -7,27 +7,26 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Browser::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Nando Vieira"]
|
10
|
-
s.email = ["fnando.
|
10
|
+
s.email = ["me@fnando.com"]
|
11
11
|
s.homepage = "https://github.com/fnando/browser"
|
12
12
|
s.summary = "Do some browser detection with Ruby."
|
13
13
|
s.description = s.summary
|
14
14
|
s.license = "MIT"
|
15
|
-
s.required_ruby_version = ">= 2.
|
15
|
+
s.required_ruby_version = ">= 3.2.0"
|
16
16
|
|
17
|
+
s.metadata["rubygems_mfa_required"] = "true"
|
17
18
|
s.metadata["changelog_uri"] = "https://github.com/fnando/browser/blob/main/CHANGELOG.md"
|
18
19
|
|
19
20
|
s.files = `git ls-files`.split("\n")
|
20
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
21
|
s.executables = `git ls-files -- exe/*`
|
22
22
|
.split("\n")
|
23
23
|
.map {|f| File.basename(f) }
|
24
24
|
s.require_paths = ["lib"]
|
25
25
|
|
26
|
-
s.add_development_dependency "bundler"
|
26
|
+
s.add_development_dependency "bundler"
|
27
27
|
s.add_development_dependency "minitest"
|
28
28
|
s.add_development_dependency "minitest-autotest"
|
29
29
|
s.add_development_dependency "minitest-utils"
|
30
|
-
s.add_development_dependency "pry-meta"
|
31
30
|
s.add_development_dependency "rack-test"
|
32
31
|
s.add_development_dependency "rails"
|
33
32
|
s.add_development_dependency "rake"
|
data/lib/browser/base.rb
CHANGED
@@ -26,7 +26,7 @@ module Browser
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
alias to_a meta
|
30
30
|
|
31
31
|
# Return meta representation as string.
|
32
32
|
def to_s
|
@@ -59,13 +59,13 @@ module Browser
|
|
59
59
|
|
60
60
|
# Detect if browser is Microsoft Internet Explorer.
|
61
61
|
def ie?(expected_version = nil)
|
62
|
-
InternetExplorer
|
62
|
+
instance_of?(InternetExplorer) &&
|
63
63
|
detect_version?(full_version, expected_version)
|
64
64
|
end
|
65
65
|
|
66
66
|
# Detect if browser is Microsoft Edge.
|
67
67
|
def edge?(expected_version = nil)
|
68
|
-
Edge
|
68
|
+
instance_of?(Edge) && detect_version?(full_version, expected_version)
|
69
69
|
end
|
70
70
|
|
71
71
|
def compatibility_view?
|
@@ -82,32 +82,32 @@ module Browser
|
|
82
82
|
|
83
83
|
# Detect if browser is Instagram.
|
84
84
|
def instagram?(expected_version = nil)
|
85
|
-
Instagram
|
85
|
+
instance_of?(Instagram) &&
|
86
86
|
detect_version?(full_version, expected_version)
|
87
87
|
end
|
88
88
|
|
89
89
|
# Detect if browser is Snapchat.
|
90
90
|
def snapchat?(expected_version = nil)
|
91
|
-
Snapchat
|
91
|
+
instance_of?(Snapchat) &&
|
92
92
|
detect_version?(full_version, expected_version)
|
93
93
|
end
|
94
94
|
|
95
95
|
# Detect if browser if Facebook.
|
96
96
|
def facebook?(expected_version = nil)
|
97
|
-
Facebook
|
97
|
+
instance_of?(Facebook) &&
|
98
98
|
detect_version?(full_version, expected_version)
|
99
99
|
end
|
100
100
|
|
101
101
|
# Detect if browser is Otter.
|
102
102
|
def otter?(expected_version = nil)
|
103
|
-
Otter
|
103
|
+
instance_of?(Otter) &&
|
104
104
|
detect_version?(full_version, expected_version)
|
105
105
|
end
|
106
106
|
|
107
107
|
# Detect if browser is WebKit-based.
|
108
108
|
def webkit?(expected_version = nil)
|
109
109
|
ua.match?(/AppleWebKit/i) &&
|
110
|
-
(!edge? ||
|
110
|
+
(!edge? || chromium_based?) &&
|
111
111
|
detect_version?(webkit_full_version, expected_version)
|
112
112
|
end
|
113
113
|
|
@@ -124,13 +124,13 @@ module Browser
|
|
124
124
|
|
125
125
|
# Detect if browser is PhantomJS
|
126
126
|
def phantom_js?(expected_version = nil)
|
127
|
-
PhantomJS
|
127
|
+
instance_of?(PhantomJS) &&
|
128
128
|
detect_version?(full_version, expected_version)
|
129
129
|
end
|
130
130
|
|
131
131
|
# Detect if browser is Safari.
|
132
132
|
def safari?(expected_version = nil)
|
133
|
-
Safari
|
133
|
+
instance_of?(Safari) && detect_version?(full_version, expected_version)
|
134
134
|
end
|
135
135
|
|
136
136
|
def safari_webapp_mode?
|
@@ -139,55 +139,55 @@ module Browser
|
|
139
139
|
|
140
140
|
# Detect if browser is Firefox.
|
141
141
|
def firefox?(expected_version = nil)
|
142
|
-
Firefox
|
142
|
+
instance_of?(Firefox) && detect_version?(full_version, expected_version)
|
143
143
|
end
|
144
144
|
|
145
145
|
# Detect if browser is Chrome.
|
146
146
|
def chrome?(expected_version = nil)
|
147
|
-
Chrome
|
147
|
+
instance_of?(Chrome) && detect_version?(full_version, expected_version)
|
148
148
|
end
|
149
149
|
|
150
150
|
# Detect if browser is Opera.
|
151
151
|
def opera?(expected_version = nil)
|
152
|
-
Opera
|
152
|
+
instance_of?(Opera) && detect_version?(full_version, expected_version)
|
153
153
|
end
|
154
154
|
|
155
155
|
# Detect if browser is Sputnik.
|
156
156
|
def sputnik?(expected_version = nil)
|
157
|
-
Sputnik
|
157
|
+
instance_of?(Sputnik) && detect_version?(full_version, expected_version)
|
158
158
|
end
|
159
159
|
|
160
160
|
# Detect if browser is Yandex.
|
161
161
|
def yandex?(expected_version = nil)
|
162
|
-
Yandex
|
162
|
+
instance_of?(Yandex) && detect_version?(full_version, expected_version)
|
163
163
|
end
|
164
|
-
|
164
|
+
alias yandex_browser? yandex?
|
165
165
|
|
166
166
|
# Detect if browser is UCBrowser.
|
167
167
|
def uc_browser?(expected_version = nil)
|
168
|
-
UCBrowser
|
168
|
+
instance_of?(UCBrowser) &&
|
169
169
|
detect_version?(full_version, expected_version)
|
170
170
|
end
|
171
171
|
|
172
172
|
# Detect if browser is Nokia S40 Ovi Browser.
|
173
173
|
def nokia?(expected_version = nil)
|
174
|
-
Nokia
|
174
|
+
instance_of?(Nokia) && detect_version?(full_version, expected_version)
|
175
175
|
end
|
176
176
|
|
177
177
|
# Detect if browser is MicroMessenger.
|
178
178
|
def micro_messenger?(expected_version = nil)
|
179
|
-
MicroMessenger
|
179
|
+
instance_of?(MicroMessenger) &&
|
180
180
|
detect_version?(full_version, expected_version)
|
181
181
|
end
|
182
182
|
|
183
|
-
|
183
|
+
alias wechat? micro_messenger?
|
184
184
|
|
185
185
|
def weibo?(expected_version = nil)
|
186
|
-
Weibo
|
186
|
+
instance_of?(Weibo) && detect_version?(full_version, expected_version)
|
187
187
|
end
|
188
188
|
|
189
189
|
def alipay?(expected_version = nil)
|
190
|
-
Alipay
|
190
|
+
instance_of?(Alipay) && detect_version?(full_version, expected_version)
|
191
191
|
end
|
192
192
|
|
193
193
|
# Detect if browser is Opera Mini.
|
@@ -210,29 +210,29 @@ module Browser
|
|
210
210
|
|
211
211
|
# Detect if browser is Huawei.
|
212
212
|
def huawei_browser?(expected_version = nil)
|
213
|
-
HuaweiBrowser
|
213
|
+
instance_of?(HuaweiBrowser) &&
|
214
214
|
detect_version?(full_version, expected_version)
|
215
215
|
end
|
216
216
|
|
217
217
|
# Detect if browser is Xiaomi Miui.
|
218
218
|
def miui_browser?(expected_version = nil)
|
219
|
-
MiuiBrowser
|
219
|
+
instance_of?(MiuiBrowser) &&
|
220
220
|
detect_version?(full_version, expected_version)
|
221
221
|
end
|
222
222
|
|
223
223
|
# Detect if browser is Maxthon.
|
224
224
|
def maxthon?(expected_version = nil)
|
225
|
-
Maxthon
|
225
|
+
instance_of?(Maxthon) && detect_version?(full_version, expected_version)
|
226
226
|
end
|
227
227
|
|
228
228
|
# Detect if browser is QQ.
|
229
229
|
def qq?(expected_version = nil)
|
230
|
-
QQ
|
230
|
+
instance_of?(QQ) && detect_version?(full_version, expected_version)
|
231
231
|
end
|
232
232
|
|
233
233
|
# Detect if browser is Sougou.
|
234
234
|
def sougou_browser?(expected_version = nil)
|
235
|
-
SougouBrowser
|
235
|
+
instance_of?(SougouBrowser) &&
|
236
236
|
detect_version?(full_version, expected_version)
|
237
237
|
end
|
238
238
|
|
@@ -241,6 +241,11 @@ module Browser
|
|
241
241
|
ua.include?("GSA") && detect_version?(full_version, expected_version)
|
242
242
|
end
|
243
243
|
|
244
|
+
# Detect if browser is Chromium-based.
|
245
|
+
def chromium_based?
|
246
|
+
false
|
247
|
+
end
|
248
|
+
|
244
249
|
def webkit_full_version
|
245
250
|
ua[%r{AppleWebKit/([\d.]+)}, 1] || "0.0"
|
246
251
|
end
|
@@ -260,12 +265,12 @@ module Browser
|
|
260
265
|
|
261
266
|
# Detect if the browser is Electron.
|
262
267
|
def electron?(expected_version = nil)
|
263
|
-
Electron
|
268
|
+
instance_of?(Electron) && detect_version?(full_version, expected_version)
|
264
269
|
end
|
265
270
|
|
266
271
|
private def validate_size(subject, input)
|
267
272
|
actual_bytesize = input.bytesize
|
268
|
-
size_limit = Browser.public_send("#{subject}_size_limit")
|
273
|
+
size_limit = Browser.public_send(:"#{subject}_size_limit")
|
269
274
|
|
270
275
|
return if actual_bytesize < size_limit
|
271
276
|
|
data/lib/browser/browser.rb
CHANGED
@@ -101,8 +101,9 @@ module Browser
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def self.new(user_agent, **kwargs)
|
104
|
-
matchers
|
105
|
-
|
106
|
-
.
|
104
|
+
matchers.each do |matcher_class|
|
105
|
+
matcher = matcher_class.new(user_agent || EMPTY_STRING, **kwargs)
|
106
|
+
return matcher if matcher.match?
|
107
|
+
end
|
107
108
|
end
|
108
109
|
end
|
data/lib/browser/chrome.rb
CHANGED
data/lib/browser/device.rb
CHANGED
@@ -96,7 +96,7 @@ module Browser
|
|
96
96
|
def ipod_touch?
|
97
97
|
id == :ipod_touch
|
98
98
|
end
|
99
|
-
|
99
|
+
alias ipod? ipod_touch?
|
100
100
|
|
101
101
|
def iphone?
|
102
102
|
id == :iphone
|
@@ -105,12 +105,12 @@ module Browser
|
|
105
105
|
def ps3?
|
106
106
|
id == :ps3
|
107
107
|
end
|
108
|
-
|
108
|
+
alias playstation3? ps3?
|
109
109
|
|
110
110
|
def ps4?
|
111
111
|
id == :ps4
|
112
112
|
end
|
113
|
-
|
113
|
+
alias playstation4? ps4?
|
114
114
|
|
115
115
|
def psp?
|
116
116
|
id == :psp
|
@@ -119,8 +119,8 @@ module Browser
|
|
119
119
|
def playstation_vita?
|
120
120
|
id == :psvita
|
121
121
|
end
|
122
|
-
|
123
|
-
|
122
|
+
alias vita? playstation_vita?
|
123
|
+
alias psp_vita? playstation_vita?
|
124
124
|
|
125
125
|
def kindle?
|
126
126
|
id == :kindle || kindle_fire?
|
@@ -133,22 +133,22 @@ module Browser
|
|
133
133
|
def nintendo_wii?
|
134
134
|
id == :wii
|
135
135
|
end
|
136
|
-
|
136
|
+
alias wii? nintendo_wii?
|
137
137
|
|
138
138
|
def nintendo_wiiu?
|
139
139
|
id == :wiiu
|
140
140
|
end
|
141
|
-
|
141
|
+
alias wiiu? nintendo_wiiu?
|
142
142
|
|
143
143
|
def nintendo_switch?
|
144
144
|
id == :switch
|
145
145
|
end
|
146
|
-
|
146
|
+
alias switch? nintendo_switch?
|
147
147
|
|
148
148
|
def blackberry_playbook?
|
149
149
|
id == :playbook
|
150
150
|
end
|
151
|
-
|
151
|
+
alias playbook? blackberry_playbook?
|
152
152
|
|
153
153
|
def surface?
|
154
154
|
id == :surface
|
data/lib/browser/edge.rb
CHANGED
data/lib/browser/meta/base.rb
CHANGED
data/lib/browser/platform.rb
CHANGED
@@ -138,7 +138,7 @@ module Browser
|
|
138
138
|
def android_app?
|
139
139
|
android? && ua.match?(/\bwv\b/)
|
140
140
|
end
|
141
|
-
|
141
|
+
alias android_webview? android_app?
|
142
142
|
|
143
143
|
# http://msdn.microsoft.com/fr-FR/library/ms537503.aspx#PltToken
|
144
144
|
def windows_xp?
|
data/lib/browser/testing.rb
CHANGED
@@ -16,9 +16,9 @@ module Browser
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.search_engine_user_agents
|
19
|
-
@search_engine_user_agents ||=
|
20
|
-
|
21
|
-
|
19
|
+
@search_engine_user_agents ||= YAML.load_file(
|
20
|
+
Browser.root.join("test/ua_search_engines.yml")
|
21
|
+
)
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.[](key)
|
data/lib/browser/version.rb
CHANGED
data/lib/browser.rb
CHANGED
data/search_engines.yml
CHANGED
data/test/browser_test.rb
CHANGED
@@ -8,7 +8,7 @@ class BrowserTest < Minitest::Test
|
|
8
8
|
assert_equal "Safari", browser.ua
|
9
9
|
end
|
10
10
|
|
11
|
-
test "
|
11
|
+
test "does not fail with nil user agent" do
|
12
12
|
browser = Browser.new(nil)
|
13
13
|
refute browser.known?
|
14
14
|
end
|
@@ -25,7 +25,7 @@ class BrowserTest < Minitest::Test
|
|
25
25
|
Safari
|
26
26
|
UCBrowser
|
27
27
|
].each do |ua|
|
28
|
-
test "
|
28
|
+
test "does not fail when have no version info (#{ua})" do
|
29
29
|
browser = Browser.new(ua)
|
30
30
|
assert_equal "0", browser.version
|
31
31
|
assert_equal "0.0", browser.full_version
|
@@ -117,7 +117,7 @@ class BrowserTest < Minitest::Test
|
|
117
117
|
|
118
118
|
test "returns empty language set for missing accept language" do
|
119
119
|
browser = Browser.new("")
|
120
|
-
|
120
|
+
assert_empty browser.accept_language
|
121
121
|
end
|
122
122
|
|
123
123
|
test "sets accept language while instantiating object" do
|
data/test/rails_test.rb
CHANGED
@@ -26,7 +26,7 @@ class RailsTest < Minitest::Test
|
|
26
26
|
"HTTP_ACCEPT_LANGUAGE" => "en-US;q=0.8"
|
27
27
|
|
28
28
|
assert_equal 200, last_response.status
|
29
|
-
|
29
|
+
assert JSON.parse(last_response.body)["isBot"]
|
30
30
|
assert_equal "en-US", JSON.parse(last_response.body)["acceptLanguages"][0]
|
31
31
|
end
|
32
32
|
end
|