browser 3.0.3 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +1 -1
  3. data/.prettierignore +1 -0
  4. data/.rubocop.yml +9 -0
  5. data/CHANGELOG.md +86 -19
  6. data/FUNDING.yml +3 -0
  7. data/README.md +101 -64
  8. data/bots.yml +300 -294
  9. data/browser.gemspec +3 -1
  10. data/lib/browser/base.rb +71 -16
  11. data/lib/browser/browser.rb +27 -26
  12. data/lib/browser/chrome.rb +12 -2
  13. data/lib/browser/device.rb +9 -2
  14. data/lib/browser/device/samsung.rb +33 -0
  15. data/lib/browser/device/unknown.rb +1 -1
  16. data/lib/browser/duck_duck_go.rb +22 -0
  17. data/lib/browser/edge.rb +2 -2
  18. data/lib/browser/google_search_app.rb +21 -0
  19. data/lib/browser/huawei_browser.rb +21 -0
  20. data/lib/browser/maxthon.rb +21 -0
  21. data/lib/browser/meta.rb +0 -1
  22. data/lib/browser/meta/base.rb +0 -1
  23. data/lib/browser/miui_browser.rb +21 -0
  24. data/lib/browser/platform.rb +5 -5
  25. data/lib/browser/platform/base.rb +3 -2
  26. data/lib/browser/platform/ios.rb +1 -1
  27. data/lib/browser/platform/mac.rb +4 -2
  28. data/lib/browser/platform/{other.rb → unknown.rb} +3 -3
  29. data/lib/browser/platform/windows.rb +1 -1
  30. data/lib/browser/safari.rb +16 -1
  31. data/lib/browser/samsung_browser.rb +21 -0
  32. data/lib/browser/sougou_browser.rb +24 -0
  33. data/lib/browser/{generic.rb → unknown.rb} +3 -3
  34. data/lib/browser/version.rb +1 -1
  35. data/samsung.yml +138 -0
  36. data/test/browser_test.rb +37 -6
  37. data/test/ua.yml +21 -1
  38. data/test/ua_bots.yml +8 -2
  39. data/test/unit/adobe_air_test.rb +1 -1
  40. data/test/unit/alipay_test.rb +6 -0
  41. data/test/unit/console_test.rb +2 -2
  42. data/test/unit/device_test.rb +29 -2
  43. data/test/unit/duck_duck_go_test.rb +37 -0
  44. data/test/unit/edge_test.rb +34 -2
  45. data/test/unit/google_search_app_test.rb +54 -0
  46. data/test/unit/huawei_browser_test.rb +25 -0
  47. data/test/unit/maxthon_test.rb +25 -0
  48. data/test/unit/meta_test.rb +9 -0
  49. data/test/unit/micro_messenger_test.rb +21 -6
  50. data/test/unit/miui_browser_test.rb +25 -0
  51. data/test/unit/opera_test.rb +1 -0
  52. data/test/unit/platform_test.rb +12 -7
  53. data/test/unit/qq_test.rb +12 -0
  54. data/test/unit/safari_test.rb +12 -7
  55. data/test/unit/samsung_browser_test.rb +23 -0
  56. data/test/unit/sougou_browser_test.rb +41 -0
  57. metadata +36 -11
  58. data/lib/browser/meta/modern.rb +0 -11
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class MiuiBrowserTest < Minitest::Test
6
+ test "detects Miui Browser" do
7
+ browser = Browser.new(Browser["MIUI_BROWSER"])
8
+ assert browser.miui_browser?
9
+ refute browser.safari?
10
+ refute browser.chrome?
11
+ assert_equal "Miui Browser", browser.name
12
+ assert_equal :miui_browser, browser.id
13
+ end
14
+
15
+ test "detects correct version" do
16
+ browser = Browser.new(Browser["MIUI_BROWSER"])
17
+ assert_equal "12.3.3", browser.full_version
18
+ assert_equal "12", browser.version
19
+ end
20
+
21
+ test "detects version by range" do
22
+ browser = Browser.new(Browser["MIUI_BROWSER"])
23
+ assert browser.miui_browser?(%w[>=12 <13])
24
+ end
25
+ end
@@ -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
@@ -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
@@ -104,7 +104,7 @@ class PlatformTest < Minitest::Test
104
104
  test "detect mac" do
105
105
  platform = Browser::Platform.new(Browser["SAFARI"])
106
106
 
107
- assert_equal "Macintosh", platform.name
107
+ assert_equal "Mac OS X", platform.name
108
108
  assert_equal :mac, platform.id
109
109
  assert platform.mac?
110
110
  assert_equal "10.6.4", platform.version
@@ -116,6 +116,11 @@ class PlatformTest < Minitest::Test
116
116
  assert_equal "0", platform.version
117
117
  end
118
118
 
119
+ test "detect mac names" do
120
+ assert_equal "Mac OS X", Browser::Platform.new(Browser["MAC_OSX"]).name
121
+ assert_equal "macOS", Browser::Platform.new(Browser["MAC_OS"]).name
122
+ end
123
+
119
124
  test "detect firefox os" do
120
125
  platform = Browser::Platform.new(Browser["FIREFOX_OS"])
121
126
 
@@ -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,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class SamsungBrowserTest < Minitest::Test
6
+ test "detects samsung browser" do
7
+ browser = Browser.new(Browser["SAMSUNG_BROWSER"])
8
+
9
+ assert browser.webkit?
10
+ assert browser.samsung_browser?
11
+ assert_equal "11", browser.version
12
+ assert_equal :samsung_browser, browser.id
13
+ assert_equal "11.1", browser.full_version
14
+ assert_equal "Samsung Browser", browser.name
15
+ refute browser.chrome?
16
+ refute browser.safari?
17
+ end
18
+
19
+ test "detects version by range" do
20
+ browser = Browser.new(Browser["SAMSUNG_BROWSER"])
21
+ assert browser.samsung_browser?(%w[>=11 <12])
22
+ end
23
+ 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: 3.0.3
4
+ version: 5.1.0
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-01-10 00:00:00.000000000 Z
11
+ date: 2020-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -173,9 +173,11 @@ extra_rdoc_files: []
173
173
  files:
174
174
  - ".github/ISSUE_TEMPLATE.md"
175
175
  - ".gitignore"
176
+ - ".prettierignore"
176
177
  - ".rubocop.yml"
177
178
  - ".travis.yml"
178
179
  - CHANGELOG.md
180
+ - FUNDING.yml
179
181
  - Gemfile
180
182
  - README.md
181
183
  - Rakefile
@@ -213,6 +215,7 @@ files:
213
215
  - lib/browser/device/playstation4.rb
214
216
  - lib/browser/device/psp.rb
215
217
  - lib/browser/device/psvita.rb
218
+ - lib/browser/device/samsung.rb
216
219
  - lib/browser/device/surface.rb
217
220
  - lib/browser/device/switch.rb
218
221
  - lib/browser/device/tv.rb
@@ -221,13 +224,16 @@ files:
221
224
  - lib/browser/device/wiiu.rb
222
225
  - lib/browser/device/xbox_360.rb
223
226
  - lib/browser/device/xbox_one.rb
227
+ - lib/browser/duck_duck_go.rb
224
228
  - lib/browser/edge.rb
225
229
  - lib/browser/electron.rb
226
230
  - lib/browser/facebook.rb
227
231
  - lib/browser/firefox.rb
228
- - lib/browser/generic.rb
232
+ - lib/browser/google_search_app.rb
233
+ - lib/browser/huawei_browser.rb
229
234
  - lib/browser/instagram.rb
230
235
  - lib/browser/internet_explorer.rb
236
+ - lib/browser/maxthon.rb
231
237
  - lib/browser/meta.rb
232
238
  - lib/browser/meta/base.rb
233
239
  - lib/browser/meta/device.rb
@@ -236,7 +242,6 @@ files:
236
242
  - lib/browser/meta/ie.rb
237
243
  - lib/browser/meta/ios.rb
238
244
  - lib/browser/meta/mobile.rb
239
- - lib/browser/meta/modern.rb
240
245
  - lib/browser/meta/platform.rb
241
246
  - lib/browser/meta/proxy.rb
242
247
  - lib/browser/meta/safari.rb
@@ -247,6 +252,7 @@ files:
247
252
  - lib/browser/middleware/context.rb
248
253
  - lib/browser/middleware/context/additions.rb
249
254
  - lib/browser/middleware/context/url_methods.rb
255
+ - lib/browser/miui_browser.rb
250
256
  - lib/browser/nokia.rb
251
257
  - lib/browser/opera.rb
252
258
  - lib/browser/otter.rb
@@ -261,20 +267,24 @@ files:
261
267
  - lib/browser/platform/ios.rb
262
268
  - lib/browser/platform/linux.rb
263
269
  - lib/browser/platform/mac.rb
264
- - lib/browser/platform/other.rb
270
+ - lib/browser/platform/unknown.rb
265
271
  - lib/browser/platform/windows.rb
266
272
  - lib/browser/platform/windows_mobile.rb
267
273
  - lib/browser/platform/windows_phone.rb
268
274
  - lib/browser/qq.rb
269
275
  - lib/browser/rails.rb
270
276
  - lib/browser/safari.rb
277
+ - lib/browser/samsung_browser.rb
271
278
  - lib/browser/snapchat.rb
279
+ - lib/browser/sougou_browser.rb
272
280
  - lib/browser/sputnik.rb
273
281
  - lib/browser/testing.rb
274
282
  - lib/browser/uc_browser.rb
283
+ - lib/browser/unknown.rb
275
284
  - lib/browser/version.rb
276
285
  - lib/browser/weibo.rb
277
286
  - lib/browser/yandex.rb
287
+ - samsung.yml
278
288
  - search_engines.yml
279
289
  - test/browser_test.rb
280
290
  - test/middleware_test.rb
@@ -295,18 +305,23 @@ files:
295
305
  - test/unit/chrome_test.rb
296
306
  - test/unit/console_test.rb
297
307
  - test/unit/device_test.rb
308
+ - test/unit/duck_duck_go_test.rb
298
309
  - test/unit/edge_test.rb
299
310
  - test/unit/electron_test.rb
300
311
  - test/unit/facebook_test.rb
301
312
  - test/unit/firefox_test.rb
302
313
  - test/unit/generic_test.rb
314
+ - test/unit/google_search_app_test.rb
315
+ - test/unit/huawei_browser_test.rb
303
316
  - test/unit/instagram_test.rb
304
317
  - test/unit/internet_explorer_test.rb
305
318
  - test/unit/ios_app_test.rb
306
319
  - test/unit/ios_test.rb
307
320
  - test/unit/kindle_test.rb
321
+ - test/unit/maxthon_test.rb
308
322
  - test/unit/meta_test.rb
309
323
  - test/unit/micro_messenger_test.rb
324
+ - test/unit/miui_browser_test.rb
310
325
  - test/unit/nokia_test.rb
311
326
  - test/unit/opera_test.rb
312
327
  - test/unit/otter_test.rb
@@ -314,18 +329,21 @@ files:
314
329
  - test/unit/proxy_test.rb
315
330
  - test/unit/qq_test.rb
316
331
  - test/unit/safari_test.rb
332
+ - test/unit/samsung_browser_test.rb
317
333
  - test/unit/snapchat_test.rb
334
+ - test/unit/sougou_browser_test.rb
318
335
  - test/unit/sputnik_test.rb
319
336
  - test/unit/uc_browser_test.rb
320
337
  - test/unit/weibo_test.rb
321
338
  - test/unit/windows_phone_test.rb
322
339
  - test/unit/windows_test.rb
323
340
  - test/unit/yandex_test.rb
324
- homepage: http://github.com/fnando/browser
341
+ homepage: https://github.com/fnando/browser
325
342
  licenses:
326
343
  - MIT
327
- metadata: {}
328
- post_install_message:
344
+ metadata:
345
+ changelog_uri: https://github.com/fnando/browser/blob/master/CHANGELOG.md
346
+ post_install_message:
329
347
  rdoc_options: []
330
348
  require_paths:
331
349
  - lib
@@ -340,8 +358,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
340
358
  - !ruby/object:Gem::Version
341
359
  version: '0'
342
360
  requirements: []
343
- rubygems_version: 3.1.2
344
- signing_key:
361
+ rubygems_version: 3.1.4
362
+ signing_key:
345
363
  specification_version: 4
346
364
  summary: Do some browser detection with Ruby.
347
365
  test_files:
@@ -364,18 +382,23 @@ test_files:
364
382
  - test/unit/chrome_test.rb
365
383
  - test/unit/console_test.rb
366
384
  - test/unit/device_test.rb
385
+ - test/unit/duck_duck_go_test.rb
367
386
  - test/unit/edge_test.rb
368
387
  - test/unit/electron_test.rb
369
388
  - test/unit/facebook_test.rb
370
389
  - test/unit/firefox_test.rb
371
390
  - test/unit/generic_test.rb
391
+ - test/unit/google_search_app_test.rb
392
+ - test/unit/huawei_browser_test.rb
372
393
  - test/unit/instagram_test.rb
373
394
  - test/unit/internet_explorer_test.rb
374
395
  - test/unit/ios_app_test.rb
375
396
  - test/unit/ios_test.rb
376
397
  - test/unit/kindle_test.rb
398
+ - test/unit/maxthon_test.rb
377
399
  - test/unit/meta_test.rb
378
400
  - test/unit/micro_messenger_test.rb
401
+ - test/unit/miui_browser_test.rb
379
402
  - test/unit/nokia_test.rb
380
403
  - test/unit/opera_test.rb
381
404
  - test/unit/otter_test.rb
@@ -383,7 +406,9 @@ test_files:
383
406
  - test/unit/proxy_test.rb
384
407
  - test/unit/qq_test.rb
385
408
  - test/unit/safari_test.rb
409
+ - test/unit/samsung_browser_test.rb
386
410
  - test/unit/snapchat_test.rb
411
+ - test/unit/sougou_browser_test.rb
387
412
  - test/unit/sputnik_test.rb
388
413
  - test/unit/uc_browser_test.rb
389
414
  - test/unit/weibo_test.rb
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Browser
4
- module Meta
5
- class Modern < Base
6
- def meta
7
- "modern" if browser.modern?
8
- end
9
- end
10
- end
11
- end