device_detector
Version, currently 0.4.111 versions
- 0.4.1latestFeb 13, 2021
- 0.4.0not indexedFeb 13, 2021
- 0.3.3not indexedFeb 13, 2021
- 0.3.2not indexedFeb 13, 2021
- 0.3.1not indexedFeb 13, 2021
- 0.3.0not indexedFeb 13, 2021
- 0.2.4not indexedFeb 13, 2021
- 0.2.3not indexedFeb 13, 2021
- 0.2.2not indexedFeb 13, 2021
- 0.1.2not indexedFeb 13, 2021
- 0.1.1not indexedFeb 13, 2021
github.com/confact/device_detector
Device detection library will parse User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), vendor and model.
Installation
# Add this to your shard.yml
dependencies:
device_detector:
github: confact/device_detector
version: ~> 0.4.1Then run:
shards installshard.yml
- Crystal
0.36.1- License
- MIT
- Authors
- creadone, delef
Dependencies
Runtime Dependencies
- baked_file_system*github: schovi/baked_file_system, branch: master
README
Device Detector
The library for parsing User Agent and browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), vendor and model detection. Currently it is an alpha-version and haven't been tested on production yet. 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:
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
Contributing
- Fork it ( https://github.com/creadone/device_detector/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.4.1- Tagged
- Feb 13, 2021
- Commit
8421e0ad31c0- Crystal
0.36.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/confact/device_detector
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 11