browser 2.7.1 → 5.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +1 -1
  3. data/.github/workflows/tests.yml +57 -0
  4. data/.gitignore +1 -0
  5. data/.prettierignore +1 -0
  6. data/.rubocop.yml +13 -1
  7. data/CHANGELOG.md +122 -13
  8. data/FUNDING.yml +3 -0
  9. data/README.md +134 -88
  10. data/Rakefile +8 -1
  11. data/bot_exceptions.yml +1 -0
  12. data/bots.yml +300 -293
  13. data/browser.gemspec +4 -1
  14. data/gemfiles/{rails5.gemfile → rails6_1.gemfile} +1 -1
  15. data/lib/browser/accept_language.rb +4 -4
  16. data/lib/browser/aliases.rb +1 -1
  17. data/lib/browser/alipay.rb +1 -1
  18. data/lib/browser/base.rb +82 -18
  19. data/lib/browser/blackberry.rb +1 -1
  20. data/lib/browser/bot/empty_user_agent_matcher.rb +11 -0
  21. data/lib/browser/bot/keyword_matcher.rb +11 -0
  22. data/lib/browser/bot/known_bots_matcher.rb +11 -0
  23. data/lib/browser/bot.rb +34 -26
  24. data/lib/browser/browser.rb +59 -56
  25. data/lib/browser/chrome.rb +13 -3
  26. data/lib/browser/device/android.rb +1 -1
  27. data/lib/browser/device/blackberry_playbook.rb +1 -1
  28. data/lib/browser/device/ipad.rb +1 -1
  29. data/lib/browser/device/iphone.rb +1 -1
  30. data/lib/browser/device/ipod_touch.rb +1 -1
  31. data/lib/browser/device/kindle.rb +1 -1
  32. data/lib/browser/device/kindle_fire.rb +1 -1
  33. data/lib/browser/device/playstation3.rb +1 -1
  34. data/lib/browser/device/playstation4.rb +1 -1
  35. data/lib/browser/device/psp.rb +1 -1
  36. data/lib/browser/device/psvita.rb +1 -1
  37. data/lib/browser/device/samsung.rb +33 -0
  38. data/lib/browser/device/surface.rb +1 -1
  39. data/lib/browser/device/switch.rb +1 -1
  40. data/lib/browser/device/tv.rb +1 -1
  41. data/lib/browser/device/unknown.rb +1 -1
  42. data/lib/browser/device/wii.rb +1 -1
  43. data/lib/browser/device/wiiu.rb +1 -1
  44. data/lib/browser/device/xbox_360.rb +1 -1
  45. data/lib/browser/device/xbox_one.rb +1 -1
  46. data/lib/browser/device.rb +37 -27
  47. data/lib/browser/duck_duck_go.rb +22 -0
  48. data/lib/browser/edge.rb +3 -3
  49. data/lib/browser/electron.rb +1 -1
  50. data/lib/browser/facebook.rb +1 -1
  51. data/lib/browser/firefox.rb +1 -1
  52. data/lib/browser/google_search_app.rb +21 -0
  53. data/lib/browser/huawei_browser.rb +21 -0
  54. data/lib/browser/instagram.rb +1 -1
  55. data/lib/browser/internet_explorer.rb +2 -2
  56. data/lib/browser/maxthon.rb +21 -0
  57. data/lib/browser/meta/base.rb +0 -1
  58. data/lib/browser/meta.rb +12 -13
  59. data/lib/browser/micro_messenger.rb +1 -1
  60. data/lib/browser/middleware/context/additions.rb +1 -1
  61. data/lib/browser/middleware.rb +1 -1
  62. data/lib/browser/miui_browser.rb +21 -0
  63. data/lib/browser/nokia.rb +1 -1
  64. data/lib/browser/opera.rb +1 -1
  65. data/lib/browser/otter.rb +1 -1
  66. data/lib/browser/phantom_js.rb +1 -1
  67. data/lib/browser/platform/adobe_air.rb +1 -1
  68. data/lib/browser/platform/android.rb +1 -1
  69. data/lib/browser/platform/base.rb +3 -2
  70. data/lib/browser/platform/blackberry.rb +1 -1
  71. data/lib/browser/platform/chrome_os.rb +1 -1
  72. data/lib/browser/platform/firefox_os.rb +1 -1
  73. data/lib/browser/platform/ios.rb +2 -2
  74. data/lib/browser/platform/kai_os.rb +23 -0
  75. data/lib/browser/platform/linux.rb +1 -1
  76. data/lib/browser/platform/mac.rb +5 -3
  77. data/lib/browser/platform/{other.rb → unknown.rb} +3 -3
  78. data/lib/browser/platform/windows.rb +2 -2
  79. data/lib/browser/platform/windows_mobile.rb +1 -1
  80. data/lib/browser/platform/windows_phone.rb +1 -1
  81. data/lib/browser/platform.rb +37 -28
  82. data/lib/browser/qq.rb +1 -1
  83. data/lib/browser/rails.rb +3 -3
  84. data/lib/browser/safari.rb +16 -1
  85. data/lib/browser/samsung_browser.rb +21 -0
  86. data/lib/browser/snapchat.rb +1 -1
  87. data/lib/browser/sougou_browser.rb +24 -0
  88. data/lib/browser/sputnik.rb +2 -5
  89. data/lib/browser/uc_browser.rb +1 -1
  90. data/lib/browser/{generic.rb → unknown.rb} +3 -3
  91. data/lib/browser/version.rb +1 -1
  92. data/lib/browser/weibo.rb +1 -1
  93. data/lib/browser/yandex.rb +1 -1
  94. data/lib/browser.rb +2 -2
  95. data/samsung.yml +138 -0
  96. data/test/browser_test.rb +37 -10
  97. data/test/test_helper.rb +8 -0
  98. data/test/ua.yml +26 -3
  99. data/test/ua_bots.yml +9 -2
  100. data/test/ua_search_engines.yml +1 -0
  101. data/test/unit/accept_language_test.rb +6 -0
  102. data/test/unit/adobe_air_test.rb +1 -1
  103. data/test/unit/alipay_test.rb +6 -0
  104. data/test/unit/blackberry_test.rb +0 -6
  105. data/test/unit/bots_test.rb +26 -39
  106. data/test/unit/chrome_test.rb +8 -3
  107. data/test/unit/console_test.rb +2 -2
  108. data/test/unit/device_test.rb +30 -3
  109. data/test/unit/duck_duck_go_test.rb +37 -0
  110. data/test/unit/edge_test.rb +34 -6
  111. data/test/unit/firefox_test.rb +0 -3
  112. data/test/unit/google_search_app_test.rb +54 -0
  113. data/test/unit/huawei_browser_test.rb +25 -0
  114. data/test/unit/internet_explorer_test.rb +0 -12
  115. data/test/unit/ios_test.rb +0 -5
  116. data/test/unit/kai_os_test.rb +31 -0
  117. data/test/unit/kindle_test.rb +0 -2
  118. data/test/unit/maxthon_test.rb +25 -0
  119. data/test/unit/meta_test.rb +10 -2
  120. data/test/unit/micro_messenger_test.rb +21 -6
  121. data/test/unit/miui_browser_test.rb +25 -0
  122. data/test/unit/opera_test.rb +1 -2
  123. data/test/unit/platform_test.rb +13 -8
  124. data/test/unit/qq_test.rb +12 -0
  125. data/test/unit/safari_test.rb +12 -7
  126. data/test/unit/samsung_browser_test.rb +23 -0
  127. data/test/unit/sougou_browser_test.rb +41 -0
  128. data/test/unit/sputnik_test.rb +1 -0
  129. metadata +46 -16
  130. data/.bundle/config +0 -2
  131. data/.travis.yml +0 -23
  132. data/lib/browser/meta/modern.rb +0 -11
  133. /data/gemfiles/{rails6.gemfile → rails6_0.gemfile} +0 -0
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Browser
2
2
 
3
- [![Travis-CI](https://travis-ci.org/fnando/browser.svg)](https://travis-ci.org/fnando/browser)
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
 
@@ -25,6 +24,7 @@ browser = Browser.new("Some User Agent", accept_language: "en-us")
25
24
  browser.bot?
26
25
  browser.chrome?
27
26
  browser.core_media?
27
+ browser.duck_duck_go?
28
28
  browser.edge? # Newest MS browser
29
29
  browser.electron? # Electron Framework
30
30
  browser.firefox?
@@ -33,8 +33,8 @@ browser.ie?
33
33
  browser.ie?(6) # detect specific IE version
34
34
  browser.ie?([">8", "<10"]) # detect specific IE (IE9).
35
35
  browser.known? # has the browser been successfully detected?
36
+ browser.unknown? # the browser wasn't detected.
36
37
  browser.meta # an array with several attributes
37
- browser.modern? # Webkit, Firefox 17+, IE 9+ and Opera 12+
38
38
  browser.name # readable browser name
39
39
  browser.nokia?
40
40
  browser.opera?
@@ -43,6 +43,7 @@ browser.phantom_js?
43
43
  browser.quicktime?
44
44
  browser.safari?
45
45
  browser.safari_webapp_mode?
46
+ browser.samsung_browser?
46
47
  browser.to_s # the meta info joined by space
47
48
  browser.uc_browser?
48
49
  browser.version # major version number
@@ -50,20 +51,24 @@ browser.webkit?
50
51
  browser.webkit_full_version
51
52
  browser.yandex?
52
53
  browser.wechat?
54
+ browser.qq?
53
55
  browser.weibo?
54
56
  browser.yandex?
55
57
  browser.sputnik?
58
+ browser.sougou_browser?
56
59
 
57
60
  # Get bot info
58
61
  browser.bot.name
59
62
  browser.bot.search_engine?
60
63
  browser.bot?
61
- Browser::Bot.why?(ua) # shows which user agent was the offender
64
+ browser.bot.why? # shows which matcher detected this user agent as a bot.
65
+ Browser::Bot.why?(ua)
62
66
 
63
67
  # Get device info
64
68
  browser.device
65
69
  browser.device.id
66
70
  browser.device.name
71
+ browser.device.unknown?
67
72
  browser.device.blackberry_playbook?
68
73
  browser.device.console?
69
74
  browser.device.ipad?
@@ -84,6 +89,7 @@ browser.device.tv?
84
89
  browser.device.vita?
85
90
  browser.device.wii?
86
91
  browser.device.wiiu?
92
+ browser.device.samsung?
87
93
  browser.device.switch?
88
94
  browser.device.xbox?
89
95
  browser.device.xbox_360?
@@ -109,7 +115,7 @@ browser.platform.ios_app? # detect webview in an iOS app
109
115
  browser.platform.ios_webview? # alias for ios_app?
110
116
  browser.platform.linux?
111
117
  browser.platform.mac?
112
- browser.platform.other?
118
+ browser.platform.unknown?
113
119
  browser.platform.windows10?
114
120
  browser.platform.windows7?
115
121
  browser.platform.windows8?
@@ -124,11 +130,14 @@ browser.platform.windows_wow64?
124
130
  browser.platform.windows_x64?
125
131
  browser.platform.windows_x64_inclusive?
126
132
  browser.platform.windows_xp?
133
+ browser.platform.kai_os?
127
134
  ```
128
135
 
129
136
  ### Aliases
130
137
 
131
- To add aliases like `mobile?` and `tablet?` to the base object (e.g `browser.mobile?`), require the `browser/aliases` file and extend the Browser::Base object like the following:
138
+ To add aliases like `mobile?` and `tablet?` to the base object (e.g
139
+ `browser.mobile?`), require the `browser/aliases` file and extend the
140
+ Browser::Base object like the following:
132
141
 
133
142
  ```ruby
134
143
  require "browser/aliases"
@@ -140,27 +149,35 @@ browser.mobile? #=> false
140
149
 
141
150
  ### What's being detected?
142
151
 
143
- - For a list of platform detections, check [lib/browser/platform.rb](https://github.com/fnando/browser/blob/master/lib/browser/platform.rb)
144
- - For a list of device detections, check [lib/browser/device.rb](https://github.com/fnando/browser/blob/master/lib/browser/device.rb)
145
- - For a list of bot detections, check [bots.yml](https://github.com/fnando/browser/blob/master/bots.yml)
152
+ - For a list of platform detections, check
153
+ [lib/browser/platform.rb](https://github.com/fnando/browser/blob/master/lib/browser/platform.rb)
154
+ - For a list of device detections, check
155
+ [lib/browser/device.rb](https://github.com/fnando/browser/blob/master/lib/browser/device.rb)
156
+ - For a list of bot detections, check
157
+ [bots.yml](https://github.com/fnando/browser/blob/master/bots.yml)
146
158
 
147
- ### What defines a modern browser?
159
+ ### Detecting modern browsers
148
160
 
149
- The current rules that define a modern browser are pretty loose:
150
-
151
- * Webkit
152
- * IE9+
153
- * Microsoft Edge
154
- * Firefox 17+
155
- * Firefox Tablet 14+
156
- * Opera 12+
157
-
158
- You can define your own rules. A rule must be a proc/lambda or any object that implements the method === and accepts the browser object. To redefine all rules, clear the existing rules before adding your own.
161
+ To detect whether a browser can be considered as modern or not, create a method
162
+ that abstracts your versioning constraints. The following example will consider
163
+ any of the following browsers as a modern:
159
164
 
160
165
  ```ruby
161
- # Only Chrome Canary is considered modern.
162
- Browser.modern_rules.clear
163
- Browser.modern_rules << -> b { b.chrome? && b.version.to_i >= 37 }
166
+ # Expects an Browser instance,
167
+ # like in `Browser.new(user_agent, accept_language: language)`.
168
+ def modern_browser?(browser)
169
+ [
170
+ browser.chrome?(">= 65"),
171
+ browser.safari?(">= 10"),
172
+ browser.firefox?(">= 52"),
173
+ browser.ie?(">= 11") && !browser.compatibility_view?,
174
+ browser.edge?(">= 15"),
175
+ browser.opera?(">= 50"),
176
+ browser.facebook?
177
+ && browser.safari_webapp_mode?
178
+ && browser.webkit_full_version.to_i >= 602
179
+ ].any?
180
+ end
164
181
  ```
165
182
 
166
183
  ### Rails integration
@@ -171,7 +188,8 @@ Just add it to the Gemfile.
171
188
  gem "browser"
172
189
  ```
173
190
 
174
- This adds a helper method called `browser`, that inspects your current user agent.
191
+ This adds a helper method called `browser`, that inspects your current user
192
+ agent.
175
193
 
176
194
  ```erb
177
195
  <% if browser.ie?(6) %>
@@ -179,7 +197,8 @@ This adds a helper method called `browser`, that inspects your current user agen
179
197
  <% end %>
180
198
  ```
181
199
 
182
- If you want to use Browser on your Rails app but don't want to taint your controller, use the following line on your Gemfile:
200
+ If you want to use Browser on your Rails app but don't want to taint your
201
+ controller, use the following line on your Gemfile:
183
202
 
184
203
  ```ruby
185
204
  gem "browser", require: "browser/browser"
@@ -187,7 +206,8 @@ gem "browser", require: "browser/browser"
187
206
 
188
207
  ### Accept Language
189
208
 
190
- Parses the accept-language header from an HTTP request and produces an array of language objects sorted by quality.
209
+ Parses the accept-language header from an HTTP request and produces an array of
210
+ language objects sorted by quality.
191
211
 
192
212
  ```ruby
193
213
  browser = Browser.new("Some User Agent", accept_language: "en-us")
@@ -213,16 +233,22 @@ language.name
213
233
  #=> "English/United States"
214
234
  ```
215
235
 
216
- Result is always sorted in quality order from highest -> lowest. As per the HTTP spec:
236
+ Result is always sorted in quality order from highest to lowest. As per the HTTP
237
+ spec:
217
238
 
218
239
  - omitting the quality value implies 1.0.
219
240
  - quality value equal to zero means that is not accepted by the client.
220
241
 
221
242
  ### Internet Explorer
222
243
 
223
- Internet Explorer has a compatibility view mode that allows newer versions (IE8+) to run as an older version. Browser will always return the navigator version, ignoring the compatibility view version, when defined. If you need to get the engine's version, you have to use `Browser#msie_version` and `Browser#msie_full_version`.
244
+ Internet Explorer has a compatibility view mode that allows newer versions
245
+ (IE8+) to run as an older version. Browser will always return the navigator
246
+ version, ignoring the compatibility view version, when defined. If you need to
247
+ get the engine's version, you have to use `Browser#msie_version` and
248
+ `Browser#msie_full_version`.
224
249
 
225
- So, let's say an user activates compatibility view in a IE11 browser. This is what you'll get:
250
+ So, let's say an user activates compatibility view in a IE11 browser. This is
251
+ what you'll get:
226
252
 
227
253
  ```ruby
228
254
  browser.version
@@ -239,16 +265,16 @@ browser.msie_full_version
239
265
 
240
266
  browser.compatibility_view?
241
267
  #=> true
242
-
243
- browser.modern?
244
- #=> false
245
268
  ```
246
269
 
247
- This behavior changed in `v1.0.0`; previously there wasn't a way of getting the real browser version.
270
+ This behavior changed in `v1.0.0`; previously there wasn't a way of getting the
271
+ real browser version.
248
272
 
249
273
  ### Safari
250
274
 
251
- iOS webviews and web apps aren't detected as Safari anymore, so be aware of that if that's your case. You can use a combination of platform and webkit detection to do whatever you want.
275
+ iOS webviews and web apps aren't detected as Safari anymore, so be aware of that
276
+ if that's your case. You can use a combination of platform and webkit detection
277
+ to do whatever you want.
252
278
 
253
279
  ```ruby
254
280
  # iPad's Safari running as web app mode.
@@ -266,62 +292,78 @@ browser.platform.ios?
266
292
 
267
293
  ### Bots
268
294
 
269
- Browser used to detect empty user agents as bots, but this behavior has changed. If you want to bring this detection back, you can activate it through the following call:
295
+ The bot detection is quite aggressive. Anything that matches at least one of the
296
+ following requirements will be considered a bot.
297
+
298
+ - Empty user agent string
299
+ - User agent that matches `/crawl|fetch|search|monitoring|spider|bot/`
300
+ - Any known bot listed under
301
+ [bots.yml](https://github.com/fnando/browser/blob/master/bots.yml)
302
+
303
+ To add custom matchers, you can add a callable object to
304
+ `Browser::Bot.matchers`. The following example matches everything that has a
305
+ `externalhit` substring on it. The bot name will always be `General Bot`.
270
306
 
271
307
  ```ruby
272
- Browser::Bot.detect_empty_ua!
308
+ Browser::Bot.matchers << ->(ua, _browser) { ua.match?(/externalhit/i) }
273
309
  ```
274
310
 
275
- ### Middleware
311
+ To clear all matchers, including the ones that are bundled, use
312
+ `Browser::Bot.matchers.clear`. You can re-add built-in matchers by doing the
313
+ following:
276
314
 
277
- You can use the `Browser::Middleware` to redirect user agents.
315
+ ```ruby
316
+ Browser::Bot.matchers += Browser::Bot.default_matchers
317
+ ```
318
+
319
+ To restore v2's bot detection, remove the following matchers:
278
320
 
279
321
  ```ruby
280
- use Browser::Middleware do
281
- redirect_to "/upgrade" unless browser.modern?
282
- end
322
+ Browser::Bot.matchers.delete(Browser::Bot::KeywordMatcher)
323
+ Browser::Bot.matchers.delete(Browser::Bot::EmptyUserAgentMatcher)
283
324
  ```
284
325
 
285
- If you're using Rails, you can use the route helper methods. Just add something like the following to a initializer file (`config/initializers/browser.rb`).
326
+ ### Middleware
327
+
328
+ You can use the `Browser::Middleware` to redirect user agents.
286
329
 
287
330
  ```ruby
288
- Rails.configuration.middleware.use Browser::Middleware do
289
- redirect_to upgrade_path unless browser.modern?
331
+ use Browser::Middleware do
332
+ redirect_to "/upgrade" if browser.ie?
290
333
  end
291
334
  ```
292
335
 
293
- Notice that you can have multiple conditionals.
336
+ If you're using Rails, you can use the route helper methods. Just add something
337
+ like the following to a initializer file (`config/initializers/browser.rb`).
294
338
 
295
339
  ```ruby
296
340
  Rails.configuration.middleware.use Browser::Middleware do
297
- next if browser.bot.search_engine?
298
- redirect_to upgrade_path(browser: "oldie") if browser.ie? && !browser.modern?
299
- redirect_to upgrade_path(browser: "oldfx") if browser.firefox? && !browser.modern?
341
+ redirect_to upgrade_path if browser.ie?
300
342
  end
301
343
  ```
302
344
 
303
- If you need access to the `Rack::Request` object (e.g. to exclude a path), you can do so with `request`.
345
+ If you need access to the `Rack::Request` object (e.g. to exclude a path), you
346
+ can do so with `request`.
304
347
 
305
348
  ```ruby
306
349
  Rails.configuration.middleware.use Browser::Middleware do
307
- redirect_to upgrade_path unless browser.modern? || request.env["PATH_INFO"] == "/exclude_me"
350
+ redirect_to upgrade_path if browser.ie? && request.env["PATH_INFO"] != "/exclude_me"
308
351
  end
309
352
  ```
310
353
 
311
- ### Migrating to v2
312
-
313
- #### Troubleshooting
314
-
315
- ##### `TypeError: no implicit conversion of Hash into String`
354
+ ### Restrictions
316
355
 
317
- The class constructor now has a different signature. Change the instantiation from `Browser.new(options)` to `Browser.new(ua, options)`, where:
356
+ - User agent has a size limit of 2048 bytes. This can be customized through
357
+ `Browser.user_agent_size_limit=(size)`.
358
+ - Accept-Language has a size limit of 2048 bytes. This can be customized through
359
+ `Browser.accept_language_size_limit=(size)`.
318
360
 
319
- - `ua`: must be a string representing the user agent.
320
- - `options`: must be a hash (for now it only accepts the `accept_language` option).
361
+ If size is not respected, then `Browser::Error` is raised.
321
362
 
322
- ##### `NoMethodError: undefined method 'user_agent'`
323
-
324
- `.ua` can now be used to retrieve the full User Agent string.
363
+ ```ruby
364
+ Browser.user_agent_size_limit = 4096
365
+ Browser.accept_language_size_limit = 4096
366
+ ```
325
367
 
326
368
  ## Development
327
369
 
@@ -339,25 +381,28 @@ Once you've made your great commits (include tests, please):
339
381
  4. Create a pull request
340
382
  5. That's it!
341
383
 
342
- Please respect the indentation rules and code style.
343
- And use 2 spaces, not tabs. And don't touch the version thing.
384
+ Please respect the indentation rules and code style. And use 2 spaces, not tabs.
385
+ And don't touch the version thing.
344
386
 
345
387
  ## Configuring environment
346
388
 
347
- To configure your environment, you must have Ruby and bundler installed. Then run `bundle install` to install all dependencies.
389
+ To configure your environment, you must have Ruby and bundler installed. Then
390
+ run `bundle install` to install all dependencies.
348
391
 
349
392
  To run tests, execute `./bin/rake`.
350
393
 
351
394
  ### Adding new features
352
395
 
353
- Before using your time to code a new feature, open a ticket asking if it makes sense and if it's on this project's scope.
396
+ Before using your time to code a new feature, open a ticket asking if it makes
397
+ sense and if it's on this project's scope.
354
398
 
355
399
  Don't forget to add a new entry to `CHANGELOG.md`.
356
400
 
357
401
  #### Adding a new bot
358
402
 
359
403
  1. Add the user agent to `test/ua_bots.yml`.
360
- 2. Add the readable name to `bots.yml`. The key must be something that matches the user agent, in lowercased text.
404
+ 2. Add the readable name to `bots.yml`. The key must be something that matches
405
+ the user agent, in lowercased text.
361
406
  3. Run tests.
362
407
 
363
408
  Don't forget to add a new entry to `CHANGELOG.md`.
@@ -366,42 +411,43 @@ Don't forget to add a new entry to `CHANGELOG.md`.
366
411
 
367
412
  1. Add the user agent to `test/ua_search_engines.yml`.
368
413
  2. Add the same user agent to `test/ua_bots.yml`.
369
- 3. Add the readable name to `search_engines.yml`. The key must be something that matches the user agent, in lowercased text.
414
+ 3. Add the readable name to `search_engines.yml`. The key must be something that
415
+ matches the user agent, in lowercased text.
370
416
  4. Run tests.
371
417
 
372
418
  Don't forget to add a new entry to `CHANGELOG.md`.
373
419
 
374
420
  #### Wrong browser/platform/device detection
375
421
 
376
- If you know how to fix it, follow the "Writing code" above. Open an issue otherwise; make sure you fill in the issue template with all the required information.
422
+ If you know how to fix it, follow the "Writing code" above. Open an issue
423
+ otherwise; make sure you fill in the issue template with all the required
424
+ information.
377
425
 
378
426
  ## Maintainer
379
427
 
380
- * Nando Vieira - http://nandovieira.com
428
+ - Nando Vieira - http://nandovieira.com
381
429
 
382
430
  ## Contributors
383
431
 
384
- * https://github.com/fnando/browser/contributors
432
+ - https://github.com/fnando/browser/contributors
385
433
 
386
434
  ## License
387
435
 
388
436
  (The MIT License)
389
437
 
390
- Permission is hereby granted, free of charge, to any person obtaining
391
- a copy of this software and associated documentation files (the
392
- 'Software'), to deal in the Software without restriction, including
393
- without limitation the rights to use, copy, modify, merge, publish,
394
- distribute, sublicense, and/or sell copies of the Software, and to
395
- permit persons to whom the Software is furnished to do so, subject to
396
- the following conditions:
397
-
398
- The above copyright notice and this permission notice shall be
399
- included in all copies or substantial portions of the Software.
400
-
401
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
402
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
403
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
404
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
405
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
406
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
407
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
438
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
439
+ this software and associated documentation files (the 'Software'), to deal in
440
+ the Software without restriction, including without limitation the rights to
441
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
442
+ the Software, and to permit persons to whom the Software is furnished to do so,
443
+ subject to the following conditions:
444
+
445
+ The above copyright notice and this permission notice shall be included in all
446
+ copies or substantial portions of the Software.
447
+
448
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
449
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
450
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
451
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
452
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
453
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -16,7 +16,14 @@ end
16
16
  require "rubocop/rake_task"
17
17
  desc "Run rubocop"
18
18
  task :rubocop do
19
- RuboCop::RakeTask.new
19
+ RuboCop::RakeTask.new do |t|
20
+ t.options += %w[
21
+ --display-style-guide
22
+ --display-cop-names
23
+ --extra-details
24
+ --auto-correct
25
+ ]
26
+ end
20
27
  end
21
28
 
22
29
  desc "Run specs against all gemfiles"
data/bot_exceptions.yml CHANGED
@@ -1,3 +1,4 @@
1
+ ---
1
2
  - ruby build
2
3
  - pinterest/android
3
4
  - pinterest/ios