1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-12 10:52:47 +00:00

updated package.json

This commit is contained in:
2016-01-04 12:25:28 -05:00
parent 3443c97de4
commit 80ca24a715
1168 changed files with 73752 additions and 26424 deletions

4
node_modules/broadway/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,4 @@
node_modules
npm-debug.log
.DS_Store

10
node_modules/broadway/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,10 @@
language: node_js
node_js:
- "0.8"
- "0.10"
notifications:
email:
- travis@nodejitsu.com
irc: "irc.freenode.org#nodejitsu"

19
node_modules/broadway/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2011 Nodejitsu Inc.
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.

124
node_modules/broadway/README.md generated vendored Normal file
View File

@@ -0,0 +1,124 @@
# broadway [![Build Status](https://secure.travis-ci.org/flatiron/broadway.png)](http://travis-ci.org/flatiron/broadway)
*Lightweight application extensibility and composition with a twist of feature
reflection.*
## Example
### app.js
```js
var broadway = require("broadway");
var app = new broadway.App();
// Passes the second argument to `helloworld.attach`.
app.use(require("./plugins/helloworld"), { "delimiter": "!" } );
app.init(function (err) {
if (err) {
console.log(err);
}
});
app.hello("world");
```
### plugins/helloworld.js
```js
// `exports.attach` gets called by broadway on `app.use`
exports.attach = function (options) {
this.hello = function (world) {
console.log("Hello "+ world + options.delimiter || ".");
};
};
// `exports.init` gets called by broadway on `app.init`.
exports.init = function (done) {
// This plugin doesn't require any initialization step.
return done();
};
```
### run it!
```bash
josh@onix:~/dev/broadway/examples$ node simple/app.js
Hello world!
josh@onix:~/dev/broadway/examples$
```
## Installation
### Installing npm (node package manager)
``` bash
$ curl http://npmjs.org/install.sh | sh
```
### Installing broadway
``` bash
$ [sudo] npm install broadway
```
## API
### App#init(callback)
Initialize application and it's plugins, `callback` will be called with null or
initialization error as first argument.
### App#use(plugin, options)
Attach plugin to application. `plugin` should conform to following interface:
```javascript
var plugin = {
"name": "example-plugin", // Plugin's name
"attach": function attach(options) {
// Called with plugin options once plugin attached to application
// `this` - is a reference to application
},
"detach": function detach() {
// Called when plugin detached from application
// (Only if plugin with same name was attached)
// `this` - is a reference to application
},
"init": function init(callback) {
// Called on application initialization
// App#init(callback) will be called once every plugin will call `callback`
// `this` - is a reference to application
}
};
```
### App#on(event, callback) and App#emit(event, data)
App inherits from [EventEmitter2][2], and many plugins build on this
functionality.
#### Built-In Events:
* `error:init`: Broadway emits this event when it throws an error while attempting to initialize.
Read the [EventEmitter2][2] documentation for more information.
## Tests
All tests are written with [vows][0] and should be run with [npm][1]:
``` bash
$ npm test
```
#### [Charlie Robbins](http://nodejitsu.com)
#### License: MIT
[0]: http://vowsjs.org
[1]: http://npmjs.org
[2]: https://github.com/hij1nx/EventEmitter2

66
node_modules/broadway/bin/build generated vendored Executable file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env node
var Codesurgeon = require('codesurgeon').Codesurgeon;
var surgeon = new Codesurgeon;
var path = require('path');
var root = path.join(__dirname, '..');
var lib = path.join(root, 'lib', 'broadway');
//
// Distill and package the browser version.
//
surgeon
//
.configure({
package: root + '/package.json',
owner: 'Nodejitsu, Inc (Using Codesurgeon).'
})
.read(
path.join(root, 'node_modules', 'eventemitter2', 'lib', 'eventemitter2.js'),
path.join(lib, 'browser.js')
)
//
// we want everything so far. specify extract with no
// parameters to get everything into the output buffer.
//
.extract()
//
// clear the input so far, but don't clear the output.
//
.clear('inputs')
//
// read the `app.js` file
//
.read(
path.join(lib, 'app.js')
)
//
// the current input buffer contains stuff that we dont
// want in the browser build, so let's cherry pick from
// the buffer.
//
.extract(
'App.prototype.init',
'App.prototype.use',
'App.prototype.remove',
'App.prototype.inspect'
)
//
// wrap everything that is in the current buffer with a
// closure so that we dont get any collisions with other
// libraries
//
.wrap()
//
// write the debuggable version of the file. This file will
// get renamed to include the version from the package.json
//
.write(root + '/build/broadway.js')
//
// now lets make a minified version for production use.
//
.uglify()
.write(root + '/build/broadway.min.js')
;

12
node_modules/broadway/examples/browser/app.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
var app = new App();
app.use(HelloWorld, { "delimiter": "!" } );
app.init(function (err) {
if (err) {
console.log(err);
}
});
app.hello("world");

11
node_modules/broadway/examples/browser/index.html generated vendored Normal file
View File

@@ -0,0 +1,11 @@
<html>
<head>
<title>Example</title>
</head>
<body>
<script type="text/javascript" src="broadway.js"></script>
<script type="text/javascript" src="plugins/helloworld.js"></script>
<script type="text/javascript" src="app.js"></script>
</body>
</html>

View File

@@ -0,0 +1,23 @@
window.HelloWorld = {};
//
// `exports.attach` gets called by broadway on `app.use`
//
HelloWorld.attach = function (options) {
this.hello = function (world) {
console.log("Hello "+ world + options.delimiter || ".");
}
};
//
// `exports.init` gets called by broadway on `app.init`.
//
HelloWorld.init = function (done) {
//
// This plugin doesn't require any initialization step.
//
return done();
};

17
node_modules/broadway/examples/nodejs/app.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
var broadway = require('../../'),
app = new broadway.App();
// Passes the second argument to `helloworld.attach`.
app.use(require("./plugins/helloworld"), { "delimiter": "!" } );
app.use(broadway.plugins.log, {
logAll: true
});
app.init(function (err) {
if (err) {
console.log(err);
}
});
app.hello("world");
app.emit('world:hello', { meta: 'is here' });

View File

@@ -0,0 +1,23 @@
var HelloWorld = exports;
//
// `exports.attach` gets called by broadway on `app.use`
//
HelloWorld.attach = function (options) {
this.hello = function (world) {
console.log("Hello "+ world + options.delimiter || ".");
}
};
//
// `exports.init` gets called by broadway on `app.init`.
//
HelloWorld.init = function (done) {
//
// This plugin doesn't require any initialization step.
//
return done();
};

19
node_modules/broadway/lib/broadway.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/*
* broadway.js: Top-level include for the broadway module.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var path = require('path'),
utile = require('utile');
var broadway = exports;
broadway.App = require('./broadway/app').App;
broadway.common = require('./broadway/common');
broadway.features = require('./broadway/features');
broadway.formats = require('nconf').formats;
broadway.plugins = utile.requireDirLazy(path.join(__dirname, 'broadway', 'plugins'));

225
node_modules/broadway/lib/broadway/app.js generated vendored Normal file
View File

@@ -0,0 +1,225 @@
/*
* app.js: Core Application object for managing plugins and features in broadway
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var utile = require('utile'),
async = utile.async,
events = require('eventemitter2'),
bootstrapper = require('./bootstrapper'),
common = require('./common'),
features = require('./features');
var App = exports.App = function (options) {
//
// Setup options and `App` constants.
//
options = options || {};
this.root = options.root;
this.delimiter = options.delimiter || '::';
//
// Inherit from `EventEmitter2`
//
events.EventEmitter2.call(this, {
delimiter: this.delimiter,
wildcard: true
});
//
// Setup other relevant options such as the plugins
// for this instance.
//
this.options = options;
this.env = options.env || process.env['NODE_ENV'] || 'development'
this.plugins = options.plugins || {};
this.initialized = false;
this.bootstrapper = options.bootstrapper || bootstrapper;
this.initializers = {};
this.initlist = [];
//
// Bootstrap this instance
//
this.bootstrapper.bootstrap(this);
};
//
// Inherit from `EventEmitter2`.
//
utile.inherits(App, events.EventEmitter2);
//
// ### function init (options, callback)
// #### @options {Object} **Optional** Additional options to initialize with.
// #### @callback {function} Continuation to respond to when complete.
// Initializes this instance by the following procedure:
//
// 1. Initializes all plugins (starting with `core`).
// 2. Creates all directories in `this.config.directories` (if any).
// 3. Ensures the files in the core directory structure conform to the
// features required by this application.
//
App.prototype.init = function (options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
if (this.initialized) {
return callback();
}
var self = this;
options = options || {};
callback = callback || function () {};
this.env = options.env || this.env;
this.options = common.mixin({}, this.options, options);
function onComplete() {
self.initialized = true;
self.emit('init');
callback();
}
function ensureFeatures (err) {
return err
? onError(err)
: features.ensure(this, onComplete);
}
function initPlugin(plugin, next) {
if (typeof self.initializers[plugin] === 'function') {
return self.initializers[plugin].call(self, function (err) {
if (err) {
return next(err);
}
self.emit(['plugin', plugin, 'init']);
self.initializers[plugin] = true;
next();
});
}
next();
}
function initPlugins() {
async.forEach(self.initlist, initPlugin, ensureFeatures);
}
//
// Emit and respond with any errors that may short
// circuit the process.
//
function onError(err) {
self.emit(['error', 'init'], err);
callback(err);
}
//
// Run the bootstrapper, initialize plugins, and
// ensure features for this instance.
//
this.bootstrapper.init(this, initPlugins);
};
//
// ### function use(plugin, callback)
// Attachs the plugin with the specific name to this `App` instance.
//
App.prototype.use = function (plugin, options, callback) {
options = options || {};
if (typeof plugin === 'undefined') {
console.log('Cannot load invalid plugin!');
return callback && callback(new Error('Invalid plugin'));
}
var name = plugin.name,
self = this;
// If the plugin doesn't have a name, use itself as an identifier for the plugins hash.
if (!name) {
name = common.uuid();
}
if (this.plugins[name]) {
return callback && callback();
}
//
// Setup state on this instance for the specified plugin
//
this.plugins[name] = plugin;
this.options[name] = common.mixin({}, options, this.options[name] || {});
//
// Attach the specified plugin to this instance, extending
// the `App` with new functionality.
//
if (this.plugins[name].attach && options.attach !== false) {
this.plugins[name].attach.call(this, options);
}
//
// Setup the initializer only if `options.init` is
// not false. This allows for some plugins to be lazy-loaded
//
if (options.init === false) {
return callback && callback();
}
if (!this.initialized) {
this.initializers[name] = plugin.init || true;
this.initlist.push(name);
return callback && callback();
}
else if (plugin.init) {
plugin.init.call(this, function (err) {
var args = err
? [['plugin', name, 'error'], err]
: [['plugin', name, 'init']];
self.emit.apply(self, args);
return callback && (err ? callback(err) : callback());
});
}
};
//
// ### function remove(name)
// Detaches the plugin with the specific name from this `App` instance.
//
App.prototype.remove = function (name) {
// if this is a plugin object set the name to the plugins name
if (name.name) {
name = name.name;
}
if (this.plugins[name] && this.plugins[name].detach) {
this.plugins[name].detach.call(this);
}
delete this.plugins[name];
delete this.options[name];
delete this.initializers[name];
var init = this.initlist.indexOf(name);
if (init !== -1) {
this.initlist.splice(1, init);
}
}
//
// ### function inspect ()
// Inspects the modules and features used by the current
// application directory structure
//
App.prototype.inspect = function () {
};

84
node_modules/broadway/lib/broadway/bootstrapper.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
/*
* bootstrapper.js: Default logic for bootstrapping broadway applications.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var broadway = require('../broadway');
//
// ### bootstrap (app, callback)
// #### @app {broadway.App} Application to bootstrap
// #### @callback {function} Continuation to respond to when complete.
// Bootstraps the specified `app`.
//
exports.bootstrap = function (app) {
app.options['config'] = app.options['config'] || {};
app.options['config'].init = false;
app.use(broadway.plugins.config);
//
// Remove initializers run by the bootstrapper.
//
delete app.initializers['config'];
app.initlist.pop();
//
// Set the current environment in the config
//
app.config.set('env', app.env);
};
//
// ### bootstrap (app, callback)
// #### @app {broadway.App} Application to bootstrap
// #### @callback {function} Continuation to respond to when complete.
// Runs the initialization step of the bootstrapping process
// for the specified `app`.
//
exports.init = function (app, callback) {
broadway.plugins.config.init.call(app, function (err) {
if (err) {
return callback(err);
}
if (app.config.get('handleExceptions')) {
app.use(broadway.plugins.exceptions, app.options['exceptions'] || {});
}
app.use(broadway.plugins.directories, app.options['directories'] || {});
app.use(broadway.plugins.log, app.options['log'] || {});
//
// Ensure the `directories` and `log` plugins initialize before
// any other plugins. Since we cannot depend on ordering (if they were
// manually added) splice the specific indexes
//
var log = app.initlist.indexOf('log');
app.initlist.unshift.apply(
app.initlist,
app.initlist.splice(log)
);
var directories = app.initlist.indexOf('directories');
app.initlist.unshift.apply(
app.initlist,
app.initlist.splice(directories)
);
//
// Put the godot plugin before the log if it exists
//
var godot = app.initlist.indexOf('godot');
if(~godot) {
app.initlist.unshift.apply(
app.initlist,
app.initlist.splice(godot)
);
}
callback();
});
};

75
node_modules/broadway/lib/broadway/browser.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
/*
* browser.js: Browser specific functionality for broadway.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var id = 0;
var common = {
mixin: function (target) {
var objs = Array.prototype.slice.call(arguments, 1);
objs.forEach(function (o) {
Object.keys(o).forEach(function (attr) {
var getter = o.__lookupGetter__(attr);
if (!getter) {
target[attr] = o[attr];
}
else {
target.__defineGetter__(attr, getter);
}
});
});
return target;
},
uuid: function () {
return String(id++);
}
};
var App = exports.App = function (options) {
//
// Setup options and `App` constants.
//
var self = this;
options = options || {};
this.root = options.root;
this.delimiter = options.delimiter || '::';
//
// Inherit from `EventEmitter2`
//
exports.EventEmitter2.call(this, {
delimiter: this.delimiter,
wildcard: true
});
//
// Setup other relevant options such as the plugins
// for this instance.
//
this.options = options;
this.plugins = options.plugins || {};
this.initialized = false;
this.bootstrapper = { init: function (app, func) {} };
this.initializers = {};
};
var inherit = function (ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
}
inherit(exports.App, exports.EventEmitter2);

View File

@@ -0,0 +1,78 @@
/*
* app.js: Common utility functions for working with directories
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var utile = require('utile'),
async = utile.async,
mkdirp = utile.mkdirp,
rimraf = utile.rimraf;
var directories = exports;
//
// ### function create (dirs, callback)
// #### @dirs {Object} Directories to create
// #### @callback {function} Continuation to respond to when complete
// Creates all of the specified `directories` in the current environment.
//
directories.create = function (dirs, callback) {
function createDir(dir, next) {
mkdirp(dir, 0755, function () {
next(null, dir);
});
}
if (!dirs) {
return callback();
}
async.mapSeries(Object.keys(dirs).map(function (key) {
return dirs[key]
}), createDir, callback);
};
//
// ### function remove (dirs, callback)
// #### @dirs {Object} Directories to remove
// #### @callback {function} Continuation to respond to when complete
// Removes all of the specified `directories` in the current environment.
//
directories.remove = function (dirs, callback) {
function removeDir (dir, next) {
rimraf(dir, function () {
next(null, dir);
});
}
if (!dirs) {
return callback();
}
async.mapSeries(Object.keys(dirs).map(function (key) {
return dirs[key]
}), removeDir, callback);
};
//
// ### function normalize (root, dirs)
// #### @keys {Object} Set of keys to normalize upon.
// #### @dirs {Object} Set of directories to normalize.
// Normalizes the specified `dirs` against the relative
// `root` of the application.
//
directories.normalize = function (keys, dirs) {
var normalized = {};
Object.keys(dirs).forEach(function (key) {
normalized[key] = dirs[key];
Object.keys(keys).forEach(function (constant) {
normalized[key] = normalized[key].replace(constant, keys[constant]);
});
});
return normalized;
};

18
node_modules/broadway/lib/broadway/common/index.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
/*
* common.js: Top-level include for the `common` module.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var common = module.exports = require('utile');
common.directories = require('./directories');
// A naive shared "unique ID" generator for cases where `plugin.name` is
// undefined.
var id = 0;
common.uuid = function () {
return String(id++);
}

48
node_modules/broadway/lib/broadway/features/index.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
/*
* index.js: Top-level include for the features module.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
exports.ensure = function (app, callback) {
return callback();
}
exports.all = [
{
name: 'Entry Point',
test: function (target, name) {
return typeof target.start === 'function' ||
typeof target.createServer === 'function';
},
allExports: ['start', 'createServer', 'init', 'getRoutes']
},
{
name: 'Resource',
test: function (target, name) {
var methods = ['create', 'get', 'update', 'destroy'],
resource = target[capitalize(name)];
if (typeof resource !== 'function') {
return false;
}
for (var i = 0; i < methods.length; i++) {
if (typeof resource[method] !== 'function') {
return false;
}
}
},
allExports: ['addRoutes', 'init']
},
{
name: 'Configurator',
exports: ['config'],
},
{
name: 'Serve Files',
exports: 'serve'
}
];

46
node_modules/broadway/lib/broadway/plugins/config.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
/*
* config.js: Default configuration management plugin which attachs nconf to App instances
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var nconf = require('nconf');
//
// ### Name this plugin
//
exports.name = 'config';
//
// ### function attach (options)
// #### @options {Object} Options for this plugin
// Extends `this` (the application) with configuration functionality
// from `nconf`.
//
exports.attach = function (options) {
options = options || {};
this.config = new nconf.Provider(options);
//
// Setup a default store
//
this.config.use('literal');
this.config.stores.literal.readOnly = false;
};
//
// ### function init (done)
// #### @done {function} Continuation to respond to when complete.
// Initalizes the `nconf.Provider` associated with this instance.
//
exports.init = function (done) {
//
// Remark: There should be code here for automated remote
// seeding and loading
//
this.config.load(function (err) {
return err ? done(err) : done();
});
};

View File

@@ -0,0 +1,49 @@
/*
* directories.js: Plugin for creating directories for a required for a broadway App.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var common = require('../common');
//
// ### Name this plugin
//
exports.name = 'directories';
//
// ### function attach (options)
// #### @options {Object} Options for this plugin
// #### @done {function} Continuation to respond to when complete.
// Prepopulates the directory structure of `this` (the application).
//
exports.attach = function (options) {
options = options || {};
if (this.config) {
//
// Merge options with any pre-existing application config.
//
options = common.mixin({}, options, this.config.get('directories') || {});
}
options = common.directories.normalize({'#ROOT': this.root}, options);
this.options['directories'] = options;
if (this.config) {
this.config.merge('directories', options);
}
};
//
// ### function init (done)
// #### @done {function} Continuation to respond to when complete.
// Creates the directories associated with this instance.
//
exports.init = function (done) {
common.directories.create(this.options['directories'], function (err) {
return err ? done(err) : done();
});
};

View File

@@ -0,0 +1,70 @@
/*
* exceptions.js: Plugin responsible for logging all uncaughtExceptions in a flatiron App.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var winston = require('winston'),
common = require('../common');
var exceptions = exports;
//
// ### Setup default state for the exceptions plugin
//
exceptions.name = 'exceptions';
exceptions.initalized = false;
var defaultConfig = exceptions.defaultConfig = {
console: {
colorize: false,
json: true,
level: 'silly'
}
};
//
// ### function attach (options)
// #### @options {Object} Options for this plugin
// Extends `this` the application with exception handling
// functionality from `winston`.
//
exceptions.attach = function (options) {
options = options || {};
if (this.config) {
options = common.mixin({}, options, this.config.get('exceptions') || {});
}
if (exceptions.initalized) {
return;
}
var exceptionHandlers = [];
//
// Create the exceptionHandlers defaulting to Console and Loggly.
//
exceptionHandlers.push(new winston.transports.Console(options.console || defaultConfig.console));
Object.keys(options).forEach(function (name) {
if (name === 'console') {
return;
}
exceptionHandlers.push(new (winston.transports[common.capitalize(name)])(options[name]));
});
//
// Update the state of the plugin with the logger.
//
exceptions.logger = new winston.Logger({ exceptionHandlers: exceptionHandlers });
exceptions.initalized = true;
//
// Have the logger handle uncaught exceptions.
//
exceptions.logger.handleExceptions();
};

40
node_modules/broadway/lib/broadway/plugins/inspect.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
/*
* inspect.js: Plugin responsible for attaching inspection behavior using `cliff` and `eyes`.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
//
// ### Name this plugin
//
exports.name = 'inspect';
//
// ### function init (done)
// #### @done {function} Continuation to respond to when complete.
// Attaches inspection behavior through `cliff` and `eyes`.
//
exports.init = function (done) {
var namespace = 'default',
app = this;
if (app.options['inspect'] && app.options['inspect'].namespace) {
namespace = app.options['inspect'].namespace;
}
app.inspect = require('cliff');
app.inspect.logger = app.log.get('namespace');
done();
};
//
// ### function detact()
// Removes inspection behavior exposed by this plugin.
//
exports.detach = function () {
if (this.inspect) {
delete this.inspect;
}
};

227
node_modules/broadway/lib/broadway/plugins/log.js generated vendored Normal file
View File

@@ -0,0 +1,227 @@
/*
* log.js: Default logging plugin which attachs winston to App instances
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var winston = require('winston'),
common = require('../common');
var log = exports;
//
// ### Setup default state for the exceptions plugin
//
log.name = 'log';
log.ignore = ['broadway'];
//
// ### function attach (options)
// #### @options {Object} Options for this plugin
// Extends `this` (the application) with logging functionality from `winston`.
//
log.attach = function (options) {
options = options || {};
var app = this,
namespaces,
logAll,
level,
oldGodot,
service;
if (this.config) {
//
// Merge options with any pre-existing application config.
//
options = common.mixin({}, options, this.config.get('log') || {});
}
//
// Setup namespaces and then remove them from
// `options` so they are not caught by `winston`.
//
namespaces = options.namespaces || {};
delete options.namespaces;
//
// Setup logAll and then remove them from
// `options` so they are not caught by `winston`.
//
logAll = options.logAll || false;
if (options.logAll) {
delete options.logAll;
}
//
// Setup level and then remove them from
// `options` so they are not caught by `winston`.
//
level = options.level || false;
if (options.level) {
delete options.level;
}
//
// Make proper godot options for the winston plugin if it exists
//
if (this.godot && options.godot) {
oldGodot = options.godot;
service = this.config.get('service')
|| options.service
|| oldGodot.service
|| 'app';
options.godot = {
godot: this.godot,
service: service + '/logs',
handleExceptions: oldGodot.handleExceptions === false ? false : true
};
}
//
// Hoist up relevant logging functions onto the app
// if requested.
//
this.log = new winston.Container(options);
this.log.namespaces = namespaces;
this.log.get('default').extend(this.log);
//
// Set the default console loglevel to options.level
//
this.log.get('default').transports.console.level = level || 'info';
Object.defineProperty(this.log, 'logAll', {
get: function () {
return this._logAll;
},
set: function (val) {
if (val === this._logAll) {
//
// If the value is identical return
//
return;
}
if (val) {
app.onAny(log.logEvent);
app.off(['log'], log.logEvent);
app.off(['log', '*'], log.logEvent);
app.off(['log', '*', '*'], log.logEvent);
}
else {
app.offAny(log.logEvent);
app.on(['log'], log.logEvent);
app.on(['log', '*'], log.logEvent);
app.on(['log', '*', '*'], log.logEvent);
}
this._logAll = val;
}
});
//
// Listen to relevant `app` events and
// log them appropriately.
//
this.log.logAll = logAll;
//
// Add any namespaced containers to this App instance.
//
Object.keys(this.log.namespaces).forEach(function (namespace) {
app.log.add(app.log.namespaces[namespace]);
});
};
//
// ### function logEvent ([level], msg, meta)
// #### @msg {string} Message to log
// #### @meta {Object} **Optional** Metadata to log
// Logs the specified `msg` and `meta` according to
// the following conditions:
//
// #### `log` events
// 1. `log` - Logs to the default logger and level.
// 2. `log::[level]` - Logs to the default logger.
// 3. `log::[level]::[namespace]` - Logs to a namespaced logger.
//
// ### `[namespaced]` events
// If `app.log.logAll` is set, then find a logger at `namespace`,
// otherwise the default logger is used.
//
// 1. `[namespace]::**(level, msg, meta)` - Logs the event as the
// message to the logger for the specified namespace and level.
// 2. `[namespace]::[level]::**(msg, meta)` - Logs the event and
// the message to the logger for the specified namespace and level.
//
log.logEvent = function (/* level, msg, meta */) {
var parts = Array.isArray(this.event) ? this.event : this.event.split(this.delimiter),
ev = parts[0],
namespace,
logger,
level,
meta,
msg;
if (log.ignore.indexOf(ev) !== -1) {
return;
}
//
// Determine the `namespace` to log the event to
//
if (ev === 'log') {
namespace = parts[2] || 'default';
logger = this.log.get('default');
}
else if (this.log.logAll) {
namespace = this.log.namespaces[ev] ? this.log.namespaces[ev] : 'default';
logger = this.log.get(namespace);
}
else {
return;
}
//
// Parse arguments now that we have the logger.
//
Array.prototype.slice.call(arguments).forEach(function (a) {
switch (typeof a) {
case 'object': {
meta = a;
break;
}
case 'string': {
if (logger[a]) {
level = a;
}
else {
msg = a;
}
}
}
});
if (ev === 'log') {
level = parts[1] || level || 'info';
}
else if (this.log.logAll) {
if (logger[parts[1]]) {
level = parts[1];
parts.splice(1, 1);
}
}
if (level in logger.levels === false) {
level = 'info';
}
parts = parts.join(this.delimiter);
meta = meta || {};
msg = msg || parts;
logger.log(level, msg, meta);
this.emit(['broadway', 'logged'], level, msg, meta, parts);
};

91
node_modules/broadway/package.json generated vendored Normal file
View File

@@ -0,0 +1,91 @@
{
"_args": [
[
"broadway@~0.3.6",
"/home/mywebsite/node_modules/forever-monitor"
]
],
"_from": "broadway@>=0.3.6 <0.4.0",
"_id": "broadway@0.3.6",
"_inCache": true,
"_installable": true,
"_location": "/broadway",
"_npmUser": {
"email": "jcrugzz@gmail.com",
"name": "jcrugzz"
},
"_npmVersion": "1.4.23",
"_phantomChildren": {},
"_requested": {
"name": "broadway",
"raw": "broadway@~0.3.6",
"rawSpec": "~0.3.6",
"scope": null,
"spec": ">=0.3.6 <0.4.0",
"type": "range"
},
"_requiredBy": [
"/forever-monitor"
],
"_resolved": "https://registry.npmjs.org/broadway/-/broadway-0.3.6.tgz",
"_shasum": "7dbef068b954b7907925fd544963b578a902ba7a",
"_shrinkwrap": null,
"_spec": "broadway@~0.3.6",
"_where": "/home/mywebsite/node_modules/forever-monitor",
"author": {
"email": "info@nodejitsu.com",
"name": "Nodejitsu Inc."
},
"bugs": {
"url": "https://github.com/flatiron/broadway/issues"
},
"dependencies": {
"cliff": "0.1.9",
"eventemitter2": "0.4.14",
"nconf": "0.6.9",
"utile": "0.2.1",
"winston": "0.8.0"
},
"description": "Lightweight application extensibility and composition with a twist of feature reflection.",
"devDependencies": {
"codesurgeon": "0.3.x",
"uglify-js": "1.0.6",
"vows": "0.7.x"
},
"directories": {},
"dist": {
"shasum": "7dbef068b954b7907925fd544963b578a902ba7a",
"tarball": "http://registry.npmjs.org/broadway/-/broadway-0.3.6.tgz"
},
"engines": {
"node": ">= 0.6.4"
},
"gitHead": "d293e467b2364b2432259f8c21df0c6bf1206762",
"homepage": "https://github.com/flatiron/broadway",
"main": "./lib/broadway",
"maintainers": [
{
"name": "indexzero",
"email": "charlie.robbins@gmail.com"
},
{
"name": "mmalecki",
"email": "me@mmalecki.com"
},
{
"name": "jcrugzz",
"email": "jcrugzz@gmail.com"
}
],
"name": "broadway",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/flatiron/broadway.git"
},
"scripts": {
"test": "vows test/**/*-test.js --spec"
},
"version": "0.3.6"
}

60
node_modules/broadway/test/common/directories-test.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
/*
* directories-test.js: Tests for working with directories in broadway.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var assert = require('assert'),
fs = require('fs'),
path = require('path'),
vows = require('vows'),
broadway = require('../../lib/broadway');
var fixturesDir = path.join(__dirname, '..', 'fixtures'),
emptyAppDir = path.join(fixturesDir, 'empty-app'),
emptyAppFile = path.join(fixturesDir, 'sample-app.json'),
appConfig = JSON.parse(fs.readFileSync(emptyAppFile, 'utf8')),
directories = appConfig.directories;
vows.describe('broadway/common/directories').addBatch({
"When using broadway.common.directories": {
"it should have the correct methods defined": function () {
assert.isObject(broadway.common.directories);
assert.isFunction(broadway.common.directories.create);
assert.isFunction(broadway.common.directories.remove);
},
"the normalize() method should correctly modify a set of directories": function () {
directories = broadway.common.directories.normalize({'#ROOT': emptyAppDir}, directories);
Object.keys(directories).forEach(function (key) {
assert.isTrue(directories[key].indexOf(emptyAppDir) !== -1);
});
},
"the create() method": {
topic: function () {
broadway.common.directories.create(directories, this.callback);
},
"should create the specified directories": function (err, dirs) {
assert.isTrue(!err);
dirs.forEach(function (dir) {
assert.isTrue((fs.existsSync || path.existsSync)(dir));
});
},
"the destroy() method": {
topic: function () {
broadway.common.directories.remove(directories, this.callback);
},
"should remove the specified directories": function (err, dirs) {
assert.isTrue(!err);
dirs.forEach(function (dir) {
assert.isFalse((fs.existsSync || path.existsSync)(dir));
});
}
}
}
}
}).export(module);

100
node_modules/broadway/test/core/app-init-test.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
/*
* app-test.js: Tests for core App methods and configuration.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var events = require('eventemitter2'),
vows = require('vows'),
assert = require('../helpers/assert'),
broadway = require('../../lib/broadway');
vows.describe('broadway/app').addBatch({
"An initialized instance of broadway.App with three plugins": {
topic: function () {
var app = new broadway.App(),
that = this,
three;
that.init = [];
three = {
name: 'three',
init: function (cb) {
process.nextTick(function () {
that.init.push('three');
cb();
})
}
};
// First plugin. Includes an init step.
app.use({
attach: function () {
this.place = 'rackspace';
},
init: function (cb) {
var self = this;
// a nextTick isn't technically necessary, but it does make this
// purely async.
process.nextTick(function () {
that.init.push('one');
self.letsGo = function () {
return 'Let\'s go to '+self.place+'!';
}
cb();
});
}
});
// Second plugin. Only involves an "attach".
app.use({
attach: function () {
this.oneup = function (n) {
n++;
return n;
}
}
});
// Third pluging. Only involves an "init".
app.use(three);
// Attempt to use it again. This should not invoke `init()` twice
app.use(three);
// Remove the plugin and use it again. This should not invoke `init()` twice
app.remove(three);
app.use(three);
// Removing a plugin which was never added should not affect the initlist
app.remove({
name: 'foo'
});
app.init(function (err) {
that.callback(err, app);
});
},
"shouldn't throw an error": function (err, app) {
assert.ok(!err);
},
"should have all its methods attached/defined": function (err, app) {
assert.ok(app.place);
assert.isFunction(app.oneup);
assert.isFunction(app.letsGo);
assert.equal(2, app.oneup(1));
assert.equal(app.letsGo(), 'Let\'s go to rackspace!');
//
// This is intentional. The second plugin does not invoke `init`.
//
assert.deepEqual(this.init, ['one', 'three']);
},
}
}).export(module);

73
node_modules/broadway/test/core/app-test.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
/*
* app-test.js: Tests for core App methods and configuration.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var events = require('eventemitter2'),
vows = require('vows'),
assert = require('../helpers/assert'),
broadway = require('../../lib/broadway');
vows.describe('broadway/app').addBatch({
"An instance of broadway.App": {
topic: new broadway.App(),
"should have the correct properties and methods": function (app) {
//
// Instance
//
assert.isObject(app);
assert.instanceOf(app, events.EventEmitter2);
assert.instanceOf(app, broadway.App);
//
// Properties
//
assert.isObject(app.plugins);
assert.isObject(app.initializers);
assert.isFalse(!!app.initialized);
//
// Methods
//
assert.isFunction(app.init);
assert.isFunction(app.use);
assert.isFunction(app.remove);
assert.isFunction(app.inspect);
},
"the init() method": {
topic: function (app) {
this.app = app;
app.init(this.callback);
},
"should correctly setup the application state": function () {
assert.isTrue(this.app.initialized);
assert.isTrue(this.app.initializers['log']);
assert.plugins.has.config(this.app);
assert.plugins.has.log(this.app);
}
},
"the detach() method": {
topic: function (app) {
app.use({
name: "foo",
attach: function () {
this.attached = true;
},
detach: function () {
this.detached = true;
}
});
app.remove("foo");
return app;
},
"should correctly remove a plugin": function (app) {
assert.isTrue(app.detached);
assert.equal(undefined, app.plugins["foo"]);
}
}
}
}).export(module);

26
node_modules/broadway/test/core/broadway-test.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/*
* broadway-test.js: Tests for core App methods and configuration.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var assert = require('assert'),
events = require('eventemitter2'),
vows = require('vows'),
broadway = require('../../lib/broadway');
vows.describe('broadway').addBatch({
"The broadway module": {
"should have the appropriate properties and methods defined": function () {
assert.isFunction(broadway.App);
assert.isObject(broadway.common);
assert.isObject(broadway.features);
assert.isObject(broadway.plugins);
assert.isObject(broadway.plugins.log);
assert.isObject(broadway.plugins.config);
assert.isObject(broadway.plugins.exceptions);
}
}
}).export(module);

0
node_modules/broadway/test/fixtures/.gitkeep generated vendored Normal file
View File

View File

8
node_modules/broadway/test/fixtures/sample-app.json generated vendored Normal file
View File

@@ -0,0 +1,8 @@
{
"directories": {
"app": "#ROOT/app",
"config": "#ROOT/config",
"lib": "#ROOT/lib",
"test": "#ROOT/test"
}
}

View File

@@ -0,0 +1,2 @@
var broadway = require("../../../")

View File

@@ -0,0 +1,5 @@
{
"topics": [
]
}

107
node_modules/broadway/test/helpers/assert.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
/*
* assert.js: Assertion helpers for broadway tests
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var assert = module.exports = require('assert'),
fs = require('fs'),
path = require('path'),
nconf = require('nconf'),
vows = require('vows');
//
// ### Assertion helpers for working with `broadway.App` objects.
//
assert.app = {};
//
// ### Assertion helpers for working with `broadway.plugins`.
//
assert.plugins = {};
//
// ### Assert that an application has various plugins.
//
assert.plugins.has = {
config: function (app, config) {
assert.instanceOf(app.config, nconf.Provider);
if (config) {
//
// TODO: Assert that all configuration has been loaded
//
}
},
exceptions: function (app) {
},
directories: function (app) {
if (app.options['directories']) {
Object.keys(app.options['directories']).forEach(function (key) {
assert.isTrue((fs.existsSync || path.existsSync)(app.options['directories'][key]));
});
}
},
log: function (app) {
assert.isObject(app.log);
//
// TODO: Assert winston.extend methods
//
}
};
//
// ### Assert that an application doesn't have various plugins
//
assert.plugins.notHas = {
config: function (app) {
assert.isTrue(!app.config);
},
exceptions: function (app) {
},
directories: function (app) {
assert.isTrue(!app.config.get('directories'))
},
log: function (app) {
assert.isTrue(!app.log);
//
// TODO: Assert winston.extend methods
//
}
};
assert.log = {};
assert.log.levelMsgMeta = function (err, level, msg, meta) {
assert.equal(level, this.event[1]);
assert.equal(msg, this.event[2]);
assert.equal(meta, this.event[3]);
};
assert.log.msgMeta = function (err, level, msg, meta) {
assert.equal(level, this.event[0].split('::')[1] || 'info');
assert.equal(msg, this.event[1]);
assert.equal(meta, this.event[2]);
};
assert.log.levelMeta = function (err, level, msg, meta) {
assert.equal(level, this.event[1]);
assert.equal(msg, this.event[0]);
assert.deepEqual(meta, this.event[2]);
};
assert.log.levelMsg = function (err, level, msg, meta) {
assert.equal(level, this.event[1]);
assert.equal(msg, this.event[2]);
};
assert.log.metaOnly = function (err, level, msg, meta, event) {
assert.equal(level, 'info');
assert.equal(msg, this.event[0]);
assert.equal(meta, this.event[1]);
assert.equal(event, this.event[0]);
};

24
node_modules/broadway/test/helpers/helpers.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
/*
* helpers.js: Test helpers for using broadway.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var events = require('eventemitter2'),
broadway = require('../../lib/broadway');
var helpers = exports;
helpers.findApp = function () {
return Array.prototype.slice.call(arguments).filter(function (arg) {
return arg instanceof events.EventEmitter2;
})[0];
};
helpers.mockApp = function () {
var mock = new events.EventEmitter2({ delimiter: '::', wildcard: true });
mock.options = {};
return mock;
};

74
node_modules/broadway/test/helpers/macros.js generated vendored Normal file
View File

@@ -0,0 +1,74 @@
/*
* macros.js: Test macros for using broadway and vows
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var events = require('eventemitter2'),
assert = require('./assert'),
helpers = require('./helpers'),
broadway = require('../../lib/broadway');
var macros = exports;
macros.shouldExtend = function (app, plugin, vows) {
if (arguments.length === 1) {
plugin = app;
app = vows = null;
}
else if (arguments.length === 2) {
app = helpers.mockApp();
vows = plugin;
plugin = app;
}
var context = {
topic: function () {
app = app || helpers.mockApp();
broadway.plugins[plugin].attach.call(app, app.options[plugin] || {});
if (broadway.plugins[plugin].init) {
return broadway.plugins[plugin].init.call(app, this.callback.bind(this, null, app));
}
this.callback(null, app);
},
"should add the appropriate properties and methods": function (_, app) {
assert.plugins.has[plugin](app);
}
}
return extendContext(context, vows);
};
macros.shouldLogEvent = function (app, event, vow) {
return {
topic: function () {
app = app || helpers.findApp.apply(null, arguments);
var logger = app.log.get('default');
this.event = event;
app.once('broadway::logged', this.callback.bind(this, null));
app.emit.apply(app, event);
},
"should log the appropriate info": vow
};
};
function extendContext (context, vows) {
if (vows) {
if (vows.topic) {
console.log('Cannot include topic at top-level of nested vows:');
console.dir(vows, 'vows');
process.exit(1);
}
Object.keys(vows).forEach(function (key) {
context[key] = vows[key];
});
}
return context;
}

19
node_modules/broadway/test/plugins/config-test.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/*
* config-test.js: Tests for the broadway config plugin
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var vows = require('vows'),
events = require('eventemitter2'),
assert = require('../helpers/assert'),
macros = require('../helpers/macros'),
broadway = require('../../lib/broadway');
vows.describe('broadway/plugins/config').addBatch({
"Using the config plugin": {
"extending an application": macros.shouldExtend('config')
}
}).export(module);

28
node_modules/broadway/test/plugins/directories-test.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/*
* directories-test.js: Tests for working with directories in broadway.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var assert = require('assert'),
fs = require('fs'),
path = require('path'),
vows = require('vows'),
broadway = require('../../lib/broadway'),
macros = require('../helpers/macros');
var fixturesDir = path.join(__dirname, '..', 'fixtures'),
emptyAppDir = path.join(fixturesDir, 'empty-app'),
emptyAppFile = path.join(fixturesDir, 'sample-app.json'),
appConfig = JSON.parse(fs.readFileSync(emptyAppFile, 'utf8'));;
vows.describe('broadway/plugins/directories').addBatch({
"Using the config plugin": {
"extending an application": macros.shouldExtend(new broadway.App({
root: emptyAppDir,
directories: appConfig.directories
}), 'directories', {})
}
}).export(module);

69
node_modules/broadway/test/plugins/log-test.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
/*
* log-test.js: Tests for the broadway logger plugin
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var vows = require('vows'),
events = require('eventemitter2'),
assert = require('../helpers/assert'),
helpers = require('../helpers/helpers'),
macros = require('../helpers/macros'),
broadway = require('../../lib/broadway');
var app = helpers.mockApp();
app.options = {
log: {
logAll: true,
namespaces: {
'apps': 'foo'
}
}
};
vows.describe('broadway/plugins/log').addBatch({
"Using the log plugin": {
"to extend an application": macros.shouldExtend(app, 'log', {
"when the application emits log::# events": macros.shouldLogEvent(app, [
'log::warn',
'some warn message',
{ foo: 'bar' }
], assert.log.msgMeta)
}),
"when the application emits log::#::# events": macros.shouldLogEvent(app, [
'log::warn::some-category',
'some warn message',
{ foo: 'bar' }
], assert.log.msgMeta),
"when the application emits log events with": {
"message and meta": macros.shouldLogEvent(app, [
'log',
'some info message',
{ foo: 'bar' },
], assert.log.msgMeta),
"level and message": macros.shouldLogEvent(app, [
'log',
'silly',
'some silly message',
], assert.log.levelMsg),
"level and meta": macros.shouldLogEvent(app, [
'log',
'info',
{ foo: 'bar' },
], assert.log.levelMeta)
},
"when the application emits namespaced events with": {
"level and meta": macros.shouldLogEvent(app, [
'apps::start',
'info',
{ foo: 'bar' },
], assert.log.levelMeta),
"meta only": macros.shouldLogEvent(app, [
'apps::start',
{ foo: 'bar' },
], assert.log.metaOnly)
}
}
}).export(module);