browser 2.5.2 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +1 -1
- data/.github/workflows/tests.yml +57 -0
- data/.gitignore +1 -0
- data/.prettierignore +1 -0
- data/.rubocop.yml +22 -107
- data/CHANGELOG.md +192 -11
- data/FUNDING.yml +3 -0
- data/Gemfile +2 -0
- data/README.md +139 -89
- data/Rakefile +11 -3
- data/bot_exceptions.yml +2 -0
- data/bots.yml +302 -247
- data/browser.gemspec +12 -7
- data/gemfiles/rails6_0.gemfile +6 -0
- data/gemfiles/rails6_1.gemfile +6 -0
- data/lib/browser/accept_language.rb +12 -9
- data/lib/browser/action_controller.rb +1 -3
- data/lib/browser/aliases.rb +5 -5
- data/lib/browser/alipay.rb +2 -2
- data/lib/browser/base.rb +101 -19
- data/lib/browser/blackberry.rb +3 -3
- data/lib/browser/bot/empty_user_agent_matcher.rb +11 -0
- data/lib/browser/bot/keyword_matcher.rb +11 -0
- data/lib/browser/bot/known_bots_matcher.rb +11 -0
- data/lib/browser/bot.rb +39 -27
- data/lib/browser/browser.rb +65 -54
- data/lib/browser/chrome.rb +18 -5
- data/lib/browser/detect_version.rb +5 -5
- data/lib/browser/device/android.rb +20 -0
- 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/samsung.rb +33 -0
- data/lib/browser/device/surface.rb +2 -4
- data/lib/browser/device/switch.rb +19 -0
- data/lib/browser/device/tv.rb +1 -1
- data/lib/browser/device/unknown.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/device.rb +47 -30
- data/lib/browser/duck_duck_go.rb +22 -0
- data/lib/browser/edge.rb +6 -2
- data/lib/browser/electron.rb +2 -2
- data/lib/browser/facebook.rb +4 -2
- data/lib/browser/firefox.rb +2 -2
- data/lib/browser/google_search_app.rb +21 -0
- data/lib/browser/huawei_browser.rb +21 -0
- data/lib/browser/instagram.rb +21 -0
- data/lib/browser/internet_explorer.rb +9 -10
- data/lib/browser/maxthon.rb +21 -0
- data/lib/browser/meta/base.rb +0 -1
- data/lib/browser/meta/generic_browser.rb +1 -3
- data/lib/browser/meta.rb +12 -13
- data/lib/browser/micro_messenger.rb +2 -2
- data/lib/browser/middleware/context/additions.rb +1 -1
- data/lib/browser/middleware.rb +4 -3
- data/lib/browser/miui_browser.rb +21 -0
- data/lib/browser/nokia.rb +2 -2
- data/lib/browser/opera.rb +2 -2
- data/lib/browser/otter.rb +2 -2
- data/lib/browser/phantom_js.rb +2 -2
- data/lib/browser/platform/adobe_air.rb +2 -2
- data/lib/browser/platform/android.rb +1 -1
- data/lib/browser/platform/base.rb +3 -2
- data/lib/browser/platform/blackberry.rb +2 -2
- data/lib/browser/platform/chrome_os.rb +1 -1
- data/lib/browser/platform/firefox_os.rb +1 -1
- data/lib/browser/platform/ios.rb +17 -4
- data/lib/browser/platform/kai_os.rb +23 -0
- data/lib/browser/platform/linux.rb +1 -1
- data/lib/browser/platform/mac.rb +5 -3
- data/lib/browser/platform/{other.rb → unknown.rb} +3 -3
- data/lib/browser/platform/windows.rb +2 -2
- data/lib/browser/platform/windows_mobile.rb +1 -1
- data/lib/browser/platform/windows_phone.rb +1 -1
- data/lib/browser/platform.rb +37 -28
- data/lib/browser/qq.rb +5 -5
- data/lib/browser/rails.rb +11 -5
- data/lib/browser/safari.rb +19 -4
- data/lib/browser/samsung_browser.rb +21 -0
- data/lib/browser/snapchat.rb +21 -0
- data/lib/browser/sougou_browser.rb +24 -0
- data/lib/browser/sputnik.rb +21 -0
- data/lib/browser/uc_browser.rb +2 -2
- data/lib/browser/{generic.rb → unknown.rb} +6 -8
- data/lib/browser/version.rb +1 -1
- data/lib/browser/weibo.rb +2 -2
- data/lib/browser/yandex.rb +21 -0
- data/lib/browser.rb +2 -2
- data/samsung.yml +138 -0
- data/search_engines.yml +2 -2
- data/test/browser_test.rb +42 -10
- data/test/rails_test.rb +10 -0
- data/test/sample_app.rb +14 -0
- data/test/test_helper.rb +9 -1
- data/test/ua.yml +147 -109
- data/test/ua_bots.yml +98 -45
- data/test/ua_search_engines.yml +7 -6
- data/test/unit/accept_language_test.rb +24 -0
- data/test/unit/adobe_air_test.rb +1 -1
- data/test/unit/alipay_test.rb +6 -0
- data/test/unit/blackberry_test.rb +0 -6
- data/test/unit/bots_test.rb +37 -27
- data/test/unit/chrome_test.rb +8 -19
- data/test/unit/console_test.rb +2 -2
- data/test/unit/device_test.rb +60 -3
- data/test/unit/duck_duck_go_test.rb +37 -0
- data/test/unit/edge_test.rb +49 -5
- data/test/unit/facebook_test.rb +20 -0
- data/test/unit/firefox_test.rb +0 -3
- data/test/unit/google_search_app_test.rb +54 -0
- data/test/unit/huawei_browser_test.rb +25 -0
- data/test/unit/instagram_test.rb +30 -0
- data/test/unit/internet_explorer_test.rb +0 -12
- data/test/unit/ios_test.rb +7 -5
- data/test/unit/kai_os_test.rb +31 -0
- data/test/unit/kindle_test.rb +0 -2
- data/test/unit/maxthon_test.rb +25 -0
- data/test/unit/meta_test.rb +10 -2
- data/test/unit/micro_messenger_test.rb +21 -6
- data/test/unit/miui_browser_test.rb +25 -0
- data/test/unit/opera_test.rb +1 -2
- data/test/unit/platform_test.rb +34 -8
- data/test/unit/qq_test.rb +12 -0
- data/test/unit/safari_test.rb +12 -7
- data/test/unit/samsung_browser_test.rb +23 -0
- data/test/unit/snapchat_test.rb +40 -0
- data/test/unit/sougou_browser_test.rb +41 -0
- data/test/unit/sputnik_test.rb +22 -0
- data/test/unit/yandex_test.rb +37 -0
- metadata +83 -26
- data/.bundle/config +0 -2
- data/.travis.yml +0 -16
- data/bin/rake +0 -17
- data/gemfiles/rails4.gemfile +0 -4
- data/lib/browser/meta/modern.rb +0 -11
data/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# Browser
|
|
2
2
|
|
|
3
|
-
[](https://github.com/fnando/browser)
|
|
4
4
|
[](https://codeclimate.com/github/fnando/browser)
|
|
5
|
-
[](https://codeclimate.com/github/fnando/browser/coverage)
|
|
6
5
|
[](https://rubygems.org/gems/browser)
|
|
7
6
|
[](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,24 +43,32 @@ 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
|
|
49
50
|
browser.webkit?
|
|
50
51
|
browser.webkit_full_version
|
|
51
52
|
browser.yandex?
|
|
52
|
-
browser.wechat?
|
|
53
|
-
browser.
|
|
53
|
+
browser.wechat?
|
|
54
|
+
browser.qq?
|
|
55
|
+
browser.weibo?
|
|
56
|
+
browser.yandex?
|
|
57
|
+
browser.sputnik?
|
|
58
|
+
browser.sougou_browser?
|
|
54
59
|
|
|
55
60
|
# Get bot info
|
|
56
61
|
browser.bot.name
|
|
57
62
|
browser.bot.search_engine?
|
|
58
63
|
browser.bot?
|
|
64
|
+
browser.bot.why? # shows which matcher detected this user agent as a bot.
|
|
65
|
+
Browser::Bot.why?(ua)
|
|
59
66
|
|
|
60
67
|
# Get device info
|
|
61
68
|
browser.device
|
|
62
69
|
browser.device.id
|
|
63
70
|
browser.device.name
|
|
71
|
+
browser.device.unknown?
|
|
64
72
|
browser.device.blackberry_playbook?
|
|
65
73
|
browser.device.console?
|
|
66
74
|
browser.device.ipad?
|
|
@@ -81,6 +89,8 @@ browser.device.tv?
|
|
|
81
89
|
browser.device.vita?
|
|
82
90
|
browser.device.wii?
|
|
83
91
|
browser.device.wiiu?
|
|
92
|
+
browser.device.samsung?
|
|
93
|
+
browser.device.switch?
|
|
84
94
|
browser.device.xbox?
|
|
85
95
|
browser.device.xbox_360?
|
|
86
96
|
browser.device.xbox_one?
|
|
@@ -105,7 +115,7 @@ browser.platform.ios_app? # detect webview in an iOS app
|
|
|
105
115
|
browser.platform.ios_webview? # alias for ios_app?
|
|
106
116
|
browser.platform.linux?
|
|
107
117
|
browser.platform.mac?
|
|
108
|
-
browser.platform.
|
|
118
|
+
browser.platform.unknown?
|
|
109
119
|
browser.platform.windows10?
|
|
110
120
|
browser.platform.windows7?
|
|
111
121
|
browser.platform.windows8?
|
|
@@ -120,11 +130,14 @@ browser.platform.windows_wow64?
|
|
|
120
130
|
browser.platform.windows_x64?
|
|
121
131
|
browser.platform.windows_x64_inclusive?
|
|
122
132
|
browser.platform.windows_xp?
|
|
133
|
+
browser.platform.kai_os?
|
|
123
134
|
```
|
|
124
135
|
|
|
125
136
|
### Aliases
|
|
126
137
|
|
|
127
|
-
To add aliases like `mobile?` and `tablet?` to the base object (e.g
|
|
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:
|
|
128
141
|
|
|
129
142
|
```ruby
|
|
130
143
|
require "browser/aliases"
|
|
@@ -136,27 +149,35 @@ browser.mobile? #=> false
|
|
|
136
149
|
|
|
137
150
|
### What's being detected?
|
|
138
151
|
|
|
139
|
-
- For a list of platform detections, check
|
|
140
|
-
|
|
141
|
-
- For a list of
|
|
142
|
-
|
|
143
|
-
|
|
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)
|
|
144
158
|
|
|
145
|
-
|
|
159
|
+
### Detecting modern browsers
|
|
146
160
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
* Firefox 17+
|
|
151
|
-
* Firefox Tablet 14+
|
|
152
|
-
* Opera 12+
|
|
153
|
-
|
|
154
|
-
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:
|
|
155
164
|
|
|
156
165
|
```ruby
|
|
157
|
-
#
|
|
158
|
-
Browser.
|
|
159
|
-
|
|
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
|
|
160
181
|
```
|
|
161
182
|
|
|
162
183
|
### Rails integration
|
|
@@ -167,7 +188,8 @@ Just add it to the Gemfile.
|
|
|
167
188
|
gem "browser"
|
|
168
189
|
```
|
|
169
190
|
|
|
170
|
-
This adds a helper method called `browser`, that inspects your current user
|
|
191
|
+
This adds a helper method called `browser`, that inspects your current user
|
|
192
|
+
agent.
|
|
171
193
|
|
|
172
194
|
```erb
|
|
173
195
|
<% if browser.ie?(6) %>
|
|
@@ -175,7 +197,8 @@ This adds a helper method called `browser`, that inspects your current user agen
|
|
|
175
197
|
<% end %>
|
|
176
198
|
```
|
|
177
199
|
|
|
178
|
-
If you want to use Browser on your Rails app but don't want to taint your
|
|
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:
|
|
179
202
|
|
|
180
203
|
```ruby
|
|
181
204
|
gem "browser", require: "browser/browser"
|
|
@@ -183,7 +206,8 @@ gem "browser", require: "browser/browser"
|
|
|
183
206
|
|
|
184
207
|
### Accept Language
|
|
185
208
|
|
|
186
|
-
Parses the accept-language header from an HTTP request and produces an array of
|
|
209
|
+
Parses the accept-language header from an HTTP request and produces an array of
|
|
210
|
+
language objects sorted by quality.
|
|
187
211
|
|
|
188
212
|
```ruby
|
|
189
213
|
browser = Browser.new("Some User Agent", accept_language: "en-us")
|
|
@@ -209,16 +233,22 @@ language.name
|
|
|
209
233
|
#=> "English/United States"
|
|
210
234
|
```
|
|
211
235
|
|
|
212
|
-
Result is always sorted in quality order from highest
|
|
236
|
+
Result is always sorted in quality order from highest to lowest. As per the HTTP
|
|
237
|
+
spec:
|
|
213
238
|
|
|
214
239
|
- omitting the quality value implies 1.0.
|
|
215
240
|
- quality value equal to zero means that is not accepted by the client.
|
|
216
241
|
|
|
217
242
|
### Internet Explorer
|
|
218
243
|
|
|
219
|
-
Internet Explorer has a compatibility view mode that allows newer versions
|
|
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`.
|
|
220
249
|
|
|
221
|
-
So, let's say an user activates compatibility view in a IE11 browser. This is
|
|
250
|
+
So, let's say an user activates compatibility view in a IE11 browser. This is
|
|
251
|
+
what you'll get:
|
|
222
252
|
|
|
223
253
|
```ruby
|
|
224
254
|
browser.version
|
|
@@ -235,16 +265,16 @@ browser.msie_full_version
|
|
|
235
265
|
|
|
236
266
|
browser.compatibility_view?
|
|
237
267
|
#=> true
|
|
238
|
-
|
|
239
|
-
browser.modern?
|
|
240
|
-
#=> false
|
|
241
268
|
```
|
|
242
269
|
|
|
243
|
-
This behavior changed in `v1.0.0`; previously there wasn't a way of getting the
|
|
270
|
+
This behavior changed in `v1.0.0`; previously there wasn't a way of getting the
|
|
271
|
+
real browser version.
|
|
244
272
|
|
|
245
273
|
### Safari
|
|
246
274
|
|
|
247
|
-
iOS webviews and web apps aren't
|
|
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.
|
|
248
278
|
|
|
249
279
|
```ruby
|
|
250
280
|
# iPad's Safari running as web app mode.
|
|
@@ -262,62 +292,78 @@ browser.platform.ios?
|
|
|
262
292
|
|
|
263
293
|
### Bots
|
|
264
294
|
|
|
265
|
-
|
|
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`.
|
|
266
306
|
|
|
267
307
|
```ruby
|
|
268
|
-
Browser::Bot.
|
|
308
|
+
Browser::Bot.matchers << ->(ua, _browser) { ua.match?(/externalhit/i) }
|
|
269
309
|
```
|
|
270
310
|
|
|
271
|
-
|
|
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:
|
|
272
314
|
|
|
273
|
-
|
|
315
|
+
```ruby
|
|
316
|
+
Browser::Bot.matchers += Browser::Bot.default_matchers
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
To restore v2's bot detection, remove the following matchers:
|
|
274
320
|
|
|
275
321
|
```ruby
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
end
|
|
322
|
+
Browser::Bot.matchers.delete(Browser::Bot::KeywordMatcher)
|
|
323
|
+
Browser::Bot.matchers.delete(Browser::Bot::EmptyUserAgentMatcher)
|
|
279
324
|
```
|
|
280
325
|
|
|
281
|
-
|
|
326
|
+
### Middleware
|
|
327
|
+
|
|
328
|
+
You can use the `Browser::Middleware` to redirect user agents.
|
|
282
329
|
|
|
283
330
|
```ruby
|
|
284
|
-
|
|
285
|
-
redirect_to
|
|
331
|
+
use Browser::Middleware do
|
|
332
|
+
redirect_to "/upgrade" if browser.ie?
|
|
286
333
|
end
|
|
287
334
|
```
|
|
288
335
|
|
|
289
|
-
|
|
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`).
|
|
290
338
|
|
|
291
339
|
```ruby
|
|
292
340
|
Rails.configuration.middleware.use Browser::Middleware do
|
|
293
|
-
|
|
294
|
-
redirect_to upgrade_path(browser: "oldie") if browser.ie? && !browser.modern?
|
|
295
|
-
redirect_to upgrade_path(browser: "oldfx") if browser.firefox? && !browser.modern?
|
|
341
|
+
redirect_to upgrade_path if browser.ie?
|
|
296
342
|
end
|
|
297
343
|
```
|
|
298
344
|
|
|
299
|
-
If you need access to the `Rack::Request` object (e.g. to exclude a path), you
|
|
345
|
+
If you need access to the `Rack::Request` object (e.g. to exclude a path), you
|
|
346
|
+
can do so with `request`.
|
|
300
347
|
|
|
301
348
|
```ruby
|
|
302
349
|
Rails.configuration.middleware.use Browser::Middleware do
|
|
303
|
-
redirect_to upgrade_path
|
|
350
|
+
redirect_to upgrade_path if browser.ie? && request.env["PATH_INFO"] != "/exclude_me"
|
|
304
351
|
end
|
|
305
352
|
```
|
|
306
353
|
|
|
307
|
-
###
|
|
308
|
-
|
|
309
|
-
#### Troubleshooting
|
|
310
|
-
|
|
311
|
-
##### `TypeError: no implicit conversion of Hash into String`
|
|
354
|
+
### Restrictions
|
|
312
355
|
|
|
313
|
-
|
|
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)`.
|
|
314
360
|
|
|
315
|
-
|
|
316
|
-
- `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.
|
|
317
362
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
363
|
+
```ruby
|
|
364
|
+
Browser.user_agent_size_limit = 4096
|
|
365
|
+
Browser.accept_language_size_limit = 4096
|
|
366
|
+
```
|
|
321
367
|
|
|
322
368
|
## Development
|
|
323
369
|
|
|
@@ -335,25 +381,28 @@ Once you've made your great commits (include tests, please):
|
|
|
335
381
|
4. Create a pull request
|
|
336
382
|
5. That's it!
|
|
337
383
|
|
|
338
|
-
Please respect the indentation rules and code style.
|
|
339
|
-
And
|
|
384
|
+
Please respect the indentation rules and code style. And use 2 spaces, not tabs.
|
|
385
|
+
And don't touch the version thing.
|
|
340
386
|
|
|
341
387
|
## Configuring environment
|
|
342
388
|
|
|
343
|
-
To configure your environment, you must have Ruby and bundler installed. Then
|
|
389
|
+
To configure your environment, you must have Ruby and bundler installed. Then
|
|
390
|
+
run `bundle install` to install all dependencies.
|
|
344
391
|
|
|
345
392
|
To run tests, execute `./bin/rake`.
|
|
346
393
|
|
|
347
394
|
### Adding new features
|
|
348
395
|
|
|
349
|
-
Before using your time to code a new feature, open a ticket asking if it makes
|
|
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.
|
|
350
398
|
|
|
351
399
|
Don't forget to add a new entry to `CHANGELOG.md`.
|
|
352
400
|
|
|
353
401
|
#### Adding a new bot
|
|
354
402
|
|
|
355
403
|
1. Add the user agent to `test/ua_bots.yml`.
|
|
356
|
-
2. Add the readable name to `bots.yml`. The key must be something that matches
|
|
404
|
+
2. Add the readable name to `bots.yml`. The key must be something that matches
|
|
405
|
+
the user agent, in lowercased text.
|
|
357
406
|
3. Run tests.
|
|
358
407
|
|
|
359
408
|
Don't forget to add a new entry to `CHANGELOG.md`.
|
|
@@ -362,42 +411,43 @@ Don't forget to add a new entry to `CHANGELOG.md`.
|
|
|
362
411
|
|
|
363
412
|
1. Add the user agent to `test/ua_search_engines.yml`.
|
|
364
413
|
2. Add the same user agent to `test/ua_bots.yml`.
|
|
365
|
-
3. Add the readable name to `search_engines.yml`. The key must be something that
|
|
414
|
+
3. Add the readable name to `search_engines.yml`. The key must be something that
|
|
415
|
+
matches the user agent, in lowercased text.
|
|
366
416
|
4. Run tests.
|
|
367
417
|
|
|
368
418
|
Don't forget to add a new entry to `CHANGELOG.md`.
|
|
369
419
|
|
|
370
420
|
#### Wrong browser/platform/device detection
|
|
371
421
|
|
|
372
|
-
If you know how to fix it, follow the "Writing code" above. Open an issue
|
|
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.
|
|
373
425
|
|
|
374
426
|
## Maintainer
|
|
375
427
|
|
|
376
|
-
|
|
428
|
+
- Nando Vieira - http://nandovieira.com
|
|
377
429
|
|
|
378
430
|
## Contributors
|
|
379
431
|
|
|
380
|
-
|
|
432
|
+
- https://github.com/fnando/browser/contributors
|
|
381
433
|
|
|
382
434
|
## License
|
|
383
435
|
|
|
384
436
|
(The MIT License)
|
|
385
437
|
|
|
386
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
IN
|
|
401
|
-
|
|
402
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
403
|
-
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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "bundler"
|
|
2
4
|
require "bundler/setup"
|
|
3
5
|
Bundler::GemHelper.install_tasks
|
|
@@ -9,13 +11,19 @@ Rake::TestTask.new(:test) do |t|
|
|
|
9
11
|
t.test_files = FileList["test/**/*_test.rb"]
|
|
10
12
|
t.verbose = true
|
|
11
13
|
t.warning = false
|
|
12
|
-
t.ruby_opts = %w[-rubygems]
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
require "rubocop/rake_task"
|
|
16
17
|
desc "Run rubocop"
|
|
17
18
|
task :rubocop do
|
|
18
|
-
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
|
|
19
27
|
end
|
|
20
28
|
|
|
21
29
|
desc "Run specs against all gemfiles"
|
|
@@ -29,4 +37,4 @@ task "test:all" do
|
|
|
29
37
|
end
|
|
30
38
|
end
|
|
31
39
|
|
|
32
|
-
task default: [
|
|
40
|
+
task default: %i[test rubocop]
|