is_it_mobile
Simply determines if a user agent is for a mobile device. Comes ready with a module for Rails 2.0 to enable multiviews (respond_to with a custom mimetype) for mobile devices. Best of all, it’s fast & lightweight: it doesn‘t use anything like WURFL, which would be overkill for a quick check.
Installation
sudo gem install is_it_mobile
Usage
The lightweight tests used in IsItMobile are almost completely based on the work of Andy Moore that he published in an article. I added a couple more user agents to the mix and obviously Rubified it.
It recognizes 99% of the mobile user agents from this list of mobile agents. It has nearly no false positives using the user agents from this list of non-mobile agents. The ones that don‘t quite pass are very rare (and some are even questionable appearing in their respective lists).
With Rails 2.0, you can use its multiview capabilities simply by adding this to your app:
... in config/initializers/mime_types.rb
Mime::Type.register_alias "text/html", :mobile
... in app/controllers/application.rb
end
Then, just create your views using suffices of mobile.erb instead of html.erb
You can also just use IsItMobile directly: IsItMobile.mobile? ‘NokiaN90-1/3.0545.5.1 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1’ # => true
The future
Likely, is_it_mobile will be rolled into Quartermaster since it fits what Quartermaster is doing; detecting browsers and user agents and whatnot.