migrating repo to Bodyrep org

This commit is contained in:
2013-01-19 11:23:43 -05:00
parent 31b7303f43
commit 4ea082330b
891 changed files with 142706 additions and 0 deletions

2
node_modules/mongoose/node_modules/muri/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,2 @@
*.sw*
node_modules/

4
node_modules/mongoose/node_modules/muri/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- 0.6
- 0.8

32
node_modules/mongoose/node_modules/muri/History.md generated vendored Normal file
View File

@@ -0,0 +1,32 @@
0.1.0 / 2012-12-18
==================
* changed; include .sock in UDS
0.0.5 / 2012-12-18
==================
* fixed; unix domain sockets used with db names
0.0.4 / 2012-12-01
==================
* handle multple specified protocols
0.0.3 / 2012-11-29
==================
* validate mongodb:///db
* more detailed error message
0.0.2 / 2012-11-02
==================
* add readPreferenceTags support
* add unix domain support
0.0.1 / 2012-11-01
==================
* initial release

22
node_modules/mongoose/node_modules/muri/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2012 [Aaron Heckmann](aaron.heckmann+github@gmail.com)
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.

5
node_modules/mongoose/node_modules/muri/Makefile generated vendored Normal file
View File

@@ -0,0 +1,5 @@
test:
@node_modules/mocha/bin/mocha $(T)
.PHONY: test

46
node_modules/mongoose/node_modules/muri/README.md generated vendored Normal file
View File

@@ -0,0 +1,46 @@
#Meet Muri!
Muri is your friendly neighborhood [MongoDB URI](http://www.mongodb.org/display/DOCS/Connections) parser for Node.js.
###Install
$ npm install muri
###Use
```js
var muri = require('muri');
var o = muri('mongodb://user:pass@local,remote:27018,japan:27019/neatdb?replicaSet=myreplset&journal=true&w=2&wtimeoutMS=50');
console.log(o);
{ hosts: [ { host: 'local', port: 27017 },
{ host: 'remote', port: 27018 },
{ host: 'japan', port: 27019 } ],
db: 'neatdb',
options: {
replicaSet: 'myreplset',
journal: true,
w: 2,
wtimeoutMS: 50
},
auth: {
user: 'user',
pass: 'pass'
}
}
```
### Details
The returned object contains the following properties:
- db: the name of the database. defaults to "admin" if not specified
- auth: if auth is specified, this object will exist `{ user: 'username', pass: 'password' }`
- hosts: array of host/port objects, one for each specified `[{ host: 'local', port: 27107 }, { host: '..', port: port }]`
- if a port is not specified for a given host, the default port (27017) is used
- if a unix domain socket is passed, host/port will be undefined and `ipc` will be set to the value specified `[{ ipc: '/tmp/mongodb-27017' }]`
- options: this is a hash of all options specified in the querystring
[LICENSE](https://github.com/aheckmann/muri/blob/master/LICENSE)

1
node_modules/mongoose/node_modules/muri/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = exports = require('./lib');

184
node_modules/mongoose/node_modules/muri/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,184 @@
// muri
/**
* MongoDB URI parser as described here:
* http://www.mongodb.org/display/DOCS/Connections
*/
/**
* Module dependencies
*/
var url = require('url');
var qs = require('querystring');
/**
* Defaults
*/
const DEFAULT_PORT = 27017;
const DEFAULT_DB = 'admin';
/**
* Muri
*/
module.exports = exports = function muri (str) {
if (!/^mongodb:\/\//.test(str)) {
throw new Error('Invalid mongodb uri. Must begin with "mongodb://"'
+ '\n Received: ' + str);
}
var ret = {
hosts: []
, db: 'admin'
, options: {}
}
var match = /^mongodb:\/\/([^?]+)(\??.*)$/.exec(str);
if (!match || '/' == match[1]) {
throw new Error('Invalid mongodb uri. Missing hostname');
}
var uris = match[1];
var path = match[2];
var db;
uris.split(',').forEach(function (uri) {
if (!/^mongodb:\/\//.test(uri)) {
uri = 'mongodb://' + uri;
}
var o = url.parse(uri);
if (o.hostname) {
ret.hosts.push({
host: o.hostname
, port: parseInt(o.port || DEFAULT_PORT, 10)
})
if (!db && o.pathname) {
db = o.pathname.replace(/^\//, '');
}
} else {
var domain = /(.+\.sock)(\/?.*)$/.exec(o.pathname);
if (domain && domain[1]) {
ret.hosts.push({ ipc: domain[1] });
}
}
if (o.auth) {
var auth = o.auth.split(':');
ret.auth = {
user: auth[0]
, pass: auth[1]
}
}
})
if (!ret.hosts.length) {
throw new Error('Invalid mongodb uri. Missing hostname');
}
var parts = path.split('?');
if (!db) {
if (parts[0]) {
db = parts[0].replace(/^\//, '');
} else {
// deal with ipc formats
db = /\/([^\.]+)$/.exec(match[1]);
if (db && db[1]) {
db = db[1];
}
}
}
if (db) {
ret.db = db;
}
if (parts[1]) {
ret.options = options(parts[1]);
}
return ret;
}
/**
* Parse str into key/val pairs casting values appropriately.
*/
function options (str) {
var sep = /;/.test(str)
? ';'
: '&';
var ret = qs.parse(str, sep);
Object.keys(ret).forEach(function (key) {
var val = ret[key];
if ('readPreferenceTags' == key) {
val = readPref(val);
if (val) {
ret[key] = Array.isArray(val)
? val
: [val];
}
} else {
ret[key] = format(val);
}
});
return ret;
}
function format (val) {
var num;
if ('true' == val) {
return true;
} else if ('false' == val) {
return false;
} else {
num = parseInt(val, 10);
if (!isNaN(num)) {
return num;
}
}
return val;
}
function readPref (val) {
var ret;
if (Array.isArray(val)) {
ret = val.map(readPref).filter(Boolean);
return ret.length
? ret
: undefined
}
var pair = val.split(',');
var hasKeys;
ret = {};
pair.forEach(function (kv) {
kv = (kv || '').trim();
if (!kv) return;
hasKeys = true;
var split = kv.split(':');
ret[split[0]] = format(split[1]);
});
return hasKeys && ret;
}
/**
* Version
*/
module.exports.version = JSON.parse(
require('fs').readFileSync(__dirname + '/../package.json', 'utf8')
).version;

33
node_modules/mongoose/node_modules/muri/package.json generated vendored Normal file
View File

@@ -0,0 +1,33 @@
{
"name": "muri",
"version": "0.1.0",
"description": "MongoDB URI parser",
"main": "index.js",
"scripts": {
"test": "make test"
},
"repository": {
"type": "git",
"url": "git://github.com/aheckmann/muri.git"
},
"keywords": [
"mongodb",
"uri",
"parser"
],
"author": {
"name": "Aaron Heckmann",
"email": "aaron.heckmann+github@gmail.com"
},
"license": "MIT",
"devDependencies": {
"mocha": "1.6.0"
},
"readme": "#Meet Muri!\n\nMuri is your friendly neighborhood [MongoDB URI](http://www.mongodb.org/display/DOCS/Connections) parser for Node.js.\n\n\n###Install\n\n $ npm install muri\n\n###Use\n\n```js\n var muri = require('muri');\n var o = muri('mongodb://user:pass@local,remote:27018,japan:27019/neatdb?replicaSet=myreplset&journal=true&w=2&wtimeoutMS=50');\n\n console.log(o);\n\n { hosts: [ { host: 'local', port: 27017 },\n { host: 'remote', port: 27018 },\n { host: 'japan', port: 27019 } ],\n db: 'neatdb',\n options: {\n replicaSet: 'myreplset',\n journal: true,\n w: 2,\n wtimeoutMS: 50\n },\n auth: {\n user: 'user',\n pass: 'pass'\n }\n }\n```\n\n### Details\n\nThe returned object contains the following properties:\n\n- db: the name of the database. defaults to \"admin\" if not specified\n- auth: if auth is specified, this object will exist `{ user: 'username', pass: 'password' }`\n- hosts: array of host/port objects, one for each specified `[{ host: 'local', port: 27107 }, { host: '..', port: port }]`\n - if a port is not specified for a given host, the default port (27017) is used\n - if a unix domain socket is passed, host/port will be undefined and `ipc` will be set to the value specified `[{ ipc: '/tmp/mongodb-27017' }]`\n- options: this is a hash of all options specified in the querystring\n\n[LICENSE](https://github.com/aheckmann/muri/blob/master/LICENSE)\n",
"readmeFilename": "README.md",
"_id": "muri@0.1.0",
"dist": {
"shasum": "bd5863132bd9dffe78992ec497c1da6e283a343a"
},
"_from": "muri@0.1.0"
}

294
node_modules/mongoose/node_modules/muri/test/index.js generated vendored Normal file
View File

@@ -0,0 +1,294 @@
var muri = require('../')
var assert = require('assert')
describe('muri', function(){
it('must begin with mongodb://', function(done){
assert.throws(function () {
muri('localhost:27017');
}, /Invalid mongodb uri/);
assert.doesNotThrow(function () {
muri('mongodb://localhost:27017');
})
done();
})
describe('user:password', function(done){
it('is optional', function(done){
var uri = 'mongodb://local:27017';
var val = muri(uri);
assert.ok(!val.auth);
done();
})
it('parses properly', function(done){
var uri = 'mongodb://user:password@local:27017';
var val = muri(uri);
assert.ok(val.auth);
assert.equal('user', val.auth.user);
assert.equal('password', val.auth.pass);
done();
})
})
describe('host', function(){
it('must be specified', function(done){
assert.throws(function () {
muri('mongodb://');
}, /Missing host/)
assert.throws(function () {
muri('mongodb:///fake');
}, /Missing host/)
assert.throws(function () {
muri('mongodb://?yep');
}, /Missing host/)
assert.throws(function () {
muri('mongodb:///?yep');
}, /Missing host/)
var val = muri('mongodb://local');
assert.ok(Array.isArray(val.hosts));
assert.equal(1, val.hosts.length);
assert.equal('local', val.hosts[0].host);
done();
})
it('supports replica sets', function(done){
var val = muri('mongodb://local:27017,remote:27018,japan:99999');
assert.ok(Array.isArray(val.hosts));
assert.equal(3, val.hosts.length);
assert.equal('local', val.hosts[0].host);
assert.equal(27017, val.hosts[0].port);
assert.equal('remote', val.hosts[1].host);
assert.equal(27018, val.hosts[1].port);
assert.equal('japan', val.hosts[2].host);
assert.equal(99999, val.hosts[2].port);
done();
})
})
describe('port', function(){
describe('with single host', function(){
it('defaults to 27017 if not specified', function(done){
var val = muri('mongodb://local/');
assert.equal(27017, val.hosts[0].port);
done();
})
it('uses what is specified', function(done){
var val = muri('mongodb://local:27018');
assert.equal(27018, val.hosts[0].port);
done();
})
})
describe('with replica sets', function(){
var val;
before(function(){
val = muri('mongodb://local,remote:27018,another');
})
it('defaults to 27017 if not specified', function(done){
assert.equal(27017, val.hosts[0].port);
assert.equal(27017, val.hosts[2].port);
done();
})
it('uses what is specified', function(done){
assert.equal(27018, val.hosts[1].port);
done();
})
})
})
describe('database', function(){
it('defaults to admin', function(done){
var val = muri('mongodb://localhost/');
assert.equal('admin', val.db);
var val = muri('mongodb://localhost');
assert.equal('admin', val.db);
done();
})
it('is overridable', function(done){
var val = muri('mongodb://localhost,a,x:34343,b/muri');
assert.equal('muri', val.db);
done();
})
it('works with multiple specified protocols', function(done){
var uri = 'mongodb://localhost:27020/testing,mongodb://localhost:27019,mongodb://localhost:27018'
var val = muri(uri);
assert.equal('testing', val.db);
done();
})
})
describe('querystring separator', function(){
it('can be ; ', function(done){
var val = muri('mongodb://muri/?replicaSet=myreplset;slaveOk=true;x=1');
assert.ok(val.options);
assert.equal(true, val.options.slaveOk);
assert.equal('myreplset', val.options.replicaSet);
assert.equal(1, val.options.x);
done();
})
it('can be & ', function(done){
var val = muri('mongodb://muri/?replicaSet=myreplset&slaveOk=true&x=1');
assert.ok(val.options);
assert.equal(true, val.options.slaveOk);
assert.equal('myreplset', val.options.replicaSet);
assert.equal(1, val.options.x);
done();
})
})
describe('readPref tags', function(){
describe('with & ', function(){
it('mongodb://localhost/?readPreferenceTags=dc:ny', function(done){
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny');
assert.equal('admin', val.db);
assert.deepEqual([{ dc: 'ny' }], val.options.readPreferenceTags);
done();
})
it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1', function(done){
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1');
assert.deepEqual([{ dc: 'ny', rack: 1 }], val.options.readPreferenceTags);
done();
})
it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2', function(done){
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2');
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
done();
})
it('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2&readPreferenceTags=', function(done){
var val = muri('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2&readPreferenceTags=');
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
done();
})
it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:ny&readPreferenceTags=', function(done){
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:ny&readPreferenceTags=');
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'ny' }], val.options.readPreferenceTags);
done();
})
})
describe('with ; ', function(){
it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2', function(done){
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2');
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
done();
})
it('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2;readPreferenceTags=', function(done){
var val = muri('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2;readPreferenceTags=');
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
done();
})
it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:ny;readPreferenceTags=', function(done){
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:ny;readPreferenceTags=');
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'ny' }], val.options.readPreferenceTags);
done();
})
})
})
describe('unix domain sockets', function(){
it('without auth', function(done){
var val = muri('mongodb:///tmp/mongodb-27017.sock?safe=false');
assert.equal(val.db, 'admin')
assert.ok(Array.isArray(val.hosts));
assert.equal(1, val.hosts.length);
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
assert.equal(val.hosts[0].host, undefined);
assert.equal(val.hosts[0].port, undefined);
assert.equal(false, val.options.safe);
done();
})
it('without auth with a database name', function(done){
var val = muri('mongodb:///tmp/mongodb-27017.sock/test?safe=false');
assert.equal(val.db, 'test')
assert.ok(Array.isArray(val.hosts));
assert.equal(1, val.hosts.length);
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
assert.equal(val.hosts[0].host, undefined);
assert.equal(val.hosts[0].port, undefined);
assert.equal(false, val.options.safe);
done();
})
it('with auth', function(done){
var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock?safe=false');
assert.equal(val.db, 'admin')
assert.ok(Array.isArray(val.hosts));
assert.equal(1, val.hosts.length);
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
assert.equal(val.hosts[0].host, undefined);
assert.equal(val.hosts[0].port, undefined);
assert.equal(false, val.options.safe);
done();
})
it('with auth with a db name', function(done){
var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock/test?safe=false');
assert.equal(val.db, 'test')
assert.ok(Array.isArray(val.hosts));
assert.equal(1, val.hosts.length);
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
assert.equal(val.hosts[0].host, undefined);
assert.equal(val.hosts[0].port, undefined);
assert.equal(false, val.options.safe);
done();
})
it('with auth + repl sets', function(done){
var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock,/tmp/another-27018.sock?safe=false');
assert.equal(val.db, 'admin')
assert.ok(Array.isArray(val.hosts));
assert.equal(2, val.hosts.length);
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
assert.equal(val.hosts[0].host, undefined);
assert.equal(val.hosts[0].port, undefined);
assert.equal(val.hosts[1].ipc, '/tmp/another-27018.sock')
assert.equal(val.hosts[1].host, undefined);
assert.equal(val.hosts[1].port, undefined);
assert.equal(false, val.options.safe);
done();
})
it('with auth + repl sets with a db name', function(done){
var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock,/tmp/another-27018.sock/test?safe=false');
assert.equal(val.db, 'test')
assert.ok(Array.isArray(val.hosts));
assert.equal(2, val.hosts.length);
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
assert.equal(val.hosts[0].host, undefined);
assert.equal(val.hosts[0].port, undefined);
assert.equal(val.hosts[1].ipc, '/tmp/another-27018.sock')
assert.equal(val.hosts[1].host, undefined);
assert.equal(val.hosts[1].port, undefined);
assert.equal(false, val.options.safe);
done();
})
})
it('all together now', function(done){
var uri = 'mongodb://user:pass@local,remote:27018,japan:27019/neatdb'
uri += '?replicaSet=myreplset&journal=true&w=2&wtimeoutMS=50'
var val = muri(uri);
assert.equal('user', val.auth.user);
assert.equal('pass', val.auth.pass);
assert.equal('neatdb', val.db);
assert.equal(3, val.hosts.length);
assert.equal('local', val.hosts[0].host);
assert.strictEqual(27017, val.hosts[0].port);
assert.equal('remote', val.hosts[1].host);
assert.strictEqual(27018, val.hosts[1].port);
assert.equal('japan', val.hosts[2].host);
assert.strictEqual(27019, val.hosts[2].port);
assert.equal('myreplset', val.options.replicaSet);
assert.equal(true, val.options.journal);
assert.equal(50, val.options.wtimeoutMS);
done();
})
it('has a version', function(done){
assert.ok(muri.version);
done();
})
})