0.01
No release in over 3 years
Low commit activity in last 3 years
Ruby bindings to woothee-rust
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 1.9
>= 0
~> 13.0
~> 3.0

Runtime

 Project Readme

FastWoothee

Gem Version Build Status

Ruby Bindings to woothee-rust for performant, and safe user-agent parsing.

Installation

Having Rust/Cargo installed is optional. If it is not installed, the gem will download the libs binary automatically. Simply add this line to your application's Gemfile:

gem 'fast_woothee'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fast_woothee

Usage

FastWoothee.parse 'Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405'
# {:name=>"Webview", :category=>"smartphone", :os=>"iPad", :os_version=>"3.2.1", :browser_type=>"browser", :version=>"UNKNOWN", :vendor=>"OS vendor"}
# Determine if it is a crawler
FastWoothee.crawler?("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html") # => true
# Is the user on iOS?
FastWoothee.ios?("Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/600.1.4") # => true
# Is the user on Android?
FastWoothee.android?('Mozilla/5.0 (Linux; Android 9; SM-N960F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.105 Mobile Safari/537.36') # => true

Benchmarks

                 user     system      total        real
woothee      2.240000   0.020000   2.260000 (  2.261497)
fast-woothee  1.100000   0.010000   1.110000 (  1.134596)

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/ianks/fast_woothee.