browser 4.2.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -1
  3. data/FUNDING.yml +3 -0
  4. data/README.md +96 -47
  5. data/bots.yml +1 -1
  6. data/lib/browser/base.rb +53 -2
  7. data/lib/browser/browser.rb +22 -2
  8. data/lib/browser/chrome.rb +7 -1
  9. data/lib/browser/device.rb +2 -2
  10. data/lib/browser/device/unknown.rb +1 -1
  11. data/lib/browser/google_search_app.rb +21 -0
  12. data/lib/browser/huawei_browser.rb +21 -0
  13. data/lib/browser/maxthon.rb +21 -0
  14. data/lib/browser/miui_browser.rb +21 -0
  15. data/lib/browser/platform.rb +4 -4
  16. data/lib/browser/platform/ios.rb +1 -1
  17. data/lib/browser/platform/mac.rb +1 -1
  18. data/lib/browser/platform/{other.rb → unknown.rb} +3 -3
  19. data/lib/browser/platform/windows.rb +1 -1
  20. data/lib/browser/safari.rb +9 -1
  21. data/lib/browser/sougou_browser.rb +24 -0
  22. data/lib/browser/{generic.rb → unknown.rb} +3 -3
  23. data/lib/browser/version.rb +1 -1
  24. data/test/browser_test.rb +23 -6
  25. data/test/ua.yml +12 -4
  26. data/test/unit/adobe_air_test.rb +1 -1
  27. data/test/unit/alipay_test.rb +6 -0
  28. data/test/unit/console_test.rb +2 -2
  29. data/test/unit/device_test.rb +2 -2
  30. data/test/unit/duck_duck_go_test.rb +2 -0
  31. data/test/unit/google_search_app_test.rb +54 -0
  32. data/test/unit/huawei_browser_test.rb +25 -0
  33. data/test/unit/maxthon_test.rb +25 -0
  34. data/test/unit/meta_test.rb +9 -0
  35. data/test/unit/miui_browser_test.rb +25 -0
  36. data/test/unit/opera_test.rb +1 -0
  37. data/test/unit/platform_test.rb +6 -6
  38. data/test/unit/qq_test.rb +12 -0
  39. data/test/unit/safari_test.rb +12 -7
  40. data/test/unit/sougou_browser_test.rb +41 -0
  41. metadata +23 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d83e06fd8c03def4d4c2af17fbbd94580594eeb689aa6f4d0fda3d7c94be4c8c
4
- data.tar.gz: 4e8b416860701c61d4a1cf40d2a51316c28431e60d24716d8092746faff88c70
3
+ metadata.gz: 78fd9a10d5ca6461be5395616edcc1456967a595363f027548bf8a9fa0bfdf10
4
+ data.tar.gz: 599be9a3080333b44234ecf4c7ec21572e81e5dc3d04fccfa66a631bc6897494
5
5
  SHA512:
6
- metadata.gz: 86f29ee60621611d8abb82837eac44594b50739e7b39991bd8ce73c7b701f7630e314d3ac22fdf80567d3c2a44985ad4a632204d14805d7015e18b856d357dfc
7
- data.tar.gz: 9bb2826023b3e7d6b7a7ca7c5f0d14b0871bcb39764d3c3c05ecba7784cc4458949533dfc16cc3de7b5f3844faf254d6faf127613ca27547d52ea07040e7ccfa
6
+ metadata.gz: ca6e173a47d2d1489816eb4794c57abc4fc3ff6f1ae63826570c71213e1177813895595240c995704ff50d22666ddae78900ac8eeea77cff93f3f63397bf4d7a
7
+ data.tar.gz: a09fe431f93c0dc9dd24ae2b1679538c4f61586b8334458adb41e6475c50da5850a747e1630b3904be57ccc360bc12333632cf1986978417e690aca4f8747356
@@ -1,6 +1,29 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 5.0.0
4
+
5
+ - Rename `Browser::Platform#other?` to `Browser::Platform#unknown?`.
6
+ - Unknown platforms now return `:unknown_platform` as the id.
7
+ - Unknown devices now return `:unknown_device` as the id.
8
+ - Unknown browsers now return `:unknown_browser` as the id.
9
+ - All the changes above affect how `browser.meta` is composed.
10
+ - Add method `Browser::Base#unknown?`.
11
+ - Fix issue with `Browser::Base#safari?` matching full version.
12
+ - Add Maxthon detection.
13
+ - Add Google Search App detection.
14
+ - Add Huawei Browser detection.
15
+ - Fix Duck Duck Go browser that was being recognized as a bot.
16
+ - Add Miui Browser detection.
17
+ - Add `Browser::Base#qq?`.
18
+ - Fix QQ detection.
19
+ - Fix Alipay detection.
20
+ - Add Sougou Browser detection.
21
+ - User agent has a size limit of 512 bytes. This can be customized through
22
+ `Browser.user_agent_size_limit`.
23
+ - Accept-Language has a size limit of 256 bytes. This can be customized through
24
+ `Browser.accept_language_size_limit`.
25
+
26
+ ## 4.2.0
4
27
 
5
28
  - Fix Chrome Lighthouse detection.
6
29
  - Add Skype to bot list.
@@ -0,0 +1,3 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [fnando]
data/README.md CHANGED
@@ -34,6 +34,7 @@ browser.ie?
34
34
  browser.ie?(6) # detect specific IE version
35
35
  browser.ie?([">8", "<10"]) # detect specific IE (IE9).
36
36
  browser.known? # has the browser been successfully detected?
37
+ browser.unknown? # the browser wasn't detected.
37
38
  browser.meta # an array with several attributes
38
39
  browser.name # readable browser name
39
40
  browser.nokia?
@@ -51,9 +52,11 @@ browser.webkit?
51
52
  browser.webkit_full_version
52
53
  browser.yandex?
53
54
  browser.wechat?
55
+ browser.qq?
54
56
  browser.weibo?
55
57
  browser.yandex?
56
58
  browser.sputnik?
59
+ browser.sougou_browser?
57
60
 
58
61
  # Get bot info
59
62
  browser.bot.name
@@ -66,6 +69,7 @@ Browser::Bot.why?(ua)
66
69
  browser.device
67
70
  browser.device.id
68
71
  browser.device.name
72
+ browser.device.unknown?
69
73
  browser.device.blackberry_playbook?
70
74
  browser.device.console?
71
75
  browser.device.ipad?
@@ -111,7 +115,7 @@ browser.platform.ios_app? # detect webview in an iOS app
111
115
  browser.platform.ios_webview? # alias for ios_app?
112
116
  browser.platform.linux?
113
117
  browser.platform.mac?
114
- browser.platform.other?
118
+ browser.platform.unknown?
115
119
  browser.platform.windows10?
116
120
  browser.platform.windows7?
117
121
  browser.platform.windows8?
@@ -130,7 +134,9 @@ browser.platform.windows_xp?
130
134
 
131
135
  ### Aliases
132
136
 
133
- 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:
137
+ To add aliases like `mobile?` and `tablet?` to the base object (e.g
138
+ `browser.mobile?`), require the `browser/aliases` file and extend the
139
+ Browser::Base object like the following:
134
140
 
135
141
  ```ruby
136
142
  require "browser/aliases"
@@ -142,13 +148,18 @@ browser.mobile? #=> false
142
148
 
143
149
  ### What's being detected?
144
150
 
145
- - For a list of platform detections, check [lib/browser/platform.rb](https://github.com/fnando/browser/blob/master/lib/browser/platform.rb)
146
- - For a list of device detections, check [lib/browser/device.rb](https://github.com/fnando/browser/blob/master/lib/browser/device.rb)
147
- - For a list of bot detections, check [bots.yml](https://github.com/fnando/browser/blob/master/bots.yml)
151
+ - For a list of platform detections, check
152
+ [lib/browser/platform.rb](https://github.com/fnando/browser/blob/master/lib/browser/platform.rb)
153
+ - For a list of device detections, check
154
+ [lib/browser/device.rb](https://github.com/fnando/browser/blob/master/lib/browser/device.rb)
155
+ - For a list of bot detections, check
156
+ [bots.yml](https://github.com/fnando/browser/blob/master/bots.yml)
148
157
 
149
158
  ### Detecting modern browsers
150
159
 
151
- To detect whether a browser can be considered as modern or not, create a method that abstracts your versioning constraints. The following example will consider any of the following browsers as a modern:
160
+ To detect whether a browser can be considered as modern or not, create a method
161
+ that abstracts your versioning constraints. The following example will consider
162
+ any of the following browsers as a modern:
152
163
 
153
164
  ```ruby
154
165
  # Expects an Browser instance,
@@ -176,7 +187,8 @@ Just add it to the Gemfile.
176
187
  gem "browser"
177
188
  ```
178
189
 
179
- This adds a helper method called `browser`, that inspects your current user agent.
190
+ This adds a helper method called `browser`, that inspects your current user
191
+ agent.
180
192
 
181
193
  ```erb
182
194
  <% if browser.ie?(6) %>
@@ -184,7 +196,8 @@ This adds a helper method called `browser`, that inspects your current user agen
184
196
  <% end %>
185
197
  ```
186
198
 
187
- 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:
199
+ If you want to use Browser on your Rails app but don't want to taint your
200
+ controller, use the following line on your Gemfile:
188
201
 
189
202
  ```ruby
190
203
  gem "browser", require: "browser/browser"
@@ -192,7 +205,8 @@ gem "browser", require: "browser/browser"
192
205
 
193
206
  ### Accept Language
194
207
 
195
- Parses the accept-language header from an HTTP request and produces an array of language objects sorted by quality.
208
+ Parses the accept-language header from an HTTP request and produces an array of
209
+ language objects sorted by quality.
196
210
 
197
211
  ```ruby
198
212
  browser = Browser.new("Some User Agent", accept_language: "en-us")
@@ -218,16 +232,22 @@ language.name
218
232
  #=> "English/United States"
219
233
  ```
220
234
 
221
- Result is always sorted in quality order from highest to lowest. As per the HTTP spec:
235
+ Result is always sorted in quality order from highest to lowest. As per the HTTP
236
+ spec:
222
237
 
223
238
  - omitting the quality value implies 1.0.
224
239
  - quality value equal to zero means that is not accepted by the client.
225
240
 
226
241
  ### Internet Explorer
227
242
 
228
- 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`.
243
+ Internet Explorer has a compatibility view mode that allows newer versions
244
+ (IE8+) to run as an older version. Browser will always return the navigator
245
+ version, ignoring the compatibility view version, when defined. If you need to
246
+ get the engine's version, you have to use `Browser#msie_version` and
247
+ `Browser#msie_full_version`.
229
248
 
230
- So, let's say an user activates compatibility view in a IE11 browser. This is what you'll get:
249
+ So, let's say an user activates compatibility view in a IE11 browser. This is
250
+ what you'll get:
231
251
 
232
252
  ```ruby
233
253
  browser.version
@@ -246,11 +266,14 @@ browser.compatibility_view?
246
266
  #=> true
247
267
  ```
248
268
 
249
- This behavior changed in `v1.0.0`; previously there wasn't a way of getting the real browser version.
269
+ This behavior changed in `v1.0.0`; previously there wasn't a way of getting the
270
+ real browser version.
250
271
 
251
272
  ### Safari
252
273
 
253
- 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.
274
+ iOS webviews and web apps aren't detected as Safari anymore, so be aware of that
275
+ if that's your case. You can use a combination of platform and webkit detection
276
+ to do whatever you want.
254
277
 
255
278
  ```ruby
256
279
  # iPad's Safari running as web app mode.
@@ -268,19 +291,25 @@ browser.platform.ios?
268
291
 
269
292
  ### Bots
270
293
 
271
- The bot detection is quite aggressive. Anything that matches at least one of the following requirements will be considered a bot.
294
+ The bot detection is quite aggressive. Anything that matches at least one of the
295
+ following requirements will be considered a bot.
272
296
 
273
297
  - Empty user agent string
274
298
  - User agent that matches `/crawl|fetch|search|monitoring|spider|bot/`
275
- - Any known bot listed under [bots.yml](https://github.com/fnando/browser/blob/master/bots.yml)
299
+ - Any known bot listed under
300
+ [bots.yml](https://github.com/fnando/browser/blob/master/bots.yml)
276
301
 
277
- To add custom matchers, you can add a callable object to `Browser::Bot.matchers`. The following example matches everything that has a `externalhit` substring on it. The bot name will always be `General Bot`.
302
+ To add custom matchers, you can add a callable object to
303
+ `Browser::Bot.matchers`. The following example matches everything that has a
304
+ `externalhit` substring on it. The bot name will always be `General Bot`.
278
305
 
279
306
  ```ruby
280
307
  Browser::Bot.matchers << ->(ua, _browser) { ua =~ /externalhit/i }
281
308
  ```
282
309
 
283
- To clear all matchers, including the ones that are bundled, use `Browser::Bot.matchers.clear`. You can re-add built-in matchers by doing the following:
310
+ To clear all matchers, including the ones that are bundled, use
311
+ `Browser::Bot.matchers.clear`. You can re-add built-in matchers by doing the
312
+ following:
284
313
 
285
314
  ```ruby
286
315
  Browser::Bot.matchers += Browser::Bot.default_matchers
@@ -303,7 +332,8 @@ use Browser::Middleware do
303
332
  end
304
333
  ```
305
334
 
306
- 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`).
335
+ If you're using Rails, you can use the route helper methods. Just add something
336
+ like the following to a initializer file (`config/initializers/browser.rb`).
307
337
 
308
338
  ```ruby
309
339
  Rails.configuration.middleware.use Browser::Middleware do
@@ -311,7 +341,8 @@ Rails.configuration.middleware.use Browser::Middleware do
311
341
  end
312
342
  ```
313
343
 
314
- If you need access to the `Rack::Request` object (e.g. to exclude a path), you can do so with `request`.
344
+ If you need access to the `Rack::Request` object (e.g. to exclude a path), you
345
+ can do so with `request`.
315
346
 
316
347
  ```ruby
317
348
  Rails.configuration.middleware.use Browser::Middleware do
@@ -319,6 +350,20 @@ Rails.configuration.middleware.use Browser::Middleware do
319
350
  end
320
351
  ```
321
352
 
353
+ ### Restrictions
354
+
355
+ - User agent has a size limit of 512 bytes. This can be customized through
356
+ `Browser.user_agent_size_limit=(size)`.
357
+ - Accept-Language has a size limit of 256 bytes. This can be customized through
358
+ `Browser.accept_language_size_limit=(size)`.
359
+
360
+ If size is not respected, then `Browser::Error` is raised.
361
+
362
+ ```ruby
363
+ Browser.user_agent_size_limit = 1024
364
+ Browser.accept_language_size_limit = 150
365
+ ```
366
+
322
367
  ## Development
323
368
 
324
369
  ### Versioning
@@ -335,25 +380,28 @@ Once you've made your great commits (include tests, please):
335
380
  4. Create a pull request
336
381
  5. That's it!
337
382
 
338
- Please respect the indentation rules and code style.
339
- And use 2 spaces, not tabs. And don't touch the version thing.
383
+ Please respect the indentation rules and code style. And use 2 spaces, not tabs.
384
+ And don't touch the version thing.
340
385
 
341
386
  ## Configuring environment
342
387
 
343
- To configure your environment, you must have Ruby and bundler installed. Then run `bundle install` to install all dependencies.
388
+ To configure your environment, you must have Ruby and bundler installed. Then
389
+ run `bundle install` to install all dependencies.
344
390
 
345
391
  To run tests, execute `./bin/rake`.
346
392
 
347
393
  ### Adding new features
348
394
 
349
- 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.
395
+ Before using your time to code a new feature, open a ticket asking if it makes
396
+ sense and if it's on this project's scope.
350
397
 
351
398
  Don't forget to add a new entry to `CHANGELOG.md`.
352
399
 
353
400
  #### Adding a new bot
354
401
 
355
402
  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 the user agent, in lowercased text.
403
+ 2. Add the readable name to `bots.yml`. The key must be something that matches
404
+ the user agent, in lowercased text.
357
405
  3. Run tests.
358
406
 
359
407
  Don't forget to add a new entry to `CHANGELOG.md`.
@@ -362,42 +410,43 @@ Don't forget to add a new entry to `CHANGELOG.md`.
362
410
 
363
411
  1. Add the user agent to `test/ua_search_engines.yml`.
364
412
  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 matches the user agent, in lowercased text.
413
+ 3. Add the readable name to `search_engines.yml`. The key must be something that
414
+ matches the user agent, in lowercased text.
366
415
  4. Run tests.
367
416
 
368
417
  Don't forget to add a new entry to `CHANGELOG.md`.
369
418
 
370
419
  #### Wrong browser/platform/device detection
371
420
 
372
- 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.
421
+ If you know how to fix it, follow the "Writing code" above. Open an issue
422
+ otherwise; make sure you fill in the issue template with all the required
423
+ information.
373
424
 
374
425
  ## Maintainer
375
426
 
376
- * Nando Vieira - http://nandovieira.com
427
+ - Nando Vieira - http://nandovieira.com
377
428
 
378
429
  ## Contributors
379
430
 
380
- * https://github.com/fnando/browser/contributors
431
+ - https://github.com/fnando/browser/contributors
381
432
 
382
433
  ## License
383
434
 
384
435
  (The MIT License)
385
436
 
386
- Permission is hereby granted, free of charge, to any person obtaining
387
- a copy of this software and associated documentation files (the
388
- 'Software'), to deal in the Software without restriction, including
389
- without limitation the rights to use, copy, modify, merge, publish,
390
- distribute, sublicense, and/or sell copies of the Software, and to
391
- permit persons to whom the Software is furnished to do so, subject to
392
- the following conditions:
393
-
394
- The above copyright notice and this permission notice shall be
395
- included in all copies or substantial portions of the Software.
396
-
397
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
398
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
399
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
400
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
401
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
402
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
403
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
437
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
438
+ this software and associated documentation files (the 'Software'), to deal in
439
+ the Software without restriction, including without limitation the rights to
440
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
441
+ the Software, and to permit persons to whom the Software is furnished to do so,
442
+ subject to the following conditions:
443
+
444
+ The above copyright notice and this permission notice shall be included in all
445
+ copies or substantial portions of the Software.
446
+
447
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
448
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
449
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
450
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
451
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
452
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/bots.yml CHANGED
@@ -63,7 +63,7 @@ domain re-animator bot: Domain Re-Animator Bot
63
63
  domainsbot: DomainsBot
64
64
  domaintunocrawler: DomainTuno
65
65
  dotbot: Dot Bot
66
- duckduck: Duck Duck Go
66
+ duckduckbot: Duck Duck Go
67
67
  elb-healthchecker: AWS ELB HealthChecker
68
68
  embedly: Embedly
69
69
  eoaagent: EOAAgent
@@ -10,6 +10,9 @@ module Browser
10
10
  attr_reader :accept_language
11
11
 
12
12
  def initialize(ua, accept_language: nil)
13
+ validate_size(:user_agent, ua.to_s)
14
+ validate_size(:accept_language, accept_language.to_s)
15
+
13
16
  @ua = ua
14
17
  @accept_language = AcceptLanguage.parse(accept_language)
15
18
  end
@@ -122,7 +125,7 @@ module Browser
122
125
 
123
126
  # Detect if browser is Safari.
124
127
  def safari?(expected_version = nil)
125
- Safari.new(ua).match? && detect_version?(version, expected_version)
128
+ Safari.new(ua).match? && detect_version?(full_version, expected_version)
126
129
  end
127
130
 
128
131
  def safari_webapp_mode?
@@ -197,12 +200,49 @@ module Browser
197
200
  ua =~ /SamsungBrowser/ && detect_version?(full_version, expected_version)
198
201
  end
199
202
 
203
+ # Detect if browser is Huawei.
204
+ def huawei_browser?(expected_version = nil)
205
+ HuaweiBrowser.new(ua).match? &&
206
+ detect_version?(full_version, expected_version)
207
+ end
208
+
209
+ # Detect if browser is Xiaomi Miui.
210
+ def miui_browser?(expected_version = nil)
211
+ MiuiBrowser.new(ua).match? &&
212
+ detect_version?(full_version, expected_version)
213
+ end
214
+
215
+ # Detect if browser is Maxthon.
216
+ def maxthon?(expected_version = nil)
217
+ Maxthon.new(ua).match? && detect_version?(full_version, expected_version)
218
+ end
219
+
220
+ # Detect if browser is QQ.
221
+ def qq?(expected_version = nil)
222
+ QQ.new(ua).match? && detect_version?(full_version, expected_version)
223
+ end
224
+
225
+ # Detect if browser is Sougou.
226
+ def sougou_browser?(expected_version = nil)
227
+ SougouBrowser.new(ua).match? &&
228
+ detect_version?(full_version, expected_version)
229
+ end
230
+
231
+ # Detect if browser is Google Search App
232
+ def google_search_app?(expected_version = nil)
233
+ ua =~ /GSA/ && detect_version?(full_version, expected_version)
234
+ end
235
+
200
236
  def webkit_full_version
201
237
  ua[%r{AppleWebKit/([\d.]+)}, 1] || "0.0"
202
238
  end
203
239
 
204
240
  def known?
205
- id != :generic
241
+ !unknown?
242
+ end
243
+
244
+ def unknown?
245
+ id == :unknown_browser
206
246
  end
207
247
 
208
248
  # Detect if browser is a proxy browser.
@@ -214,5 +254,16 @@ module Browser
214
254
  def electron?(expected_version = nil)
215
255
  Electron.new(ua).match? && detect_version?(full_version, expected_version)
216
256
  end
257
+
258
+ private def validate_size(subject, input)
259
+ actual_bytesize = input.bytesize
260
+ size_limit = Browser.public_send("#{subject}_size_limit")
261
+
262
+ return if actual_bytesize < size_limit
263
+
264
+ raise Error,
265
+ "#{subject} cannot be larger than #{size_limit} bytes; " \
266
+ "actual size is #{actual_bytesize}"
267
+ end
217
268
  end
218
269
  end