All Projects → creadone → device_detector

creadone / device_detector

Licence: MIT license
Crystal shard for device detection by User-Agent string

Programming Languages

crystal
512 projects

Projects that are alternatives of or similar to device detector

Ua Parser Js
UAParser.js - Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Supports browser & node.js environment.
Stars: ✭ 6,421 (+30476.19%)
Mutual labels:  user-agent-parser, device-detection
Bowser
a browser detector
Stars: ✭ 5,006 (+23738.1%)
Mutual labels:  user-agent-parser, device-detection
react-ua
📱React User Agent Component, Hook, and HOC. SSR-ready, full UT, using new React Context and Hooks API
Stars: ✭ 18 (-14.29%)
Mutual labels:  user-agent-parser
detect-features
Detect and report browser and hardware features.
Stars: ✭ 63 (+200%)
Mutual labels:  device-detection
user-agent
User-Agent parser for Clojure
Stars: ✭ 24 (+14.29%)
Mutual labels:  user-agent-parser
db-sharding
Oracle Sharded database deployment automation and tools for use in client applications.
Stars: ✭ 30 (+42.86%)
Mutual labels:  shards
vue-device-detector
A tiny device detector plugin of Vue for mobile🐔👁
Stars: ✭ 43 (+104.76%)
Mutual labels:  device-detection
iDevicesInformation
A Light Weight and Updated Code for Device Detection and many other functionality written in swift 2.0
Stars: ✭ 13 (-38.1%)
Mutual labels:  device-detection
triki
Mysql, PostgreSQL and SQL dump obfuscator aka anonimizer
Stars: ✭ 28 (+33.33%)
Mutual labels:  shards
udger-python
Python agent string parser based on Udger https://udger.com/products/local_parser
Stars: ✭ 34 (+61.9%)
Mutual labels:  user-agent-parser
uainfer
Infer the user agent from its User Agent string
Stars: ✭ 21 (+0%)
Mutual labels:  user-agent-parser
udger-java
Java agent string parser based on Udger https://udger.com/products/local_parser
Stars: ✭ 24 (+14.29%)
Mutual labels:  user-agent-parser
Awesome Crystal
💎 A collection of awesome Crystal libraries, tools, frameworks and software
Stars: ✭ 2,902 (+13719.05%)
Mutual labels:  shards
mongo orm
Mongo ORM: A simple ORM for using MongoDB with the crystal programming language, designed for use with Amber. Based loosely on Granite ORM. Supports Rails-esque models, associations and embedded documents.
Stars: ✭ 32 (+52.38%)
Mutual labels:  shards
install-crystal
GitHub Action: Install Crystal programming language
Stars: ✭ 50 (+138.1%)
Mutual labels:  shards
Mobile Detect
Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
Stars: ✭ 9,899 (+47038.1%)
Mutual labels:  device-detection
Deviice
Swift library to easily check the current device and some more info about it.
Stars: ✭ 51 (+142.86%)
Mutual labels:  device-detection
hugo-dream-plus
🌈 An upgraded version of the Hugo "Dream" theme with tons of new features.
Stars: ✭ 67 (+219.05%)
Mutual labels:  device-detection

Device Detector

Build Status

The library for parsing User Agent and browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), vendor and model detection.

  • Support latest Crystal version and update script for private use or immediately updates.
  • Currently it is production version and works fine more that 2 years.
  • The Library uses regexes from matomo-org/device-detector.

Installation

Add this to your application's shard.yml:

dependencies:
  device_detector:
    github: creadone/device_detector

Then run shards install

Usage

require "device_detector"

user_agent = "Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 Edge/12.0"
response = DeviceDetector::Detector.new(user_agent).call  # All parsers
response = DeviceDetector::Detector.new(user_agent).lite  # Only for bot and mobile

# Check if browser detected
response.browser? #=> true

# browser name
response.browser_name #=> Microsoft Edge

# browser version
response.browser_version #=> 12.0

# get raw response with
pp response.raw

[{
    "bot" => {
      "name" => ""
    }
  },
  {
    "browser" => {
      "name" => "", "version" => ""
    }
  },

  {...},

  {
    "vendorfragment" => {
      "vendor" => ""
    }
  }
]

Available methods:

bot?
bot_name
browser_engine?
browser_engine_name
browser?
browser_name
browser_version
camera?
camera_vendor
camera_model
car_browser?
car_browser_vendor
car_browser_model
console?
console_vendor
console_model
feed_reader?
feed_reader_name
feed_reader_version
library?
library_name
library_version
mediaplayer?
mediaplayer_name
mediaplayer_version
mobile_app?
mobile_app_name
mobile_app_version
mobile_device?
mobile_device_vendor
mobile_device_type
mobile_device_model
os?
os_name
os_version
pim?
pim_name
pim_version
portable_media_player?
portable_media_player_vendor
portable_media_player_model
tv?
tv_vendor
tv_model
vendorfragment?
vendorfragment_vendor

Benchmarks

Recent benchmarking of parsing 1000 user-agent strings on a MacBook Air with Intel Core i5 dual core (0.8 Ghz per core):

Crystal 0.30.1 (2019-08-13) LLVM: 8.0.1 Default target: x86_64-apple-macosx

bench/raw_response.cr --release
            user     system      total        real
full:   5.880000   0.060000   5.940000 (  5.940340)
lite:   3.880000   0.040000   3.920000 (  3.953958)

It's mean that device_detector can work with 1000 / 5.9 ~ 169 QPS.

Testing

crystal spec

Update regexes

crystal scripts/update_regexes.cr

ToDo

  • Support overloading of base rules
  • CLI & HTTP version
  • More lighter and faster the lite version
  • Reload regexes on the fly (may be)

Contributing

  1. Fork it ( https://github.com/creadone/device_detector/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • @creadone Sergey Fedorov - creator, maintainer
  • @delef Ivan Palamarchuk - new api, code optimization
  • @zaycker Yuriy Zaitsev - fix check order
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].