# UAParser

[![Build Status][travis-img]][travis] [![Hex Version][hex-img]][hex] [![License][license-img]][license]

A user-agent parsing library based on BrowserScope's UA database


## Installation

1. Add `ua_parser` to your `mix.exs` dependencies:

    def deps do
      [{:ua_parser, "~> 1.0.0"}]

2. Add `:ua_parser` to your application dependencies:

    def application do
      [applications: [:ua_parser]]

## Usage

iex> ua = UAParser.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17 Skyfire/2.0")
  device: %UAParser.Device{family: nil},
  family: "Skyfire",
  os: %UAParser.OperatingSystem{
    family: "Mac OS X",
    version: %UAParser.Version{major: "10", minor: "5", patch: "7", patch_minor: nil}
  version: %UAParser.Version{major: "2", minor: "0", patch: nil, patch_minor: nil}
iex> to_string(ua)
"Skyfire 2.0"
iex> to_string(ua.os)
"Mac OS X 10.5.7"
iex> to_string(ua.device)

Retrieving and parsing a user-agent string from Plug:
ua =
  |> Plug.Conn.get_req_header("user-agent")
  |> List.first()
  |> UAParser.parse()

## Contributing

Contributions are always welcome.  We ask that contributors familiarize themselves with the []( guide.

## License

UAParser source code is released under Apache 2.0 License.

See [LICENSE](LICENSE) for more information.