-
Notifications
You must be signed in to change notification settings - Fork 4
/
README
58 lines (33 loc) · 2.63 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
rails_cache_wurfl
This plugin combines the persistence and quick access of memcachedb (http://www.memcachedb.org) with the WURFL (http://wurfl.sourceforge.net) to allow your Rails views to easily access the capabilities of the current user's handset or browsing device. The plugin uses Rails' built-in cache access functionality to access memcachedb through a memcached interface. Rake tasks are provided to download and uncompress the latest WURFL as well as update and/or populate your memcachedb with a new WURFL, even while your app is running.
Even though you could theoretically use memcached instead of memcachedb, you shouldn’t! You couldn’t use that instance for anything but the WURFL, because unused key-value pairs will be thrown out when there is no room for them and your lookups will start failing. Due to the (appropriate) behavior of memcached, you will not be notified! Memcachedb alleviates this problem because it will not throw out data without specifically being told to. Another advantage that you will lose if you use memcached is startup time; your server (or one process of your server cluster) will spend around a minute loading the WURFL from xml into the cache each time the memcached instance is restarted.
So: DON’T use memcached instead of memcachedb!!!
You could also theoretically use Tokyo Cabinet/Tyrant or any other persistent key-value datastore with a memcached interface, though I haven't tested it.
This plugin is best used if you already know a user is on a mobile phone. Other plugins handle this well. The WURFL doesn’t seem to report accurate capabilities for desktop web browsers.
Dependencies
Nokogiri, RSpec (if you wish to run the tests)
Install
script/plugin install git://github.com/antipax/rails_cache_wurfl.git
(If your memcachedb (or whatever memcached interfaced datastore you use) isn't running at localhost:21201, go to rails_cache_wurfl/lib/rails_cache_wurfl.rb and change the obvious-looking constant at the top to point to it.)
rake wurfl:update
rake wurfl:cache_update
If you want to download the latest wurfl.xml and update the cache in place:
rake wurfl:update
rake wurfl:cache_update
Example
In ApplicationController.rb (or wherever you're going to use WURFL):
before_filter :set_wurfl
In your views:
<% if handset_capability('mp3') %>
<%= link_for_mp3 %>
<% end %>
License
MIT license for original code.
Authors
Eric Entin (eric@socialight.com)
Contact
Eric Entin (eric@socialight.com)
Download
You can clone the project with Git by running:
$ git clone git://github.com/antipax/rails_cache_wurfl.git
Original Code: Copyright (c) 2009 Socialight, released under the MIT license