device_detector
Version, currently 0.2.311 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.
Nothing has been indexed for 0.2.3 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
device_detector:
github: confact/device_detector
version: ~> 0.2.3Then run:
shards installshard.yml
No shard.yml has been indexed for 0.2.3. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
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.2.3- Tagged
- Feb 13, 2021
- Commit
52424962322d- Indexed
- not yet
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