nhz.lib
Version:
NHZ Library
58 lines (55 loc) • 1.47 kB
JavaScript
var genClassTests;
genClassTests = require('../coffee/gen-class-tests');
module.exports = function(argv) {
var ancestors, arg, args, i, len, methods, name, properties, ref, staticMethods, staticProperties, target;
args = argv.slice(2);
ancestors = [];
staticProperties = [];
staticMethods = [];
properties = [];
methods = [];
target = null;
name = (ref = args.shift()) != null ? ref.replace(/\s/g, '') : void 0;
if (!name || name.match(/(^[^a-z_])|[^0-9a-z_\-]+/i)) {
throw new Error("Invalid class name: " + name);
}
for (i = 0, len = args.length; i < len; i++) {
arg = args[i];
switch (arg) {
case '-a':
target = ancestors;
break;
case '-p':
target = properties;
break;
case '-m':
target = methods;
break;
case '-P':
target = staticProperties;
break;
case '-sp':
target = staticProperties;
break;
case '-M':
target = staticMethods;
break;
case '-sm':
target = staticMethods;
break;
default:
if (!target) {
throw new Error('Dont know where #{arg} belongs. Use one of the: -a, -p, -m, -P or -M');
}
target.push(arg);
}
}
return console.log(genClassTests({
name: name,
ancestors: ancestors,
staticProperties: staticProperties,
staticMethods: staticMethods,
properties: properties,
methods: methods
}));
};