lastminutelabs / Device-Aware

rails plugin for device atlas database

This URL has Read+Write access

name age message
file MIT-LICENSE Mon Jul 13 06:01:19 -0700 2009 inital checkin of plugin [mdahlstrom]
file README Mon Jul 13 06:01:19 -0700 2009 inital checkin of plugin [mdahlstrom]
file Rakefile Mon Jul 13 06:01:19 -0700 2009 inital checkin of plugin [mdahlstrom]
file init.rb Mon Jul 13 06:01:19 -0700 2009 inital checkin of plugin [mdahlstrom]
file install.rb Mon Jul 13 06:01:19 -0700 2009 inital checkin of plugin [mdahlstrom]
directory lib/ Mon Jul 13 06:01:19 -0700 2009 inital checkin of plugin [mdahlstrom]
directory tasks/ Mon Jul 13 06:01:19 -0700 2009 inital checkin of plugin [mdahlstrom]
file uninstall.rb Mon Jul 13 06:01:19 -0700 2009 inital checkin of plugin [mdahlstrom]
README
ActAsDeviceAware
================

This plugin is rails wrapper around dotmobis http://deviceatlas.com ruby library. It allows you to integrate the Device 
Atlas database into your action controllers. Device Atlas is a database of mobile handsets properties. For each view 
requests you can check properties such as display widths and heights, maximum image dimensions etc and scale content 
appropriately. 

This plugin requires that json and rubyzip gems are available on your system.


Example
=======

1. gem install json

2. gem install rubyzip

3. Make sure that 'lib/data' directory was created in your rails app, the plugin stores the json data file there. 

4. Edit the rake task file and replace the dummy value for license key with your own key. You need to register with 
deviceatlas.com

5. run the rake task 'deviceatlas_update', which will download the latest json data file from deviceatlas.com

6. include ActsAsDeviceAware in your desired controller, for example like this:
  class WelcomeController < ApplicationController
    include ActsAsDeviceAware
  
7. Format you views given the known device properties using the variable @device_atlas_data, for example
  <% if !@device_atlas_data["vendor"].nil? &&  
      !@device_atlas_data["developerPlatformVersion"].nil? && 
       @device_atlas_data["vendor"] == 'Sony Ericsson' && 
       @device_atlas_data["developerPlatformVersion"].to_f >= 7 %>
    <p>Your using a Sony Ericsson that can determine its cell tower data in j2me.</p>
  <% end %>

Copyright (c) 2008-2009 lastminute.com , released under the MIT license