Ewigkeks
Ewigkeks is a library for integrating the evercookie JavaScript library into your Rails application. It saves and retrieves key-value-pairs in different client/browser storages.
Requirements
- Ruby ≥ 1.9.3
- Rails ~> 4.0
Installation
Add this line to your application's Gemfile:
gem 'ewigkeks'
execute:
$ bundle install
and run:
$ bin/rails generate ewigkeks:install
Usage
In order to set an evercookie, call this JavaScript in your view:
var evercookie = new <%= Ewigkeks.js_class %>();
evercookie.set('foo', 'bar');
This evercookie is accessible later on by using the get
function:
var evercookie = new <%= Ewigkeks.js_class %>();
evercookie.get('foo', function(value) {
// do something with the value
});
Per default, evercookie will repopulate missing key-value-pairs to the client/browser storages when calling the get
function. If you explicitely do not want this behaviour, call get
with an additional argument like this:
var evercookie = new <%= Ewigkeks.js_class %>();
evercookie.get('foo', function(value) {
// do something with the value
}, 1);
1
tells evercookie to not repopulate, 0 tells it to repopulate (default).
Optional Configuration
When running the install generator, Ewigkeks will add an initializer to your Rails application with several configuration options:
Option | Default | Meaning |
---|---|---|
js_class |
'evercookie' |
Changes the evercookie function name inside the JavaScript library |
scope |
'ewigkeks' |
Changes the route under which the Ewigkeks controller gets called |
png_cookie_name |
"#{js_class}_png" |
Changes the cookie name for the PNG storage |
cache_cookie_name |
"#{js_class}_cache" |
Changes the cookie name for the Cache storage |
etag_cookie_name |
"#{js_class}_etag" |
Changes the cookie name for the ETAG storage |
License
Copyright 2015 VersaCommerce
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.