Static functions are static.

pull/740/head
Chad Weider 2012-05-28 18:11:59 -07:00
parent b0d71df604
commit e375b6212a
1 changed files with 14 additions and 14 deletions

View File

@ -53,7 +53,7 @@ exports.formatHooks = function (hook_set_name) {
return "<dl>" + res.join("\n") + "</dl>"; return "<dl>" + res.join("\n") + "</dl>";
}; };
exports.loadFn = function (path, hookName) { function loadFn(path, hookName) {
var functionName var functionName
, parts = path.split(":"); , parts = path.split(":");
@ -95,7 +95,7 @@ exports.extractHooks = function (parts, hook_set_name) {
} }
try { try {
var hook_fn = exports.loadFn(hook_fn_name, hook_name); var hook_fn = loadFn(hook_fn_name, hook_name);
if (!hook_fn) { if (!hook_fn) {
throw "Not a function"; throw "Not a function";
} }
@ -161,12 +161,12 @@ exports.update = function (cb) {
async.forEach( async.forEach(
Object.keys(packages), Object.keys(packages),
function (plugin_name, cb) { function (plugin_name, cb) {
exports.loadPlugin(packages, plugin_name, plugins, parts, cb); loadPlugin(packages, plugin_name, plugins, parts, cb);
}, },
function (err) { function (err) {
if (err) cb(err); if (err) cb(err);
exports.plugins = plugins; exports.plugins = plugins;
exports.parts = exports.sortParts(parts); exports.parts = sortParts(parts);
exports.hooks = exports.extractHooks(exports.parts, "hooks"); exports.hooks = exports.extractHooks(exports.parts, "hooks");
exports.loaded = true; exports.loaded = true;
exports.callInit(cb); exports.callInit(cb);
@ -202,7 +202,10 @@ exports.getPackages = function (cb) {
}); });
}; };
exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) { }
function loadPlugin(packages, plugin_name, plugins, parts, cb) {
var plugin_path = path.resolve(packages[plugin_name].path, "ep.json"); var plugin_path = path.resolve(packages[plugin_name].path, "ep.json");
fs.readFile( fs.readFile(
plugin_path, plugin_path,
@ -226,9 +229,9 @@ exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) {
cb(); cb();
} }
); );
}; }
exports.partsToParentChildList = function (parts) { function partsToParentChildList(parts) {
var res = []; var res = [];
_.chain(parts).keys().forEach(function (name) { _.chain(parts).keys().forEach(function (name) {
_.each(parts[name].post || [], function (child_name) { _.each(parts[name].post || [], function (child_name) {
@ -242,18 +245,15 @@ exports.partsToParentChildList = function (parts) {
} }
}); });
return res; return res;
}; }
// Used only in Node, so no need for _ // Used only in Node, so no need for _
exports.sortParts = function(parts) { function sortParts(parts) {
return tsort( return tsort(
exports.partsToParentChildList(parts) partsToParentChildList(parts)
).filter( ).filter(
function (name) { return parts[name] !== undefined; } function (name) { return parts[name] !== undefined; }
).map( ).map(
function (name) { return parts[name]; } function (name) { return parts[name]; }
); );
}; }
}