browser 4.2.0 → 5.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +57 -0
  3. data/.rubocop.yml +3 -0
  4. data/CHANGELOG.md +47 -1
  5. data/FUNDING.yml +3 -0
  6. data/README.md +100 -50
  7. data/bots.yml +1 -2
  8. data/browser.gemspec +4 -3
  9. data/gemfiles/{rails6.gemfile → rails6_0.gemfile} +0 -0
  10. data/gemfiles/{rails5.gemfile → rails6_1.gemfile} +1 -1
  11. data/lib/browser/accept_language.rb +4 -4
  12. data/lib/browser/alipay.rb +1 -1
  13. data/lib/browser/base.rb +72 -13
  14. data/lib/browser/blackberry.rb +1 -1
  15. data/lib/browser/bot/keyword_matcher.rb +1 -1
  16. data/lib/browser/browser.rb +21 -2
  17. data/lib/browser/chrome.rb +9 -3
  18. data/lib/browser/device.rb +12 -5
  19. data/lib/browser/device/android.rb +1 -1
  20. data/lib/browser/device/blackberry_playbook.rb +1 -1
  21. data/lib/browser/device/ipad.rb +1 -1
  22. data/lib/browser/device/iphone.rb +1 -1
  23. data/lib/browser/device/ipod_touch.rb +1 -1
  24. data/lib/browser/device/kindle.rb +1 -1
  25. data/lib/browser/device/kindle_fire.rb +1 -1
  26. data/lib/browser/device/playstation3.rb +1 -1
  27. data/lib/browser/device/playstation4.rb +1 -1
  28. data/lib/browser/device/psp.rb +1 -1
  29. data/lib/browser/device/psvita.rb +1 -1
  30. data/lib/browser/device/samsung.rb +33 -0
  31. data/lib/browser/device/surface.rb +1 -1
  32. data/lib/browser/device/switch.rb +1 -1
  33. data/lib/browser/device/tv.rb +1 -1
  34. data/lib/browser/device/unknown.rb +1 -1
  35. data/lib/browser/device/wii.rb +1 -1
  36. data/lib/browser/device/wiiu.rb +1 -1
  37. data/lib/browser/device/xbox_360.rb +1 -1
  38. data/lib/browser/device/xbox_one.rb +1 -1
  39. data/lib/browser/duck_duck_go.rb +1 -1
  40. data/lib/browser/edge.rb +2 -2
  41. data/lib/browser/electron.rb +1 -1
  42. data/lib/browser/facebook.rb +1 -1
  43. data/lib/browser/firefox.rb +1 -1
  44. data/lib/browser/google_search_app.rb +21 -0
  45. data/lib/browser/huawei_browser.rb +21 -0
  46. data/lib/browser/instagram.rb +1 -1
  47. data/lib/browser/internet_explorer.rb +2 -2
  48. data/lib/browser/maxthon.rb +21 -0
  49. data/lib/browser/micro_messenger.rb +1 -1
  50. data/lib/browser/miui_browser.rb +21 -0
  51. data/lib/browser/nokia.rb +1 -1
  52. data/lib/browser/opera.rb +1 -1
  53. data/lib/browser/otter.rb +1 -1
  54. data/lib/browser/phantom_js.rb +1 -1
  55. data/lib/browser/platform.rb +21 -15
  56. data/lib/browser/platform/adobe_air.rb +1 -1
  57. data/lib/browser/platform/android.rb +1 -1
  58. data/lib/browser/platform/blackberry.rb +1 -1
  59. data/lib/browser/platform/chrome_os.rb +1 -1
  60. data/lib/browser/platform/firefox_os.rb +1 -1
  61. data/lib/browser/platform/ios.rb +2 -2
  62. data/lib/browser/platform/kai_os.rb +23 -0
  63. data/lib/browser/platform/linux.rb +1 -1
  64. data/lib/browser/platform/mac.rb +2 -2
  65. data/lib/browser/platform/{other.rb → unknown.rb} +3 -3
  66. data/lib/browser/platform/windows.rb +2 -2
  67. data/lib/browser/platform/windows_mobile.rb +1 -1
  68. data/lib/browser/platform/windows_phone.rb +1 -1
  69. data/lib/browser/qq.rb +1 -1
  70. data/lib/browser/safari.rb +11 -3
  71. data/lib/browser/samsung_browser.rb +1 -1
  72. data/lib/browser/snapchat.rb +1 -1
  73. data/lib/browser/sougou_browser.rb +24 -0
  74. data/lib/browser/sputnik.rb +1 -1
  75. data/lib/browser/uc_browser.rb +1 -1
  76. data/lib/browser/{generic.rb → unknown.rb} +3 -3
  77. data/lib/browser/version.rb +1 -1
  78. data/lib/browser/weibo.rb +1 -1
  79. data/lib/browser/yandex.rb +1 -1
  80. data/samsung.yml +138 -0
  81. data/test/browser_test.rb +37 -6
  82. data/test/ua.yml +18 -4
  83. data/test/ua_bots.yml +0 -1
  84. data/test/unit/adobe_air_test.rb +1 -1
  85. data/test/unit/alipay_test.rb +6 -0
  86. data/test/unit/bots_test.rb +1 -1
  87. data/test/unit/console_test.rb +2 -2
  88. data/test/unit/device_test.rb +30 -3
  89. data/test/unit/duck_duck_go_test.rb +2 -0
  90. data/test/unit/google_search_app_test.rb +54 -0
  91. data/test/unit/huawei_browser_test.rb +25 -0
  92. data/test/unit/kai_os_test.rb +31 -0
  93. data/test/unit/maxthon_test.rb +25 -0
  94. data/test/unit/meta_test.rb +10 -1
  95. data/test/unit/miui_browser_test.rb +25 -0
  96. data/test/unit/opera_test.rb +1 -0
  97. data/test/unit/platform_test.rb +7 -7
  98. data/test/unit/qq_test.rb +12 -0
  99. data/test/unit/safari_test.rb +12 -7
  100. data/test/unit/sougou_browser_test.rb +41 -0
  101. metadata +38 -17
  102. data/.travis.yml +0 -23
@@ -20,6 +20,7 @@ class OperaTest < Minitest::Test
20
20
  assert browser.opera?
21
21
  assert browser.webkit?
22
22
  refute browser.chrome?
23
+ refute browser.safari?
23
24
  assert_equal "15.0.1147.44", browser.full_version
24
25
  assert_equal "15", browser.version
25
26
  end
@@ -5,7 +5,7 @@ require "test_helper"
5
5
  class PlatformTest < Minitest::Test
6
6
  class CustomPlatform < Browser::Platform::Base
7
7
  def match?
8
- ua =~ /Custom/
8
+ ua.include?("Custom")
9
9
  end
10
10
 
11
11
  def id
@@ -20,7 +20,7 @@ class PlatformTest < Minitest::Test
20
20
 
21
21
  Browser::Platform.matchers.shift
22
22
  platform = Browser::Platform.new("Custom")
23
- assert_equal :other, platform.id
23
+ assert_equal :unknown_platform, platform.id
24
24
  end
25
25
 
26
26
  test "implements to_s" do
@@ -35,13 +35,13 @@ class PlatformTest < Minitest::Test
35
35
  refute platform == :android
36
36
  end
37
37
 
38
- test "detect other" do
39
- platform = Browser::Platform.new("Other")
38
+ test "detect unknown platforms" do
39
+ platform = Browser::Platform.new("Unknown")
40
40
 
41
- assert_equal "Other", platform.name
42
- assert_equal :other, platform.id
41
+ assert_equal "Unknown", platform.name
42
+ assert_equal :unknown_platform, platform.id
43
43
  assert_equal "0", platform.version
44
- assert platform.other?
44
+ assert platform.unknown?
45
45
  end
46
46
 
47
47
  test "detect ios (iPhone)" do
data/test/unit/qq_test.rb CHANGED
@@ -9,6 +9,9 @@ class QQTest < Minitest::Test
9
9
  assert_equal "6.3.3.432", browser.full_version
10
10
  assert_equal "QQ Browser", browser.name
11
11
  assert_equal :qq, browser.id
12
+
13
+ refute browser.chrome?
14
+ refute browser.safari?
12
15
  end
13
16
 
14
17
  test "detects QQ browser for Android" do
@@ -17,6 +20,9 @@ class QQTest < Minitest::Test
17
20
  assert_equal "6.2", browser.full_version
18
21
  assert_equal "QQ Browser", browser.name
19
22
  assert_equal :qq, browser.id
23
+
24
+ refute browser.chrome?
25
+ refute browser.safari?
20
26
  end
21
27
 
22
28
  test "detects QQ browser for Mac" do
@@ -25,6 +31,9 @@ class QQTest < Minitest::Test
25
31
  assert_equal "4.2.4753.400", browser.full_version
26
32
  assert_equal "QQ Browser", browser.name
27
33
  assert_equal :qq, browser.id
34
+
35
+ refute browser.chrome?
36
+ refute browser.safari?
28
37
  end
29
38
 
30
39
  test "detects QQ browser lite for Mac" do
@@ -33,5 +42,8 @@ class QQTest < Minitest::Test
33
42
  assert_equal "1.0.4", browser.full_version
34
43
  assert_equal "QQ Browser", browser.name
35
44
  assert_equal :qq, browser.id
45
+
46
+ refute browser.chrome?
47
+ refute browser.safari?
36
48
  end
37
49
  end
@@ -7,7 +7,7 @@ class SafariTest < Minitest::Test
7
7
  browser = Browser.new(Browser["SAFARI3"])
8
8
 
9
9
  assert browser.safari?
10
- assert browser.safari?(3)
10
+ assert browser.safari?("~>3.0")
11
11
  assert_equal "3", browser.version
12
12
  assert_equal "3.0.3", browser.full_version
13
13
  end
@@ -16,7 +16,7 @@ class SafariTest < Minitest::Test
16
16
  browser = Browser.new(Browser["SAFARI4"])
17
17
 
18
18
  assert browser.safari?
19
- assert browser.safari?(4)
19
+ assert browser.safari?("~>4.0")
20
20
  assert_equal "4", browser.version
21
21
  assert_equal "4.0.3", browser.full_version
22
22
  end
@@ -25,7 +25,7 @@ class SafariTest < Minitest::Test
25
25
  browser = Browser.new(Browser["SAFARI5"])
26
26
 
27
27
  assert browser.safari?
28
- assert browser.safari?(5)
28
+ assert browser.safari?("~>5.0")
29
29
  assert_equal "5", browser.version
30
30
  assert_equal "5.0.3", browser.full_version
31
31
  end
@@ -34,7 +34,7 @@ class SafariTest < Minitest::Test
34
34
  browser = Browser.new(Browser["SAFARI6"])
35
35
 
36
36
  assert browser.safari?
37
- assert browser.safari?(6)
37
+ assert browser.safari?("~>6.0")
38
38
  assert_equal "6", browser.version
39
39
  assert_equal "6.0", browser.full_version
40
40
  end
@@ -43,7 +43,7 @@ class SafariTest < Minitest::Test
43
43
  browser = Browser.new(Browser["SAFARI7"])
44
44
 
45
45
  assert browser.safari?
46
- assert browser.safari?(7)
46
+ assert browser.safari?("~>7.0")
47
47
  assert_equal "7", browser.version
48
48
  assert_equal "7.0", browser.full_version
49
49
  end
@@ -52,7 +52,7 @@ class SafariTest < Minitest::Test
52
52
  browser = Browser.new(Browser["SAFARI8"])
53
53
 
54
54
  assert browser.safari?
55
- assert browser.safari?(8)
55
+ assert browser.safari?("~>8.0")
56
56
  assert_equal "8", browser.version
57
57
  assert_equal "8.0", browser.full_version
58
58
  end
@@ -61,7 +61,7 @@ class SafariTest < Minitest::Test
61
61
  browser = Browser.new(Browser["SAFARI9"])
62
62
 
63
63
  assert browser.safari?
64
- assert browser.safari?(9)
64
+ assert browser.safari?("~>9.0")
65
65
  assert_equal "9", browser.version
66
66
  assert_equal "9.0.2", browser.full_version
67
67
  end
@@ -88,4 +88,9 @@ class SafariTest < Minitest::Test
88
88
  browser = Browser.new(Browser["SAFARI9"])
89
89
  assert browser.webkit?(%w[>=601 <602])
90
90
  end
91
+
92
+ test "detects safari version by range" do
93
+ browser = Browser.new(Browser["SAFARI9"])
94
+ assert browser.safari?(%w[>=9.0 <10])
95
+ end
91
96
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class SougouBrowserTest < Minitest::Test
6
+ test "detects Sougou Browser on desktop device" do
7
+ browser = Browser.new(Browser["SOUGOU_BROWSER"])
8
+ assert browser.sougou_browser?
9
+ refute browser.safari?
10
+ refute browser.chrome?
11
+ assert_equal "Sougou Browser", browser.name
12
+ assert_equal :sougou_browser, browser.id
13
+ end
14
+
15
+ test "detects correct version on desktop device" do
16
+ browser = Browser.new(Browser["SOUGOU_BROWSER"])
17
+ assert_equal "0.0", browser.full_version
18
+ assert_equal "0", browser.version
19
+ end
20
+
21
+ test "detects Sougou Browser on mobile device" do
22
+ browser = Browser.new(Browser["SOUGOU_BROWSER_MOBILE"])
23
+ assert browser.sougou_browser?
24
+ assert browser.device.mobile?
25
+ refute browser.safari?
26
+ refute browser.chrome?
27
+ assert_equal "Sougou Browser", browser.name
28
+ assert_equal :sougou_browser, browser.id
29
+ end
30
+
31
+ test "detects correct version on mobile device" do
32
+ browser = Browser.new(Browser["SOUGOU_BROWSER_MOBILE"])
33
+ assert_equal "5.28.12", browser.full_version
34
+ assert_equal "5", browser.version
35
+ end
36
+
37
+ test "detects version by range on mobile device" do
38
+ browser = Browser.new(Browser["SOUGOU_BROWSER_MOBILE"])
39
+ assert browser.sougou_browser?(%w[>=5 <6])
40
+ end
41
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 5.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-31 00:00:00.000000000 Z
11
+ date: 2021-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: rubocop-fnando
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 0.0.3
145
+ version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: 0.0.3
152
+ version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -172,11 +172,12 @@ extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
174
  - ".github/ISSUE_TEMPLATE.md"
175
+ - ".github/workflows/tests.yml"
175
176
  - ".gitignore"
176
177
  - ".prettierignore"
177
178
  - ".rubocop.yml"
178
- - ".travis.yml"
179
179
  - CHANGELOG.md
180
+ - FUNDING.yml
180
181
  - Gemfile
181
182
  - README.md
182
183
  - Rakefile
@@ -184,8 +185,8 @@ files:
184
185
  - bots.yml
185
186
  - browser.gemspec
186
187
  - config.ru
187
- - gemfiles/rails5.gemfile
188
- - gemfiles/rails6.gemfile
188
+ - gemfiles/rails6_0.gemfile
189
+ - gemfiles/rails6_1.gemfile
189
190
  - languages.yml
190
191
  - lib/browser.rb
191
192
  - lib/browser/accept_language.rb
@@ -214,6 +215,7 @@ files:
214
215
  - lib/browser/device/playstation4.rb
215
216
  - lib/browser/device/psp.rb
216
217
  - lib/browser/device/psvita.rb
218
+ - lib/browser/device/samsung.rb
217
219
  - lib/browser/device/surface.rb
218
220
  - lib/browser/device/switch.rb
219
221
  - lib/browser/device/tv.rb
@@ -227,9 +229,11 @@ files:
227
229
  - lib/browser/electron.rb
228
230
  - lib/browser/facebook.rb
229
231
  - lib/browser/firefox.rb
230
- - lib/browser/generic.rb
232
+ - lib/browser/google_search_app.rb
233
+ - lib/browser/huawei_browser.rb
231
234
  - lib/browser/instagram.rb
232
235
  - lib/browser/internet_explorer.rb
236
+ - lib/browser/maxthon.rb
233
237
  - lib/browser/meta.rb
234
238
  - lib/browser/meta/base.rb
235
239
  - lib/browser/meta/device.rb
@@ -248,6 +252,7 @@ files:
248
252
  - lib/browser/middleware/context.rb
249
253
  - lib/browser/middleware/context/additions.rb
250
254
  - lib/browser/middleware/context/url_methods.rb
255
+ - lib/browser/miui_browser.rb
251
256
  - lib/browser/nokia.rb
252
257
  - lib/browser/opera.rb
253
258
  - lib/browser/otter.rb
@@ -260,9 +265,10 @@ files:
260
265
  - lib/browser/platform/chrome_os.rb
261
266
  - lib/browser/platform/firefox_os.rb
262
267
  - lib/browser/platform/ios.rb
268
+ - lib/browser/platform/kai_os.rb
263
269
  - lib/browser/platform/linux.rb
264
270
  - lib/browser/platform/mac.rb
265
- - lib/browser/platform/other.rb
271
+ - lib/browser/platform/unknown.rb
266
272
  - lib/browser/platform/windows.rb
267
273
  - lib/browser/platform/windows_mobile.rb
268
274
  - lib/browser/platform/windows_phone.rb
@@ -271,12 +277,15 @@ files:
271
277
  - lib/browser/safari.rb
272
278
  - lib/browser/samsung_browser.rb
273
279
  - lib/browser/snapchat.rb
280
+ - lib/browser/sougou_browser.rb
274
281
  - lib/browser/sputnik.rb
275
282
  - lib/browser/testing.rb
276
283
  - lib/browser/uc_browser.rb
284
+ - lib/browser/unknown.rb
277
285
  - lib/browser/version.rb
278
286
  - lib/browser/weibo.rb
279
287
  - lib/browser/yandex.rb
288
+ - samsung.yml
280
289
  - search_engines.yml
281
290
  - test/browser_test.rb
282
291
  - test/middleware_test.rb
@@ -303,13 +312,18 @@ files:
303
312
  - test/unit/facebook_test.rb
304
313
  - test/unit/firefox_test.rb
305
314
  - test/unit/generic_test.rb
315
+ - test/unit/google_search_app_test.rb
316
+ - test/unit/huawei_browser_test.rb
306
317
  - test/unit/instagram_test.rb
307
318
  - test/unit/internet_explorer_test.rb
308
319
  - test/unit/ios_app_test.rb
309
320
  - test/unit/ios_test.rb
321
+ - test/unit/kai_os_test.rb
310
322
  - test/unit/kindle_test.rb
323
+ - test/unit/maxthon_test.rb
311
324
  - test/unit/meta_test.rb
312
325
  - test/unit/micro_messenger_test.rb
326
+ - test/unit/miui_browser_test.rb
313
327
  - test/unit/nokia_test.rb
314
328
  - test/unit/opera_test.rb
315
329
  - test/unit/otter_test.rb
@@ -319,6 +333,7 @@ files:
319
333
  - test/unit/safari_test.rb
320
334
  - test/unit/samsung_browser_test.rb
321
335
  - test/unit/snapchat_test.rb
336
+ - test/unit/sougou_browser_test.rb
322
337
  - test/unit/sputnik_test.rb
323
338
  - test/unit/uc_browser_test.rb
324
339
  - test/unit/weibo_test.rb
@@ -329,8 +344,8 @@ homepage: https://github.com/fnando/browser
329
344
  licenses:
330
345
  - MIT
331
346
  metadata:
332
- changelog_uri: https://github.com/fnando/browser/blob/master/CHANGELOG.md
333
- post_install_message:
347
+ changelog_uri: https://github.com/fnando/browser/blob/main/CHANGELOG.md
348
+ post_install_message:
334
349
  rdoc_options: []
335
350
  require_paths:
336
351
  - lib
@@ -338,15 +353,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
338
353
  requirements:
339
354
  - - ">="
340
355
  - !ruby/object:Gem::Version
341
- version: '0'
356
+ version: 2.5.0
342
357
  required_rubygems_version: !ruby/object:Gem::Requirement
343
358
  requirements:
344
359
  - - ">="
345
360
  - !ruby/object:Gem::Version
346
361
  version: '0'
347
362
  requirements: []
348
- rubygems_version: 3.1.2
349
- signing_key:
363
+ rubygems_version: 3.2.3
364
+ signing_key:
350
365
  specification_version: 4
351
366
  summary: Do some browser detection with Ruby.
352
367
  test_files:
@@ -375,13 +390,18 @@ test_files:
375
390
  - test/unit/facebook_test.rb
376
391
  - test/unit/firefox_test.rb
377
392
  - test/unit/generic_test.rb
393
+ - test/unit/google_search_app_test.rb
394
+ - test/unit/huawei_browser_test.rb
378
395
  - test/unit/instagram_test.rb
379
396
  - test/unit/internet_explorer_test.rb
380
397
  - test/unit/ios_app_test.rb
381
398
  - test/unit/ios_test.rb
399
+ - test/unit/kai_os_test.rb
382
400
  - test/unit/kindle_test.rb
401
+ - test/unit/maxthon_test.rb
383
402
  - test/unit/meta_test.rb
384
403
  - test/unit/micro_messenger_test.rb
404
+ - test/unit/miui_browser_test.rb
385
405
  - test/unit/nokia_test.rb
386
406
  - test/unit/opera_test.rb
387
407
  - test/unit/otter_test.rb
@@ -391,6 +411,7 @@ test_files:
391
411
  - test/unit/safari_test.rb
392
412
  - test/unit/samsung_browser_test.rb
393
413
  - test/unit/snapchat_test.rb
414
+ - test/unit/sougou_browser_test.rb
394
415
  - test/unit/sputnik_test.rb
395
416
  - test/unit/uc_browser_test.rb
396
417
  - test/unit/weibo_test.rb
data/.travis.yml DELETED
@@ -1,23 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7
6
- - 2.6
7
- - 2.5
8
- gemfile:
9
- - Gemfile
10
- - gemfiles/rails5.gemfile
11
- - gemfiles/rails6.gemfile
12
- script: bundle exec rake
13
- notifications:
14
- email: false
15
- before_script:
16
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
17
- - chmod +x ./cc-test-reporter
18
- - "./cc-test-reporter before-build"
19
- after_script:
20
- - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
21
- env:
22
- global:
23
- secure: LrxynbbiJMX5vy/UVPfQsnT21oUpqpuHbUM9YOy0+ZYfDCjprvM/UGxFgjM+unRzyPI0mrNyU65ohpj8R1//tvdFW+xYau6QmFgSTU6OAQrckW/n+jqwQZV37a38wEGV0QvA6A0HW9pTrJfatUBmpaAeHAxcaBMk51tEgX/8poA=