zookeeper-hd
Advanced tools
Comparing version 0.3.3 to 0.3.4
// This file has been generated from coffee source files | ||
var SimpleClient, Zookeeper, normalizeCallBack, path, _; | ||
var SimpleClient, Zookeeper, normalizeCallBack, _; | ||
Zookeeper = require('zookeeper'); | ||
path = require('path'); | ||
_ = require('underscore'); | ||
@@ -30,3 +28,3 @@ | ||
this.client = new Zookeeper(options); | ||
this.root = options.root || ''; | ||
this.root = options.root || '/'; | ||
} | ||
@@ -43,10 +41,11 @@ | ||
SimpleClient.prototype.joinPath = function(base, extra) { | ||
extra = extra || ''; | ||
if (_.isArray(base)) { | ||
base = path.join.apply(this, _.flatten(base)); | ||
var all; | ||
all = []; | ||
if (base) { | ||
all.push(base); | ||
} | ||
if (_.isArray(extra)) { | ||
extra = path.join.apply(this, _.flatten(extra)); | ||
if (extra) { | ||
all.push(extra); | ||
} | ||
return path.join(base, extra); | ||
return (_.flatten(all)).join('/').replace('///', '/').replace('//', '/'); | ||
}; | ||
@@ -53,0 +52,0 @@ |
@@ -37,3 +37,3 @@ // This file has been generated from coffee source files | ||
client.should.exist; | ||
return client.root.should.equal(''); | ||
return client.root.should.equal('/'); | ||
}); | ||
@@ -44,3 +44,3 @@ it('has a zookeeper client', function() { | ||
client.client.should.be["instanceof"](zookeeperStub.Client); | ||
return client.root.should.equal(''); | ||
return client.root.should.equal('/'); | ||
}); | ||
@@ -72,4 +72,4 @@ return it('can have a root', function() { | ||
}); | ||
return it('return the exact path if no root and path is without leading slash', function() { | ||
return clientWithoutRoot.fullPath('somePath').should.equal('somePath'); | ||
return it('return the absolute path if no root given and path is without leading slash', function() { | ||
return clientWithoutRoot.fullPath('somePath').should.equal('/somePath'); | ||
}); | ||
@@ -108,5 +108,8 @@ }); | ||
}); | ||
return it('accepts nested arrays as arguments', function() { | ||
it('accepts nested arrays as arguments', function() { | ||
return client.joinPath(['base', ['path']], [['too']]).should.equal('base/path/too'); | ||
}); | ||
return it('accepts an array as 2nd argument with first empty', function() { | ||
return client.joinPath('', ['extra', 'path']).should.equal('extra/path'); | ||
}); | ||
}); | ||
@@ -113,0 +116,0 @@ describe('#create', function() { |
{ | ||
"name": "zookeeper-hd", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Higher level (normalized) zookeeper client", | ||
@@ -5,0 +5,0 @@ "author": "Hans Donner", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
243078
2028