Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rename to yar

  • Loading branch information...
commit 69e1710ac44f14aeb1c6c334e3467276f60d4e43 1 parent 3473dd2
@hueniverse hueniverse authored
View
18 README.md
@@ -1,27 +1,27 @@
<a href="https://github.com/walmartlabs/blammo"><img src="https://raw.github.com/walmartlabs/blammo/master/images/from.png" align="right" /></a>
-![jar Logo](/images/jar.png)
+![yar Logo](https://raw.github.com/walmartlabs/yar/master/images/yar.png)
A [**hapi**](https://github.com/walmartlabs/hapi) cookie jar
-[![Build Status](https://secure.travis-ci.org/walmartlabs/jar.png)](http://travis-ci.org/walmartlabs/jar)
+[![Build Status](https://secure.travis-ci.org/walmartlabs/yar.png)](http://travis-ci.org/walmartlabs/yar)
-The jar plugin adds a simple was to set a persistant state (using an [Iron](https://github.com/hueniverse/iron) encrypted cookie) across requests.
+The ***yar*** plugin adds a simple was to set a persistant state (using an [Iron](https://github.com/hueniverse/iron) encrypted cookie) across requests.
It is not designed for session management but to supplement an active session with transactional information.
-For example, the first handler sets the jar context and the second utilizes it:
+For example, the first handler sets the jar content and the second utilizes it:
```javascript
var handler1 = function () {
- this.plugins.jar = {
+ this.plugins.yar = {
key: 'value'
};
-
+
return this.reply();
};
var handler2 = function () {
- this.reply(this.plugins.jar.key); // Will send back 'value'
+ this.reply(this.state.yar.key); // Will send back 'value'
};
```
@@ -32,7 +32,7 @@ var options = {
ext: true // Required
},
plugin: {
- name: 'jar' , // Optional, overrides cookie name. Defaults to 'jar'. Doesn't affect 'plugins.jar'.
+ name: 'yar' , // Optional, overrides cookie name. Defaults to 'yar'. Doesn't affect 'plugins.yar'.
isSingleUse: false, // Optional, clears jar after one request. Defaults to false.
options: {
password: 'password', // Required
@@ -43,5 +43,5 @@ var options = {
var server = new Hapi.Server();
-server.plugin().require('hapi-jar', options, function (err) { });
+server.plugin().require('yar', options, function (err) { });
```
View
BIN  images/jar.png
Deleted file not rendered
View
BIN  images/yar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
10 lib/index.js
@@ -8,7 +8,7 @@ var Hoek = require('hoek');
var internals = {};
internals.config = {
- name: 'jar',
+ name: 'yar',
isSingleUse: false, // Cleared after every request, unless modified
options: { // hapi server.state() options, except 'encoding' which is always 'iron'. 'password' required.
path: '/'
@@ -31,8 +31,8 @@ exports.register = function (pack, options, next) {
internals.onPreHandler = function (request, next) {
- request.state.jar = request.state.jar || {};
- request.plugins.jar = {};
+ request.state.yar = request.state.yar || {};
+ request.plugins.yar = {};
if (internals.config.isSingleUse) {
request.clearState(internals.config.name);
@@ -44,8 +44,8 @@ internals.onPreHandler = function (request, next) {
internals.onPostHandler = function (request, next) {
- if (Object.keys(request.plugins.jar).length) {
- request.setState(internals.config.name, request.plugins.jar);
+ if (Object.keys(request.plugins.yar).length) {
+ request.setState(internals.config.name, request.plugins.yar);
}
next();
View
8 package.json
@@ -1,10 +1,10 @@
{
- "name": "hapi-jar",
+ "name": "yar",
"description": "Cookie jar plugin",
- "version": "0.0.5",
+ "version": "0.0.1",
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)",
"contributors": [],
- "repository": "git://github.com/walmartlabs/jar",
+ "repository": "git://github.com/walmartlabs/yar",
"main": "index",
"keywords": [
"hapi",
@@ -30,7 +30,7 @@
"licenses": [
{
"type": "BSD",
- "url": "http://github.com/hueniverse/jar/raw/master/LICENSE"
+ "url": "http://github.com/walmartlabs/yar/raw/master/LICENSE"
}
],
"hapi": {
View
16 test/index.js
@@ -2,7 +2,7 @@
var Chai = require('chai');
var Hapi = require('hapi');
-var Jar = process.env.TEST_COV ? require('../lib-cov') : require('../lib');
+var Yar = process.env.TEST_COV ? require('../lib-cov') : require('../lib');
// Declare internals
@@ -15,20 +15,20 @@ var internals = {};
var expect = Chai.expect;
-describe('Jar', function () {
+describe('Yar', function () {
// Wrapper is required for coverage
var plugin = {
- name: 'jar',
+ name: 'yar',
version: Hapi.utils.loadPackage().version,
hapi: {
plugin: '1.x.x'
},
- register: Jar.register
+ register: Yar.register
};
- it('sets jar then gets it back', function (done) {
+ it('sets yar then gets it back', function (done) {
var options = {
permissions: {
@@ -51,8 +51,8 @@ describe('Jar', function () {
method: 'GET', path: '/1', handler: function () {
expect(this.state.jarx).to.not.exist;
- expect(this.plugins.jar).to.deep.equal({});
- this.plugins.jar.some = { value: 123 };
+ expect(this.plugins.yar).to.deep.equal({});
+ this.plugins.yar.some = { value: 123 };
return this.reply('1');
}
},
@@ -60,7 +60,7 @@ describe('Jar', function () {
method: 'GET', path: '/2', handler: function () {
expect(this.state.jarx).to.deep.equal({ some: { value: 123 } });
- expect(this.plugins.jar).to.deep.equal({});
+ expect(this.plugins.yar).to.deep.equal({});
return this.reply('2');
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.