1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-15 10:07:07 +01:00

Refactor command processing.

This commit is contained in:
hacksalot
2016-01-02 00:15:46 -05:00
parent 47553b6def
commit a95b52acd0
8 changed files with 74 additions and 60 deletions

View File

@ -22,14 +22,19 @@ Implementation of the 'analyze' verb for HackMyResume.
/**
Run the 'analyze' command.
*/
module.exports = function analyze( src, dst, opts, logger ) {
module.exports = function analyze( sources, dst, opts, logger ) {
var _log = logger || console.log;
if( !src || !src.length ) throw { fluenterror: 3 };
var sourceResumes = ResumeFactory.load( src, _log, null, true );
if( !sources || !sources.length ) throw { fluenterror: 3 };
var nlzrs = _loadInspectors();
sourceResumes.forEach( function(r) {
_analyze( r, nlzrs, opts, _log );
sources.forEach( function(src) {
var result = ResumeFactory.loadOne( src, {
log: _log, format: 'FRESH', objectify: true, throw: false
});
result.error || _analyze( result, nlzrs, opts, _log );
});
};
@ -39,7 +44,9 @@ Implementation of the 'analyze' verb for HackMyResume.
*/
function _analyze( resumeObject, nlzrs, opts, log ) {
var rez = resumeObject.rez;
var safeFormat = rez.meta.format.startsWith('FRESH') ? 'FRESH' : 'JRS';
var safeFormat =
(rez.meta && rez.meta.format && rez.meta.format.startsWith('FRESH')) ?
'FRESH' : 'JRS';
log(chalk.cyan('Analyzing ') + chalk.cyan.bold(safeFormat) +
chalk.cyan(' resume: ') + chalk.cyan.bold(resumeObject.file));
var info = _.mapObject( nlzrs, function(val, key) {