device_detector 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +49 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +1 -1
  5. data/CHANGELOG.md +5 -0
  6. data/README.md +4 -4
  7. data/Rakefile +6 -17
  8. data/device_detector.gemspec +1 -0
  9. data/lib/device_detector.rb +17 -28
  10. data/lib/device_detector/bot.rb +2 -2
  11. data/lib/device_detector/client.rb +3 -2
  12. data/lib/device_detector/device.rb +44 -21
  13. data/lib/device_detector/memory_cache.rb +5 -5
  14. data/lib/device_detector/metadata_extractor.rb +7 -8
  15. data/lib/device_detector/model_extractor.rb +3 -3
  16. data/lib/device_detector/name_extractor.rb +2 -2
  17. data/lib/device_detector/os.rb +121 -114
  18. data/lib/device_detector/parser.rb +22 -9
  19. data/lib/device_detector/version.rb +1 -1
  20. data/lib/device_detector/version_extractor.rb +2 -3
  21. data/regexes/bots.yml +228 -12
  22. data/regexes/client/browser_engine.yml +4 -1
  23. data/regexes/client/browsers.yml +358 -34
  24. data/regexes/client/feed_readers.yml +1 -1
  25. data/regexes/client/libraries.yml +16 -1
  26. data/regexes/client/mediaplayers.yml +14 -2
  27. data/regexes/client/mobile_apps.yml +26 -2
  28. data/regexes/client/pim.yml +1 -1
  29. data/regexes/device/cameras.yml +1 -1
  30. data/regexes/device/car_browsers.yml +7 -3
  31. data/regexes/device/consoles.yml +3 -3
  32. data/regexes/device/mobiles.yml +2468 -823
  33. data/regexes/device/portable_media_player.yml +2 -2
  34. data/regexes/device/televisions.yml +1 -1
  35. data/regexes/oss.yml +20 -5
  36. data/regexes/vendorfragments.yml +5 -1
  37. data/spec/device_detector/device_spec.rb +4 -24
  38. data/spec/fixtures/client/browser.yml +632 -2
  39. data/spec/fixtures/client/library.yml +18 -0
  40. data/spec/fixtures/client/mobile_app.yml +24 -0
  41. data/spec/fixtures/detector/bots.yml +533 -67
  42. data/spec/fixtures/detector/camera.yml +20 -0
  43. data/spec/fixtures/detector/car_browser.yml +60 -0
  44. data/spec/fixtures/detector/console.yml +40 -0
  45. data/spec/fixtures/detector/desktop.yml +140 -40
  46. data/spec/fixtures/detector/mediaplayer.yml +43 -0
  47. data/spec/fixtures/detector/mobile_apps.yml +40 -2
  48. data/spec/fixtures/detector/phablet.yml +383 -1
  49. data/spec/fixtures/detector/smart_speaker.yml +55 -0
  50. data/spec/fixtures/detector/smartphone-1.yml +3669 -3695
  51. data/spec/fixtures/detector/smartphone-10.yml +4147 -4094
  52. data/spec/fixtures/detector/smartphone-11.yml +4475 -4473
  53. data/spec/fixtures/detector/smartphone-12.yml +5502 -4251
  54. data/spec/fixtures/detector/smartphone-13.yml +9920 -0
  55. data/spec/fixtures/detector/smartphone-14.yml +2662 -0
  56. data/spec/fixtures/detector/smartphone-2.yml +3738 -3713
  57. data/spec/fixtures/detector/smartphone-3.yml +3970 -3912
  58. data/spec/fixtures/detector/smartphone-4.yml +4518 -4506
  59. data/spec/fixtures/detector/smartphone-5.yml +3645 -3664
  60. data/spec/fixtures/detector/smartphone-6.yml +3868 -3829
  61. data/spec/fixtures/detector/smartphone-7.yml +3992 -3985
  62. data/spec/fixtures/detector/smartphone-8.yml +4510 -4475
  63. data/spec/fixtures/detector/smartphone-9.yml +4226 -4255
  64. data/spec/fixtures/detector/smartphone.yml +3197 -3197
  65. data/spec/fixtures/detector/tablet-1.yml +3940 -3968
  66. data/spec/fixtures/detector/tablet-2.yml +3773 -3764
  67. data/spec/fixtures/detector/tablet-3.yml +5243 -3071
  68. data/spec/fixtures/detector/tablet-4.yml +4528 -0
  69. data/spec/fixtures/detector/tablet.yml +3145 -3125
  70. data/spec/fixtures/detector/tv.yml +1695 -95
  71. data/spec/fixtures/detector/unknown.yml +13 -60
  72. data/spec/fixtures/detector/wearable.yml +61 -0
  73. data/spec/fixtures/device/car_browser.yml +6 -0
  74. data/spec/fixtures/parser/oss.yml +36 -1
  75. data/spec/fixtures/parser/vendorfragments.yml +6 -0
  76. metadata +32 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d05eccb050bff6aa4688bd53d886e93df0925d5e
4
- data.tar.gz: a197886f998a925a7cdc9f0b238556cfec2cff96
2
+ SHA256:
3
+ metadata.gz: 5b73863bdb837708cf4e4e202747535e275823acbf14abf506174717980763bb
4
+ data.tar.gz: dad905ef5c510e73f3c5450d65ee231eff9c2a6815af171124081eaa380c26a4
5
5
  SHA512:
6
- metadata.gz: 5fbece6531362b1125f35d8fb578e0e559bb003026cc7f2e45a72314fc416ef0cc3bc452baadd95f0ec2129c52f4211d1660a8c0268ecedb36b8c112a26be214
7
- data.tar.gz: 5322208277526dbbfceb78924d6c15da242a7a5c958e89b6587bfc6c5b2904f5ae2e1b378c9e23022e743e4c5111c8654204dad409c9ec1fc59344bb853d97f5
6
+ metadata.gz: e738d06e2ce209367d4783d84480078ea0c44bac8e6cfc563a01af4257d85de109fc1f4be66d67feb0d64800905eb59c4604e9d5bb6f7d3d4645ddafa849d3e0
7
+ data.tar.gz: de39db15cb9ab997ee2c362cda93cd29876d06ac913f6aba283d90c164599d43d7c53ea39c003964fe1e3f1cd83440d95d22c72202b2a7396912689c1c233e87
@@ -0,0 +1,49 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+ Exclude:
4
+ - 'db/schema.rb'
5
+ - 'Gemfile'
6
+ - 'bin/'
7
+ Style/Documentation:
8
+ Enabled: false
9
+ Style/EmptyMethod:
10
+ EnforcedStyle: expanded
11
+ Style/HashEachMethods:
12
+ Enabled: true
13
+ Style/HashTransformKeys:
14
+ Enabled: true
15
+ Style/HashTransformValues:
16
+ Enabled: true
17
+ Style/RedundantRegexpCharacterClass:
18
+ Enabled: true
19
+ Style/RedundantRegexpEscape:
20
+ Enabled: true
21
+ Style/StructInheritance:
22
+ Enabled: false
23
+ Style/ExponentialNotation:
24
+ Enabled: true
25
+ Style/SlicingWithRange:
26
+ Enabled: true
27
+ Layout/EmptyLinesAroundAttributeAccessor:
28
+ Enabled: true
29
+ Layout/LineLength:
30
+ Max: 100
31
+ Layout/SpaceAroundMethodCallOperator:
32
+ Enabled: true
33
+ Metrics/MethodLength:
34
+ Max: 15
35
+ Metrics/BlockLength:
36
+ Exclude:
37
+ - 'Rakefile'
38
+ - '**/*.rake'
39
+ - 'spec/**/*.rb'
40
+ Lint/DeprecatedOpenSSLConstant:
41
+ Enabled: true
42
+ Lint/MixedRegexpCaptureTypes:
43
+ Enabled: true
44
+ Lint/RedundantCopDisableDirective:
45
+ Enabled: false
46
+ Lint/RaiseException:
47
+ Enabled: true
48
+ Lint/StructNewOverride:
49
+ Enabled: true
@@ -0,0 +1 @@
1
+ 2.6.6
@@ -8,7 +8,7 @@ before_install:
8
8
  - gem update --system
9
9
  - gem --version
10
10
  - gem update bundler
11
- - bundler --version
11
+ - bundle --version
12
12
  cache: bundler
13
13
  script:
14
14
  bundle exec rake test
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## [1.0.4]
4
+ - Updated detection rules from upstream on 2020-06-23
5
+ - [Issue #69](https://github.com/podigee/device_detector/issues/69): Performance: RegExp definitions are only loaded once.
6
+ - [Issue #74](https://github.com/podigee/device_detector/issues/74): Development: Added Rubocop
7
+
3
8
  ## [1.0.3]
4
9
  - Updated detection rules from upstream on 2019-12-09
5
10
 
data/README.md CHANGED
@@ -134,19 +134,19 @@ useragent 4.450000 0.000000 4.450000 ( 4.452741)
134
134
 
135
135
  ## Detectable clients, bots and devices
136
136
 
137
- Updated on 2019-12-09
137
+ Updated on 2020-06-23
138
138
 
139
139
  ### Bots
140
140
 
141
- 360Spider, Aboundexbot, Acoon, AddThis.com, ADMantX, aHrefs Bot, Alexa Crawler, Alexa Site Audit, Amazon Route53 Health Check, Amorank Spider, Analytics SEO Crawler, ApacheBench, Applebot, Arachni, archive.org bot, Ask Jeeves, Backlink-Check.de, BacklinkCrawler, Baidu Spider, BazQux Reader, BingBot, BitlyBot, Blekkobot, BLEXBot Crawler, Bloglovin, Blogtrottr, BoardReader Blog Indexer, Bountii Bot, Browsershots, BUbiNG, Butterfly Robot, CareerBot, Castro 2, Catchpoint, ccBot crawler, Charlotte, Cliqzbot, CloudFlare Always Online, CloudFlare AMP Fetcher, Collectd, CommaFeed, CSS Certificate Spider, Cốc Cốc Bot, Datadog Agent, Datanyze, Dataprovider, Daum, Dazoobot, Discobot, Domain Re-Animator Bot, DotBot, DuckDuckGo Bot, Easou Spider, eCairn-Grabber, EMail Exractor, EmailWolf, evc-batch, ExaBot, ExactSeek Crawler, Ezooms, Facebook External Hit, Feed Wrangler, Feedbin, FeedBurner, Feedly, Feedspot, Fever, Findxbot, Flipboard, FreshRSS, Generic Bot, Genieo Web filter, Gigablast, Gigabot, Gluten Free Crawler, Gmail Image Proxy, Goo, Google Favicon, Google PageSpeed Insights, Google Partner Monitoring, Google Search Console, Google Structured Data Testing Tool, Googlebot, Grapeshot, Heritrix, Heureka Feed, HTTPMon, HubPages, HubSpot, ICC-Crawler, ichiro, IIS Site Analysis, Inktomi Slurp, inoreader, IP-Guide Crawler, IPS Agent, Kouio, Larbin web crawler, Let's Encrypt Validation, Lighthouse, Linkdex Bot, LinkedIn Bot, LTX71, Lycos, Magpie-Crawler, MagpieRSS, Mail.Ru Bot, masscan, Mastodon Bot, Meanpath Bot, MetaInspector, MetaJobBot, Mixrank Bot, MJ12 Bot, Mnogosearch, MojeekBot, Monitor.Us, Munin, Nagios check_http, NalezenCzBot, nbertaupete95, Netcraft Survey Bot, netEstate, NetLyzer FastProbe, NetResearchServer, Netvibes, NewsBlur, NewsGator, NLCrawler, Nmap, Nutch-based Bot, Nuzzel, Octopus, Omgili bot, Openindex Spider, OpenLinkProfiler, OpenWebSpider, Orange Bot, Outbrain, PagePeeker, PaperLiBot, Phantomas, PHP Server Monitor, Picsearch bot, Pingdom Bot, Pinterest, PocketParser, Pompos, PritTorrent, QuerySeekerSpider, Quora Link Preview, Qwantify, Rainmeter, RamblerMail Image Proxy, Reddit Bot, Riddler, Rogerbot, ROI Hunter, RSSRadio Bot, SafeDNSBot, Scooter, ScoutJet, Scrapy, Screaming Frog SEO Spider, ScreenerBot, Semrush Bot, Sensika Bot, Sentry Bot, SEOENGBot, SEOkicks-Robot, Seoscanners.net, Server Density, Seznam Bot, Seznam Email Proxy, Seznam Zbozi.cz, ShopAlike, Shopify Partner, ShopWiki, SilverReader, SimplePie, SISTRIX Crawler, SISTRIX Optimizer, Site24x7 Website Monitoring, SiteSucker, Sixy.ch, Skype URI Preview, Slackbot, Snapchat Proxy, Sogou Spider, Soso Spider, Sparkler, Speedy, Spinn3r, Spotify, Sputnik Bot, sqlmap, SSL Labs, StatusCake, Superfeedr Bot, Survey Bot, Tarmot Gezgin, TelegramBot, The Knowledge AI, theoldreader, TinEye Crawler, Tiny Tiny RSS, TLSProbe, Trendiction Bot, TurnitinBot, TweetedTimes Bot, Tweetmeme Bot, Twingly Recon, Twitterbot, UkrNet Mail Proxy, UniversalFeedParser, Uptime Robot, Uptimebot, URLAppendBot, Vagabondo, Visual Site Mapper Crawler, VK Share Button, W3C CSS Validator, W3C I18N Checker, W3C Link Checker, W3C Markup Validation Service, W3C MobileOK Checker, W3C Unified Validator, Wappalyzer, WebbCrawler, WebPageTest, WebSitePulse, WebThumbnail, WeSEE:Search, Willow Internet Crawler, WordPress, Wotbox, YaCy, Yahoo Gemini, Yahoo! Cache System, Yahoo! Link Preview, Yahoo! Slurp, Yandex Bot, Yeti/Naverbot, Yottaa Site Monitor, Youdao Bot, Yourls, Yunyun Bot, Zao, zgrab, Zookabot, ZumBot
141
+ 360Spider, Aboundexbot, Acoon, AddThis.com, ADMantX, aHrefs Bot, Alexa Crawler, Alexa Site Audit, Amazon Route53 Health Check, Amorank Spider, Analytics SEO Crawler, ApacheBench, Applebot, Arachni, archive.org bot, Ask Jeeves, AspiegelBot, Awario, Backlink-Check.de, BacklinkCrawler, Baidu Spider, BazQux Reader, BingBot, BitlyBot, Blekkobot, BLEXBot Crawler, Bloglovin, Blogtrottr, BoardReader, BoardReader Blog Indexer, Bountii Bot, BrandVerity, Browsershots, BUbiNG, Buck, Butterfly Robot, Bytespider, CareerBot, Castro 2, Catchpoint, CATExplorador, ccBot crawler, Charlotte, Cliqzbot, CloudFlare Always Online, CloudFlare AMP Fetcher, Collectd, CommaFeed, CSS Certificate Spider, Cốc Cốc Bot, Datadog Agent, Datanyze, Dataprovider, Daum, Dazoobot, Discobot, Domain Re-Animator Bot, DotBot, DuckDuckGo Bot, Easou Spider, eCairn-Grabber, EMail Exractor, EmailWolf, Embedly, evc-batch, ExaBot, ExactSeek Crawler, eZ Publish Link Validator, Ezooms, Facebook External Hit, Feed Wrangler, Feedbin, FeedBurner, Feedly, Feedspot, Fever, Findxbot, Flipboard, FreshRSS, Generic Bot, Genieo Web filter, Gigablast, Gigabot, Gluten Free Crawler, Gmail Image Proxy, Goo, Google Cloud Scheduler, Google Favicon, Google PageSpeed Insights, Google Partner Monitoring, Google Search Console, Google Stackdriver Monitoring, Google Structured Data Testing Tool, Googlebot, Grapeshot, GTmetrix, Heritrix, Heureka Feed, HTTPMon, HubPages, HubSpot, ICC-Crawler, ichiro, IDG/IT, IIS Site Analysis, Inktomi Slurp, inoreader, IP-Guide Crawler, IPS Agent, Kaspersky, Kouio, Larbin web crawler, LCC, Let's Encrypt Validation, Lighthouse, Linkdex Bot, LinkedIn Bot, LTX71, Lycos, Magpie-Crawler, MagpieRSS, Mail.Ru Bot, masscan, Mastodon Bot, Meanpath Bot, MetaInspector, MetaJobBot, Mixrank Bot, MJ12 Bot, Mnogosearch, MojeekBot, Monitor.Us, Munin, Nagios check_http, NalezenCzBot, nbertaupete95, Netcraft Survey Bot, netEstate, NetLyzer FastProbe, NetResearchServer, Netvibes, NewsBlur, NewsGator, NLCrawler, Nmap, Nutch-based Bot, Nuzzel, oBot, Octopus, Omgili bot, Openindex Spider, OpenLinkProfiler, OpenWebSpider, Orange Bot, Outbrain, PagePeeker, PaperLiBot, Phantomas, PHP Server Monitor, Picsearch bot, Pingdom Bot, Pinterest, PocketParser, Pompos, PritTorrent, QuerySeekerSpider, Quora Link Preview, Qwantify, Rainmeter, RamblerMail Image Proxy, Reddit Bot, Riddler, Rogerbot, ROI Hunter, RSSRadio Bot, SafeDNSBot, Scooter, ScoutJet, Scrapy, Screaming Frog SEO Spider, ScreenerBot, Semrush Bot, Sensika Bot, Sentry Bot, SEOENGBot, SEOkicks-Robot, Seoscanners.net, Server Density, Seznam Bot, Seznam Email Proxy, Seznam Zbozi.cz, ShopAlike, Shopify Partner, ShopWiki, SilverReader, SimplePie, SISTRIX Crawler, SISTRIX Optimizer, Site24x7 Website Monitoring, Siteimprove, SiteSucker, Sixy.ch, Skype URI Preview, Slackbot, SMTBot, Snapchat Proxy, Sogou Spider, Soso Spider, Sparkler, Speedy, Spinn3r, Spotify, Sputnik Bot, sqlmap, SSL Labs, Startpagina Linkchecker, StatusCake, Superfeedr Bot, Survey Bot, Tarmot Gezgin, TelegramBot, The Knowledge AI, theoldreader, TinEye Crawler, Tiny Tiny RSS, TLSProbe, TraceMyFile, Trendiction Bot, TurnitinBot, TweetedTimes Bot, Tweetmeme Bot, Twingly Recon, Twitterbot, UkrNet Mail Proxy, UniversalFeedParser, Uptime Robot, Uptimebot, URLAppendBot, Vagabondo, Visual Site Mapper Crawler, VK Share Button, W3C CSS Validator, W3C I18N Checker, W3C Link Checker, W3C Markup Validation Service, W3C MobileOK Checker, W3C Unified Validator, Wappalyzer, WebbCrawler, Weborama, WebPageTest, WebSitePulse, WebThumbnail, WeSEE:Search, WikiDo, Willow Internet Crawler, WooRank, WordPress, Wotbox, XenForo, YaCy, Yahoo Gemini, Yahoo! Cache System, Yahoo! Japan BRW, Yahoo! Link Preview, Yahoo! Slurp, Yandex Bot, Yeti/Naverbot, Yottaa Site Monitor, Youdao Bot, Yourls, Yunyun Bot, Zao, Ze List, zgrab, Zookabot, ZumBot
142
142
 
143
143
  ### Clients
144
144
 
145
- 2345 Browser, 360 Browser, 360 Phone Browser, ABrowse, aiohttp, Airmail, Akregator, Aloha Browser, Amaya, Amiga Aweb, Amiga Voyager, Amigo, Android Browser, AndroidDownloadManager, ANT Fresco, AntennaPod, ANTGalio, AOL Shield, Apple News, Apple PubSub, Arora, Atomic Web Browser, Audacious, Avant Browser, Avast Secure Browser, B-Line, Baidu Box App, Baidu Browser, Baidu Spark, Banshee, Barca, BashPodder, Basilisk, Beaker Browser, Beonex, BeyondPod, BingWebApp, BlackBerry Browser, Boxee, bPod, Brave, Breaker, BriskBard, BrowseX, Bunjalloo, Camino, Castro, Castro 2, Charon, Cheetah Browser, Cheshire, Chrome, Chrome Frame, Chrome Mobile, Chrome Mobile iOS, Chrome Webview, ChromePlus, Chromium, Clementine, CM Browser, Coast, Coc Coc, CometBird, Comodo Dragon, Conkeror, CoolNovo, CrosswalkApp, Cunaguaro, curl, Cyberfox, DAVdroid, dbrowser, Deepnet Explorer, Deezer, Dillo, DoggCatcher, Dolphin, Dooble, Dorado, douban App, Downcast, DuckDuckGo Privacy Browser, Ecosia, Element Browser, Elinks, Epic, Espial TV Browser, Facebook, Facebook Messenger, Faraday, FeedDemon, Feeddler RSS Reader, FeedR, Fennec, Firebird, Firefox, Firefox Focus, Firefox Mobile, Firefox Mobile iOS, Firefox Rocket, Fireweb, Fireweb Navigator, Flipboard App, Flock, Fluid, FlyCast, Foobar2000, FreeU, Galeon, GNOME Web, Go-http-client, Google Earth, Google HTTP Java Client, Google Play Newsstand, Google Plus, Google Search App, gPodder, Guzzle (PHP HTTP Client), Hawk Turbo Browser, Headless Chrome, hola! Browser, HotJava, HTTP_Request2, HTTPie, Huawei Browser, IBrowse, iCab, iCab Mobile, iCatcher, IceCat, IceDragon, Iceweasel, IE Mobile, Instacast, Instagram App, Internet Explorer, Iridium, Iron, Iron Mobile, Isivioo, iTunes, Jasmine, Java, JetBrains Omea Reader, Jig Browser, Jio Browser, K-meleon, K.Browser, Kapiko, Kazehakase, Kindle Browser, Kiwi, Kodi, Konqueror, Kylo, LG Browser, libdnf, LieBaoFast, Liferea, Line, Links, Lotus Notes, LuaKit, Lunascape, Lynx, MailBar, Maxthon, Mechanize, MediaMonkey, Mercury, MicroB, Microsoft Edge, Microsoft Outlook, Midori, Mint Browser, Miro, MIUI Browser, Mobicip, Mobile Safari, Mobile Silk, NCSA Mosaic, NetFront, NetFront Life, NetNewsWire, NetPositive, Netscape, NetSurf, NewsArticle App, Newsbeuter, NewsBlur, NewsBlur Mobile App, NexPlayer, Nightingale, Nokia Browser, Nokia OSS Browser, Nokia Ovi Browser, Nox Browser, NTENT Browser, Obigo, Oculus Browser, Odyssey Web Browser, Off By One, OkHttp, OmniWeb, ONE Browser, Openwave Mobile Browser, Opera, Opera Devices, Opera Mini, Opera Mini iOS, Opera Mobile, Opera Neon, Opera Next, Opera Touch, Oppo Browser, Oregano, Otter Browser, Outlook Express, Overcast, Pale Moon, Palm Blazer, Palm Pre, Palm WebPro, Palmscape, Perl, Phoenix, Pinterest, Player FM, Pocket Casts, Podcast & Radio Addict, Podcast Republic, Podcasts, Podcat, Podcatcher Deluxe, Podkicker, Polaris, Polarity, Postbox, PritTorrent, Puffin, Pulp, Python Requests, Python urllib, QQ Browser, QQ Browser Mini, QtWebEngine, QuickTime, QuiteRSS, QupZilla, Qutebrowser, Qwant Mobile, ReadKit, Realme Browser, Reeder, Rekonq, REST Client for Ruby, RestSharp, RockMelt, RSS Bandit, RSS Junkie, RSSOwl, RSSRadio, Safari, Sailfish Browser, Samsung Browser, SeaMonkey, SEMC-Browser, Seraphic Sraf, Seznam Browser, Shiira, Sina Weibo, Skyfire, Sleipnir, Snowshoe, Sogou Explorer, Sogou Mobile Browser, SogouSearch App, Songbird, Sputnik Browser, Stagefright, Streamy, Stringer, SubStream, Sunrise, SuperBird, Swiftfox, TenFourFox, Tenta Browser, The Bat!, Thunderbird, tieba, Tizen Browser, TweakStyle, UC Browser, UC Browser Mini, urlgrabber (yum), Vision Mobile Browser, Vivaldi, vivo Browser, VLC, Waterfox, Web Explorer, WebPositive, WeChat, WeTab Browser, Wget, Whale Browser, WhatsApp, Winamp, Windows Media Player, wOSBrowser, WWW-Mechanize, XBMC, Xiino, Yahoo! Japan, Yandex Browser, Yandex Browser Lite, Yelp Mobile, YouTube
145
+ 115 Browser, 2345 Browser, 360 Browser, 360 Phone Browser, ABrowse, aiohttp, Airmail, Akregator, Aloha Browser, Aloha Browser Lite, Amaya, Amiga Aweb, Amiga Voyager, Amigo, Android Browser, AndroidDownloadManager, ANT Fresco, AntennaPod, ANTGalio, AOL Desktop, AOL Shield, Apple News, Apple PubSub, Arctic Fox, Arora, Atom, Atomic Web Browser, Audacious, Avant Browser, Avast Secure Browser, AVG Secure Browser, B-Line, Baidu Box App, Baidu Browser, Baidu Spark, Banshee, Barca, BashPodder, Basilisk, Beaker Browser, Beamrise, Beonex, BeyondPod, BingWebApp, BlackBerry Browser, BlackHawk, Boxee, bPod, Brave, Breaker, BriskBard, BrowseX, Bunjalloo, Camino, CastBox, Castro, Castro 2, CCleaner, Centaury, Charon, Cheetah Browser, Cheshire, Chrome, Chrome Frame, Chrome Mobile, Chrome Mobile iOS, Chrome Webview, ChromePlus, Chromium, Clementine, CM Browser, Coast, Coc Coc, Colibri, CometBird, Comodo Dragon, Conkeror, CoolNovo, COS Browser, CrosswalkApp, Crusta, Cunaguaro, curl, Cyberfox, DAVdroid, dbrowser, Deepnet Explorer, Deezer, Delta Browser, Dillo, DoggCatcher, Dolphin, Dooble, Dorado, douban App, Downcast, DuckDuckGo Privacy Browser, Ecosia, Element Browser, Elements Browser, Elinks, Epic, Espial TV Browser, EUI Browser, eZ Browser, Facebook, Facebook Messenger, Falkon, Faraday, Faux Browser, FeedDemon, Feeddler RSS Reader, FeedR, Fennec, Firebird, Firefox, Firefox Focus, Firefox Mobile, Firefox Mobile iOS, Firefox Reality, Firefox Rocket, Fireweb, Fireweb Navigator, Flipboard App, Flock, Fluid, FlyCast, Foobar2000, FreeU, Galeon, Glass Browser, GNOME Web, Go-http-client, Google Earth, Google Go, Google HTTP Java Client, Google Play Newsstand, Google Plus, Google Podcasts, Google Search App, gPodder, Guzzle (PHP HTTP Client), Hawk Turbo Browser, Headless Chrome, hola! Browser, HotJava, HTTP_Request2, HTTPie, Huawei Browser, IBrowse, iCab, iCab Mobile, iCatcher, IceCat, IceDragon, Iceweasel, IE Mobile, Instacast, Instagram App, Internet Explorer, Iridium, Iron, Iron Mobile, Isivioo, iTunes, Jasmine, Java, JetBrains Omea Reader, Jig Browser, Jig Browser Plus, Jio Browser, K-meleon, K.Browser, Kapiko, Kazehakase, Kindle Browser, Kinza, Kiwi, Kodi, Konqueror, Kylo, LG Browser, libdnf, LieBaoFast, Liferea, Light, Line, Links, Lotus Notes, Lovense Browser, LuaKit, Lulumi, Lunascape, Lunascape Lite, Lynx, MailBar, Maxthon, mCent, Mechanize, MediaMonkey, Meizu Browser, Mercury, MicroB, Microsoft Edge, Microsoft Outlook, Midori, Minimo, Mint Browser, Miro, MIUI Browser, Mobicip, Mobile Safari, Mobile Silk, mpv, Music Player Daemon, Mypal, NCSA Mosaic, NetFront, NetFront Life, NetNewsWire, NetPositive, Netscape, NetSurf, NewsArticle App, Newsbeuter, NewsBlur, NewsBlur Mobile App, NexPlayer, Nightingale, Node Fetch, Nokia Browser, Nokia OSS Browser, Nokia Ovi Browser, Nox Browser, NTENT Browser, Obigo, Oculus Browser, Odyssey Web Browser, Off By One, OhHai Browser, OkHttp, OmniWeb, ONE Browser, Openwave Mobile Browser, Opera, Opera Devices, Opera GX, Opera Mini, Opera Mini iOS, Opera Mobile, Opera Neon, Opera Next, Opera Touch, Oppo Browser, Ordissimo, Oregano, Origin In-Game Overlay, Origyn Web Browser, Otter Browser, Outlook Express, Overcast, Pale Moon, Palm Blazer, Palm Pre, Palm WebPro, Palmscape, Perl, Perl REST::Client, Phoenix, Pinterest, Player FM, Pocket Casts, Podcast & Radio Addict, Podcast Republic, Podcasts, Podcat, Podcatcher Deluxe, Podkicker, Polaris, Polarity, Polypane, Postbox, PritTorrent, Puffin, Pulp, Python Requests, Python urllib, QQ Browser, QQ Browser Mini, QtWebEngine, Quark, QuickTime, QuiteRSS, QupZilla, Qutebrowser, Qwant Mobile, ReadKit, Realme Browser, Reeder, Rekonq, REST Client for Ruby, RestSharp, RockMelt, RSS Bandit, RSS Junkie, RSSOwl, RSSRadio, Safari, Safe Exam Browser, Sailfish Browser, SalamWeb, Samsung Browser, ScalaJ HTTP, SeaMonkey, SEMC-Browser, Seraphic Sraf, Seznam Browser, Shiira, SimpleBrowser, Sina Weibo, Sizzy, Skyfire, Sleipnir, Snapchat, Snowshoe, Sogou Explorer, Sogou Mobile Browser, SogouSearch App, Songbird, Splash, Sputnik Browser, Stagefright, START Internet Browser, Steam In-Game Overlay, Streamy, Stringer, SubStream, Sunrise, Super Fast Browser, SuperBird, surf, Swiftfox, t-online.de Browser, Tao Browser, TenFourFox, Tenta Browser, The Bat!, Thunderbird, tieba, Tizen Browser, ToGate, TopBuzz, Tungsten, TV Bro, TweakStyle, Twitter, UBrowser, UC Browser, UC Browser Mini, UC Browser Turbo, urlgrabber (yum), Uzbl, Vision Mobile Browser, Vivaldi, vivo Browser, VLC, VMware AirWatch, Waterfox, Wear Internet Browser, Web Explorer, WebPositive, WeChat, WeTab Browser, Wget, Whale Browser, WhatsApp, Winamp, Windows Media Player, wOSBrowser, WWW-Mechanize, XBMC, Xiino, Xvast, Yahoo! Japan, Yahoo! Japan Browser, Yandex Browser, Yandex Browser Lite, Yelp Mobile, YouTube, Zvu
146
146
 
147
147
  ### Devices
148
148
 
149
- 3Q, 4Good, Acer, Advan, Advance, AGM, Ainol, Airness, Airties, AIS, Aiwa, Akai, Alcatel, AllCall, Allview, Allwinner, Altech UEC, altron, Amazon, AMGOO, Amoi, ANS, Apple, Archos, Arian Space, Ark, Arnova, ARRIS, Ask, Assistant, Asus, Audiovox, AVH, Avvio, Axxion, Azumi Mobile, BangOlufsen, Barnes & Noble, Becker, Beeline, Beetel, BenQ, BenQ-Siemens, BGH, Bird, Bitel, Black Fox, Blackview, Blaupunkt, Blu, Bluboo, Bluegood, Bmobile, bogo, Boway, bq, Bravis, Brondi, Bush, CAGI, Capitel, Captiva, Carrefour, Casio, Casper, Cat, Celkon, Changhong, Cherry Mobile, China Mobile, Clarmin, CnM, Coby Kyros, Comio, Compal, ComTrade Tesla, Concord, ConCorde, Condor, Coolpad, Cowon, CreNova, Crescent, Cricket, Crius Mea, Crosscall, Cube, CUBOT, Cyrus, Danew, Datang, Datsun, Dbtel, Dell, Denver, Desay, DEXP, Dialog, Dicam, Digi, Digicel, Digiland, Digma, DMM, DNS, DoCoMo, Doogee, Doov, Dopod, Doro, Dune HD, E-Boda, E-tel, Easypix, EBEST, Echo Mobiles, ECS, EE, EKO, Eks Mobility, Elenberg, Elephone, Energizer, Energy Sistem, Ergo, Ericsson, Ericy, Essential, Essentielb, Eton, eTouch, Etuline, Eurostar, Evercoss, Evertek, Evolio, Evolveo, EvroMedia, Explay, Extrem, Ezio, Ezze, Fairphone, Famoco, Fengxiang, FiGO, FinePower, Fly, FNB, Fondi, FORME, Forstar, Foxconn, Freetel, Fujitsu, G-TiDE, Garmin-Asus, Gemini, Geotel, Ghia, Gigabyte, Gigaset, Ginzzu, Gionee, GOCLEVER, Goly, GoMobile, Google, Gradiente, Grape, Grundig, Hafury, Haier, HannSpree, Hasee, Hi-Level, Hisense, Hoffmann, Homtom, Hoozo, Hosin, HP, HTC, Huawei, Humax, Hyundai, i-Joy, i-mate, i-mobile, iBall, iBerry, IconBIT, iHunt, Ikea, iKoMo, iLA, IMO Mobile, Impression, iNew, Infinix, InFocus, Inkti, InnJoo, Innostream, Inoi, INQ, Insignia, Intek, Intex, Inverto, iOcean, iPro, Irbis, iRola, iTel, iView, JAY-Tech, Jiayu, Jolla, Just5, K-Touch, Kaan, Kalley, Karbonn, Kazam, KDDI, Kempler & Strauss, Keneksi, Kiano, Kingsun, Kocaso, Kodak, Kogan, Komu, Konka, Konrow, Koobee, KOPO, Koridy, KRONO, Krüger&Matz, KT-Tech, Kumai, Kyocera, LAIQ, Land Rover, Landvo, Lanix, Lark, Lava, LCT, Le Pan, Leagoo, Ledstar, LeEco, Lemhoov, Lenco, Lenovo, Leotec, Lephone, Lexand, Lexibook, LG, Lingwin, Loewe, Logicom, Lumus, LYF, M.T.T., M4tel, Majestic, Manta Multimedia, Masstel, Maxwest, Maze, Mecer, Mecool, Mediacom, MediaTek, Medion, MEEG, MegaFon, Meitu, Meizu, Memup, Metz, MEU, MicroMax, Microsoft, Mio, Miray, Mitsubishi, MIXC, MLLED, Mobicel, Mobiistar, Mobiola, Mobistel, Modecom, Mofut, Motorola, Movic, Mpman, MSI, MTC, MTN, MYFON, MyPhone, Myria, MyWigo, Navon, NEC, Neffos, Netgear, NeuImage, Newgen, NEXBOX, Nexian, Nextbit, NextBook, NGM, Nikon, Nintendo, NOA, Noain, Nobby, Noblex, Nokia, Nomi, Nous, NUU Mobile, Nvidia, NYX Mobile, O+, O2, Obi, Odys, Onda, OnePlus, OPPO, Opsson, Orange, Ouki, OUYA, Overmax, Oysters, Palm, Panacom, Panasonic, Pantech, PCBOX, PCD, PCD Argentina, PEAQ, Pentagram, Philips, phoneOne, Pioneer, Pixus, Ployer, Plum, Point of View, Polaroid, PolyPad, Polytron, Pomp, Positivo, PPTV, Prestigio, Primepad, ProScan, PULID, Q-Touch, Qilive, QMobile, Qtek, Quantum, Quechua, R-TV, Ramos, RCA Tablets, Readboy, Rikomagic, RIM, Rinno, Ritmix, Riviera, Rokit, Roku, Rombica, Ross&Moor, Rover, RT Project, Safaricom, Sagem, Samsung, Sanei, Santin BiTBiZ, Sanyo, Savio, Sega, Selevision, Selfix, Sencor, Sendo, Senseit, Senwa, SFR, Sharp, Shuttle, Siemens, Sigma, Silent Circle, Simbans, Sky, Skyworth, Smart, Smartfren, Smartisan, Softbank, Sonim, Sony, Spice, Star, Starway, STF Mobile, STK, Stonex, Storex, Sumvision, SunVan, SuperSonic, Supra, SWISSMOBILITY, Symphony, Syrox, T-Mobile, TB Touch, TCL, TechniSat, TechnoTrend, TechPad, Teclast, Tecno Mobile, Telefunken, Telego, Telenor, Telit, Tesco, Tesla, teXet, ThL, Thomson, TIANYU, Timovi, TiPhone, Tolino, Tooky, Top House, Toplux, Toshiba, Touchmate, TrekStor, Trevi, True, Tunisie Telecom, Turbo-X, TVC, U.S. Cellular, Uhappy, Ulefone, UMIDIGI, Unimax, Uniscope, Unknown, Unnecto, Unonu, Unowhy, UTOK, UTStarcom, Vastking, Venso, Verizon, Vernee, Vertex, Vertu, Verykool, Vestel, VGO TEL, Videocon, Videoweb, ViewSonic, Vinsoc, Vitelcom, Vivax, Vivo, Vizio, VK Mobile, Vodafone, Vonino, Vorago, Voto, Voxtel, Vulcan, Walton, Weimei, WellcoM, Wexler, Wiko, Wileyfox, Wink, Wolder, Wolfgang, Wonu, Woo, Woxter, X-TIGI, X-View, Xiaolajiao, Xiaomi, Xion, Xolo, Yandex, Yarvik, Yes, Yezz, Ytone, Yu, Yuandao, Yusun, Zeemi, Zen, Zenek, Zonda, Zopo, ZTE, Zuum, Zync, ZYQ, öwn
149
+ 3Q, 4Good, Ace, Acer, Advan, Advance, AGM, Ainol, Airness, Airties, AIS, Aiwa, Akai, Alba, Alcatel, Aligator, AllCall, AllDocube, Allview, Allwinner, Altech UEC, altron, Amazon, AMGOO, Amoi, ANS, Apple, Archos, Arian Space, Ark, ArmPhone, Arnova, ARRIS, Ask, Assistant, Asus, Atom, Audiovox, AVH, Avvio, Axxion, Azumi Mobile, BangOlufsen, Barnes & Noble, BDF, Becker, Beeline, Beetel, BenQ, BenQ-Siemens, Bezkam, BGH, Bird, Bitel, Bitmore, Black Fox, Blackview, Blaupunkt, Blu, Bluboo, Bluegood, Bmobile, bogo, Boway, bq, Bravis, Brondi, Bush, CAGI, Capitel, Captiva, Carrefour, Casio, Casper, Cat, Celkon, Changhong, Cherry Mobile, China Mobile, Chuwi, Clarmin, CnM, Coby Kyros, Comio, Compal, ComTrade Tesla, Concord, ConCorde, Condor, Coolpad, Cowon, CreNova, Crescent, Cricket, Crius Mea, Crosscall, Cube, CUBOT, CVTE, Cyrus, Daewoo, Danew, Datang, Datawind, Datsun, Dbtel, Dell, Denver, Desay, DeWalt, DEXP, Dialog, Dicam, Digi, Digicel, Digiland, Digma, Divisat, DMM, DNS, DoCoMo, Doogee, Doov, Dopod, Doro, Droxio, Dune HD, E-Boda, E-tel, Easypix, EBEST, Echo Mobiles, ECS, EE, EKO, Eks Mobility, Element, Elenberg, Elephone, Energizer, Energy Sistem, Ergo, Ericsson, Ericy, Essential, Essentielb, Eton, eTouch, Etuline, Eurostar, Evercoss, Evertek, Evolio, Evolveo, EvroMedia, Explay, Extrem, Ezio, Ezze, Fairphone, Famoco, Fengxiang, FiGO, FinePower, Fly, FNB, Fondi, FORME, Forstar, Foxconn, Freetel, Fujitsu, G-TiDE, Garmin-Asus, Gemini, General Mobile, Geotel, Ghia, Ghong, Gigabyte, Gigaset, Ginzzu, Gionee, Globex, GOCLEVER, Goly, Gome, GoMobile, Google, Goophone, Gradiente, Grape, Gree, Grundig, Hafury, Haier, HannSpree, Hasee, Hi-Level, Highscreen, Hisense, Hoffmann, Homtom, Hoozo, Hosin, HP, HTC, Huadoo, Huawei, Humax, Hyundai, i-Joy, i-mate, i-mobile, iBall, iBerry, IconBIT, iGet, iHunt, Ikea, iKoMo, iLA, IMO Mobile, Impression, iNew, Infinix, InFocus, Inkti, InnJoo, Innostream, Inoi, INQ, Insignia, Intek, Intex, Inverto, iOcean, iPro, Irbis, iRola, iRulu, iTel, iVA, iView, iZotron, JAY-Tech, JFone, Jiayu, JKL, Jolla, Just5, K-Touch, Kaan, Kaiomy, Kalley, Kanji, Karbonn, KATV1, Kazam, KDDI, Kempler & Strauss, Keneksi, Kiano, Kingsun, Kivi, Kocaso, Kodak, Kogan, Komu, Konka, Konrow, Koobee, KOPO, Koridy, KRONO, Krüger&Matz, KT-Tech, Kuliao, Kumai, Kyocera, LAIQ, Land Rover, Landvo, Lanix, Lark, Lava, LCT, Le Pan, Leagoo, Ledstar, LeEco, Lemhoov, Lenco, Lenovo, Leotec, Lephone, Lexand, Lexibook, LG, Lingwin, Loewe, Logicom, Lumus, Luna, LYF, M.T.T., M4tel, Macoox, Majestic, Mann, Manta Multimedia, Masstel, Maxcom, Maxwest, Maze, Mecer, Mecool, Mediacom, MediaTek, Medion, MEEG, MegaFon, Meitu, Meizu, Memup, Metz, MEU, MicroMax, Microsoft, Mio, Miray, Mito, Mitsubishi, MIXC, MLLED, Mobicel, Mobiistar, Mobiola, Mobistel, Mobo, Modecom, Mofut, Motorola, Movic, Mpman, MSI, MTC, MTN, MYFON, MyPhone, Myria, Mystery, MyWigo, National, Navon, NEC, Neffos, Netgear, NeuImage, Newgen, NewsMy, NEXBOX, Nexian, NEXON, Nextbit, NextBook, NG Optics, NGM, Nikon, Nintendo, NOA, Noain, Nobby, Noblex, Nokia, Nomi, Nous, NUU Mobile, Nuvo, Nvidia, NYX Mobile, O+, O2, Obi, Odys, Onda, OnePlus, Onix, ONN, OPPO, Opsson, Orange, Ouki, Oukitel, OUYA, Overmax, Oysters, Palm, Panacom, Panasonic, Pantech, PCBOX, PCD, PCD Argentina, PEAQ, Pentagram, Phicomm, Philips, phoneOne, Pioneer, Pixus, Ployer, Plum, PocketBook, Point of View, Polaroid, PolyPad, Polytron, Pomp, Positivo, PPTV, Prestigio, Primepad, Proline, ProScan, Protruly, PULID, Q-Touch, Q.Bell, Qilive, QMobile, Qtek, Quantum, Quechua, Qumo, R-TV, Ramos, Razer, RCA Tablets, Readboy, Realme, Rikomagic, RIM, Rinno, Ritmix, Ritzviva, Riviera, Roadrover, Rokit, Roku, Rombica, Ross&Moor, Rover, RoverPad, RT Project, RugGear, Runbo, Ryte, Safaricom, Sagem, Samsung, Sanei, Santin, Sanyo, Savio, Sega, Selevision, Selfix, Sencor, Sendo, Senseit, Senwa, SFR, Sharp, Shift Phones, Shuttle, Siemens, Sigma, Silent Circle, Simbans, Sky, Skyworth, Smart, Smartfren, Smartisan, Softbank, Sonim, Sony, Soyes, Spectrum, Spice, Star, Starway, STF Mobile, STK, Stonex, Storex, Sugar, Sumvision, SunVan, Sunvell, SuperSonic, Supra, SWISSMOBILITY, Symphony, Syrox, T-Mobile, TB Touch, TCL, TechniSat, TechnoTrend, TechPad, Teclast, Tecno Mobile, Telefunken, Telego, Telenor, Telit, Tesco, Tesla, teXet, ThL, Thomson, TIANYU, Timovi, TiPhone, Tolino, Tooky, Top House, Toplux, Toshiba, Touchmate, TrekStor, Trevi, True, Tunisie Telecom, Turbo, Turbo-X, TVC, TWM, U.S. Cellular, Ugoos, Uhans, Uhappy, Ulefone, Umax, UMIDIGI, Unihertz, Unimax, Uniscope, Unknown, Unnecto, Unonu, Unowhy, UTOK, UTStarcom, Vastking, Venso, Verizon, Vernee, Vertex, Vertu, Verykool, Vesta, Vestel, VGO TEL, Videocon, Videoweb, ViewSonic, Vinga, Vinsoc, Vitelcom, Vivax, Vivo, Vizio, VK Mobile, VKworld, Vodacom, Vodafone, Vonino, Vontar, Vorago, Vorke, Voto, Voxtel, Voyo, Vsun, Vulcan, Walton, Weimei, WellcoM, Wexler, Wieppo, Wigor, Wiko, Wileyfox, Wink, Wolder, Wolfgang, Wonu, Woo, Woxter, X-TIGI, X-View, Xiaolajiao, Xiaomi, Xion, Xolo, Xoro, Xshitou, Yandex, Yarvik, Yes, Yezz, Yota, Ytone, Yu, Yuandao, Yusun, Yxtel, Zeemi, Zen, Zenek, Zfiner, Zidoo, Zonda, Zopo, ZTE, Zuum, Zync, ZYQ, öwn
150
150
 
151
151
  ## Maintainers
152
152
 
data/Rakefile CHANGED
@@ -14,13 +14,15 @@ end
14
14
  task default: :test
15
15
 
16
16
  task :detectable_names do
17
- require 'Date'
17
+ require 'date'
18
18
 
19
- bot_names = DeviceDetector::Bot.new.send(:regexes).map { |r| r[:name] }.uniq.sort_by(&:downcase)
19
+ bot_names = DeviceDetector::Bot.new('').send(:regexes)
20
+ .map { |r| r[:name] }.uniq.sort_by(&:downcase)
20
21
  bot_names.delete('$1')
21
- client_names = DeviceDetector::Client.new.send(:regexes).map { |r| r[:name] }.uniq.sort_by(&:downcase)
22
+ client_names = DeviceDetector::Client.new('').send(:regexes)
23
+ .map { |r| r[:name] }.uniq.sort_by(&:downcase)
22
24
  client_names.delete('$1')
23
- device = DeviceDetector::Device.new
25
+ device = DeviceDetector::Device.new('')
24
26
  device_paths = device.send(:filepaths)
25
27
  device_regexes = device.send(:load_regexes, device_paths)
26
28
  device_names = device_regexes.flat_map { |dn| dn[1].keys }.uniq.sort_by(&:downcase)
@@ -63,19 +65,6 @@ task :update_regexes do
63
65
  system "cp -R #{PIWIK_CHECKOUT_LOCATION}/regexes/* #{top}/regexes"
64
66
  end
65
67
 
66
- desc 'fix regexes that are broken because of a bug in ruby'
67
- task :fix_regexes do
68
- # fix broken regexes: https://github.com/podigee/device_detector/issues/65
69
-
70
- # modify regex to bypass ruby bug
71
- system "sed -i '' 's/\|ImSmart \|ERGO \|X-Style Tab //g' regexes/device/mobiles.yml"
72
-
73
- # remove fixtures that test that regex
74
- system "sed -i '' '/X-Style Tab A101/,/^-/{d;};' spec/fixtures/**/*.yml"
75
- system "sed -i '' '/ERGO A500 Best Build/,/^-/{d;};' spec/fixtures/**/*.yml"
76
- system "sed -i '' '/ImSmart A501 Build.KOT49H/,/^-/{d;};' spec/fixtures/**/*.yml"
77
- end
78
-
79
68
  desc 'update fixtures from piwik project'
80
69
  task :update_fixtures do
81
70
  top = File.expand_path(__dir__)
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'minitest'
24
24
  spec.add_development_dependency 'rake'
25
25
  spec.add_development_dependency 'pry', '>= 0.10'
26
+ spec.add_development_dependency 'rubocop', '0.85.1'
26
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
 
3
5
  require 'device_detector/version'
@@ -13,7 +15,6 @@ require 'device_detector/device'
13
15
  require 'device_detector/os'
14
16
 
15
17
  class DeviceDetector
16
-
17
18
  attr_reader :user_agent
18
19
 
19
20
  def initialize(user_agent)
@@ -54,7 +55,10 @@ class DeviceDetector
54
55
  # Chrome on Android passes the device type based on the keyword 'Mobile'
55
56
  # If it is present the device should be a smartphone, otherwise it's a tablet
56
57
  # See https://developer.chrome.com/multidevice/user-agent#chrome_for_android_user_agent
57
- if t.nil? && os.family == 'Android' && ['Chrome', 'Chrome Mobile'].include?(name)
58
+ # Note: We do not check for browser (family) here, as there might be mobile apps using Chrome,
59
+ # that won't have a detected browser, but can still be detected. So we check the useragent for
60
+ # Chrome instead.
61
+ if t.nil? && os.family == 'Android' && user_agent =~ build_regex('Chrome\/[\.0-9]*')
58
62
  if user_agent =~ build_regex('Chrome\/[\.0-9]* Mobile')
59
63
  t = 'smartphone'
60
64
  elsif user_agent =~ build_regex('Chrome\/[\.0-9]* (?!Mobile)')
@@ -62,13 +66,9 @@ class DeviceDetector
62
66
  end
63
67
  end
64
68
 
65
- if t.nil? && android_tablet_fragment? || opera_tablet?
66
- t = 'tablet'
67
- end
69
+ t = 'tablet' if t.nil? && android_tablet_fragment? || opera_tablet?
68
70
 
69
- if t.nil? && android_mobile_fragment?
70
- t = 'smartphone'
71
- end
71
+ t = 'smartphone' if t.nil? && android_mobile_fragment?
72
72
 
73
73
  # Android up to 3.0 was designed for smartphones only. But as 3.0,
74
74
  # which was tablet only, was published too late, there were a
@@ -87,35 +87,27 @@ class DeviceDetector
87
87
  end
88
88
 
89
89
  # All detected feature phones running android are more likely a smartphone
90
- if t == 'feature phone' && os.family == 'Android'
91
- t = 'smartphone'
92
- end
90
+ t = 'smartphone' if t == 'feature phone' && os.family == 'Android'
93
91
 
94
92
  # According to http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
95
- # Internet Explorer 10 introduces the "Touch" UA string token. If this token is present at the end of the
96
- # UA string, the computer has touch capability, and is running Windows 8 (or later).
93
+ # Internet Explorer 10 introduces the "Touch" UA string token. If this token is present at the
94
+ # end of the UA string, the computer has touch capability, and is running Windows 8 (or later).
97
95
  # This UA string will be transmitted on a touch-enabled system running Windows 8 (RT)
98
96
  #
99
- # As most touch enabled devices are tablets and only a smaller part are desktops/notebooks we assume that
100
- # all Windows 8 touch devices are tablets.
97
+ # As most touch enabled devices are tablets and only a smaller part are desktops/notebooks we
98
+ # assume that all Windows 8 touch devices are tablets.
101
99
  if t.nil? && touch_enabled? &&
102
100
  (os.short_name == 'WRT' || (os.short_name == 'WIN' && os.full_version && os.full_version >= '8'))
103
101
  t = 'tablet'
104
102
  end
105
103
 
106
- if opera_tv_store?
107
- t = 'tv'
108
- end
104
+ t = 'tv' if opera_tv_store?
109
105
 
110
- if t.nil? && ['Kylo', 'Espial TV Browser'].include?(client.name)
111
- t = 'tv'
112
- end
106
+ t = 'tv' if t.nil? && ['Kylo', 'Espial TV Browser'].include?(client.name)
113
107
 
114
108
  # set device type to desktop for all devices running a desktop os that were
115
109
  # not detected as an other device type
116
- if t.nil? && os.desktop? && !puffin_browser?
117
- t = 'desktop'
118
- end
110
+ t = 'desktop' if t.nil? && os.desktop? && !puffin_browser?
119
111
 
120
112
  t
121
113
  end
@@ -133,7 +125,6 @@ class DeviceDetector
133
125
  end
134
126
 
135
127
  class << self
136
-
137
128
  class Configuration
138
129
  attr_accessor :max_cache_keys
139
130
 
@@ -152,11 +143,10 @@ class DeviceDetector
152
143
  @cache ||= MemoryCache.new(config.to_hash)
153
144
  end
154
145
 
155
- def configure(&block)
146
+ def configure
156
147
  @config = Configuration.new
157
148
  yield(config)
158
149
  end
159
-
160
150
  end
161
151
 
162
152
  private
@@ -205,5 +195,4 @@ class DeviceDetector
205
195
  def build_regex(src)
206
196
  Regexp.new('(?:^|[^A-Z0-9\_\-])(?:' + src + ')', Regexp::IGNORECASE)
207
197
  end
208
-
209
198
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DeviceDetector
2
4
  class Bot < Parser
3
-
4
5
  def bot?
5
6
  regex_meta.any?
6
7
  end
@@ -10,6 +11,5 @@ class DeviceDetector
10
11
  def filenames
11
12
  ['bots.yml']
12
13
  end
13
-
14
14
  end
15
15
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DeviceDetector
2
4
  class Client < Parser
3
-
4
5
  def known?
5
6
  regex_meta.any?
6
7
  end
@@ -14,7 +15,7 @@ class DeviceDetector
14
15
  'client/mediaplayers.yml',
15
16
  'client/pim.yml',
16
17
  'client/browsers.yml',
17
- 'client/libraries.yml',
18
+ 'client/libraries.yml'
18
19
  ]
19
20
  end
20
21
  end
@@ -1,20 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DeviceDetector
2
4
  class Device < Parser
3
-
4
5
  # order is relevant for testing with fixtures
5
6
  DEVICE_NAMES = [
6
- 'desktop',
7
- 'smartphone',
8
- 'tablet',
9
- 'feature phone',
10
- 'console',
11
- 'tv',
12
- 'car browser',
13
- 'smart display',
14
- 'camera',
15
- 'portable media player',
16
- 'phablet'
17
- ]
7
+ 'desktop',
8
+ 'smartphone',
9
+ 'tablet',
10
+ 'feature phone',
11
+ 'console',
12
+ 'tv',
13
+ 'car browser',
14
+ 'smart display',
15
+ 'camera',
16
+ 'portable media player',
17
+ 'phablet'
18
+ ].freeze
18
19
 
19
20
  def known?
20
21
  regex_meta.any?
@@ -43,18 +44,22 @@ class DeviceDetector
43
44
  'device/car_browsers.yml',
44
45
  'device/cameras.yml',
45
46
  'device/portable_media_player.yml',
46
- 'device/mobiles.yml',
47
+ 'device/mobiles.yml'
47
48
  ]
48
49
  end
49
50
 
50
51
  def matching_regex
51
52
  from_cache([self.class.name, user_agent]) do
52
53
  regex_list = hbbtv? ? regexes_for_hbbtv : regexes_other
53
- regex = regex_list.find { |r| user_agent =~ r[:regex] }
54
+ regex = regex_find(user_agent, regex_list)
54
55
  if regex && regex[:models]
55
- model_regex = regex[:models].find { |m| user_agent =~ m[:regex]}
56
+ model_regex = regex[:models].find { |m| user_agent =~ m[:regex] }
56
57
  if model_regex
57
- regex = regex.merge(:regex_model => model_regex[:regex], :model => model_regex[:model], :brand => model_regex[:brand])
58
+ regex = regex.merge({
59
+ regex_model: model_regex[:regex],
60
+ model: model_regex[:model],
61
+ brand: model_regex[:brand]
62
+ })
58
63
  regex[:device] = model_regex[:device] if model_regex.key?(:device)
59
64
  regex.delete(:models)
60
65
  end
@@ -63,6 +68,23 @@ class DeviceDetector
63
68
  end
64
69
  end
65
70
 
71
+ # Finds the first match of the string in a list of regexes.
72
+ # Handles exception with special characters caused by bug in Ruby regex
73
+ # @param user_agent [String] User Agent string
74
+ # @param regex_list [Array<Regex>] List of regexes
75
+ #
76
+ # @return [MatchData, nil] MatchData if string matches any regexp, nil otherwise
77
+ def regex_find(user_agent, regex_list)
78
+ regex_list.find { |r| user_agent =~ r[:regex] }
79
+ rescue RegexpError
80
+ # Bug in ruby regex and special characters, retry with clean
81
+ # https://bugs.ruby-lang.org/issues/13671
82
+ user_agent = user_agent.encode(
83
+ ::Encoding::ASCII, invalid: :replace, undef: :replace, replace: ''
84
+ )
85
+ regex_list.find { |r| user_agent =~ r[:regex] }
86
+ end
87
+
66
88
  def hbbtv?
67
89
  @regex_hbbtv ||= build_regex('HbbTV/([1-9]{1}(?:\.[0-9]{1}){1,2})')
68
90
  user_agent =~ @regex_hbbtv
@@ -73,16 +95,18 @@ class DeviceDetector
73
95
  end
74
96
 
75
97
  def regexes_other
76
- regexes.select { |r| r[:path] != :'device/televisions.yml' }
98
+ regexes.reject { |r| r[:path] == :'device/televisions.yml' }
77
99
  end
78
100
 
79
101
  def parse_regexes(path, raw_regexes)
80
102
  raw_regexes.map do |brand, meta|
81
- fail "invalid device spec: #{meta.inspect}" unless meta[:regex].is_a? String
103
+ raise "invalid device spec: #{meta.inspect}" unless meta[:regex].is_a? String
104
+
82
105
  meta[:regex] = build_regex(meta[:regex])
83
106
  if meta.key?(:models)
84
107
  meta[:models].each do |model|
85
- fail "invalid model spec: #{model.inspect}" unless model[:regex].is_a? String
108
+ raise "invalid model spec: #{model.inspect}" unless model[:regex].is_a? String
109
+
86
110
  model[:regex] = build_regex(model[:regex])
87
111
  model[:brand] = brand.to_s unless model[:brand]
88
112
  end
@@ -91,6 +115,5 @@ class DeviceDetector
91
115
  meta
92
116
  end
93
117
  end
94
-
95
118
  end
96
119
  end
@@ -51,12 +51,12 @@ class DeviceDetector
51
51
  def purge_cache
52
52
  key_size = data.size
53
53
 
54
- if key_size >= max_keys
55
- # always remove about 1/3 of keys to reduce garbage collecting
56
- amount_of_keys = key_size / 3
54
+ return if key_size < max_keys
57
55
 
58
- data.keys.first(amount_of_keys).each { |key| data.delete(key) }
59
- end
56
+ # always remove about 1/3 of keys to reduce garbage collecting
57
+ amount_of_keys = key_size / 3
58
+
59
+ data.keys.first(amount_of_keys).each { |key| data.delete(key) }
60
60
  end
61
61
  end
62
62
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DeviceDetector
2
4
  class MetadataExtractor < Struct.new(:user_agent, :regex_meta)
3
-
4
5
  def call
5
6
  regex_meta.any? ? extract_metadata : nil
6
7
  end
@@ -8,22 +9,20 @@ class DeviceDetector
8
9
  private
9
10
 
10
11
  def metadata_string
11
- message = "#{self.name} (a child of MetadataExtractor) must implement the '#{__method__}' method."
12
- fail NotImplementedError, message
12
+ message = "#{name} (a child of MetadataExtractor) must implement the '#{__method__}' method."
13
+ raise NotImplementedError, message
13
14
  end
14
15
 
15
16
  def extract_metadata
16
17
  user_agent.match(regex) do |match_data|
17
- metadata_string.gsub(/\$(\d)/) {
18
- match_data[$1.to_i].to_s
19
- }.strip
18
+ metadata_string.gsub(/\$(\d)/) do
19
+ match_data[Regexp.last_match(1).to_i].to_s
20
+ end.strip
20
21
  end
21
22
  end
22
23
 
23
24
  def regex
24
25
  @regex ||= regex_meta[:regex]
25
26
  end
26
-
27
27
  end
28
28
  end
29
-