Skip to content

feedforce/userstack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Userstack

Travis Status License Gem

This gem provides an access to Userstack.

Installation

Add this line to your application's Gemfile:

gem 'userstack'

And then execute:

$ bundle

Or install it yourself as:

$ gem install userstack

Usage

  1. Instantiate an instance of {Userstack::Client} with a valid Access key.

    client = Userstack::Client.new(ACCESS_KEY)
  2. Parse an useragent.

    result = client.parse('an useragent')

Use http

If you are Free plan user, you have to use http scheme.

client = Userstack::Client.new(ACCESS_KEY, use_ssl: false)
result = client.parse('an useragent')

Legacy response

Userstack supports Useragent API response.

client = Userstack::Client.new(ACCESS_KEY, legacy: true)
result = client.parse('an useragent')

example response

{
  "data": {
    "ua_type": "Desktop",
    "os_name": "macOS 10.14 Mojave",
    "os_version": "",
    "browser_name": "Chrome",
    "browser_version": "71.0.3578.98",
    "engine_name": "WebKit/Blink",
    "engine_version": ""
  }
}

refs. https://userstack.com/documentation#enable_legacy_format

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/feedforce/userstack.

License

The gem is available as open source under the terms of the MIT License.