Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shopify/browser_sniffer
Properly detect what browser you are dealing with
https://github.com/shopify/browser_sniffer
Last synced: 3 months ago
JSON representation
Properly detect what browser you are dealing with
- Host: GitHub
- URL: https://github.com/shopify/browser_sniffer
- Owner: Shopify
- License: other
- Created: 2013-06-19T15:24:42.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2024-03-15T19:45:37.000Z (8 months ago)
- Last Synced: 2024-04-14T09:45:25.570Z (7 months ago)
- Language: Ruby
- Homepage: https://shopify.github.io/browser_sniffer/
- Size: 111 KB
- Stars: 117
- Watchers: 464
- Forks: 22
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-network-stuff - **90**星
README
[![Build Status](https://github.com/Shopify/browser_sniffer/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/Shopify/browser_sniffer/actions/workflows/test.yml)
[![Gem Version](https://badge.fury.io/rb/browser_sniffer.png)](http://badge.fury.io/rb/browser_sniffer)# BrowserSniffer
## Description
Parses user agent strings and boils it all down to a few simple classifications.
## Installation
Add this line to your application's Gemfile:
gem "browser_sniffer"
And then execute:
$ bundle install
Or install it yourself as:
$ git clone https://github.com/Shopify/browser_sniffer && cd browser_sniffer && bundle install && rake install
## Usage
```ruby
require "browser_sniffer"client_info = BrowserSniffer.new(request.user_agent)
client_info.form_factor # => :tablet
client_info.browser # => :safari
client_info.major_browser_version # => 4
client_info.engine # => :webkit
client_info.major_engine_version # => 531
client_info.os # => :ios
client_info.os_version # => 3.2
```## Contributing
Fork, branch & pull request.
## Licensing
Based off [UAParser.js](https://github.com/faisalman/ua-parser-js)
Copyright (c) 2013 Shopify
Copyright (c) 2012-2013 Faisalman
Dual licensed under GPLv2 & MIT