refactoring the testing process

This commit is contained in:
Fede Ramirez
2015-03-23 05:15:10 -03:00
parent b825142f83
commit d9d4471678
5 changed files with 219 additions and 134 deletions
+31 -2
View File
@@ -1,7 +1,9 @@
"use strict;"
'use strict';
var util = require('util');
var path = require('path');
var JsonFile = require('./JsonFile');
var PACKAGE_EXPECTATION = /^([^:\s]*):([^\s]*)$/;
/**
* @constructor RegistryFile
@@ -15,5 +17,32 @@ var RegistryFile = module.exports = function RegistryFile(){
JsonFile.call(this, path.resolve('./registry.json'));
};
util.inherits(RegistryFile, JsonFile);
util.inherits(RegistryFile, JsonFile);
RegistryFile.prototype.forEachPackage = function(fn){
return this.forEach(function(redirection, name){
var pkg = {};
var match = PACKAGE_EXPECTATION.exec(redirection);
if (!match) {
pkg = {
value: redirection,
endpoint: undefined,
name: undefined,
};
} else {
pkg = {
value: match[0],
endpoint: match[1],
name: match[2],
};
}
fn.call(this, pkg, name);
});
};