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

Introduce "analyze" verb and framework.

Introduce a new "analyze" command and start setting up the inspector /
analyzer pipeline with a simple "gap analysis" inspector using a
reference-counted gap detection approach.
This commit is contained in:
hacksalot
2016-01-01 03:39:48 -05:00
parent 3453293c79
commit 6285c2db3b
4 changed files with 153 additions and 2 deletions

64
src/verbs/analyze.js Normal file
View File

@ -0,0 +1,64 @@
/**
Implementation of the 'analyze' verb for HackMyResume.
@module create.js
@license MIT. See LICENSE.md for details.
*/
(function(){
var FLUENT = require('../hackmyapi')
, MKDIRP = require('mkdirp')
, PATH = require('path')
, _ = require('underscore')
, ResumeFactory = require('../core/resume-factory');
/**
Run the 'analyze' command.
*/
module.exports = function analyze( src, dst, opts, logger ) {
var _log = logger || console.log;
if( !src || !src.length ) throw { fluenterror: 8 };
var sourceResumes = ResumeFactory.load( src, _log, null, true );
var nlzrs = _loadInspectors();
sourceResumes.forEach( function(r) {
_analyze( r, nlzrs, opts, _log );
});
};
/**
Analyze a single resume.
*/
function _analyze( resumeObject, nlzrs, opts, log ) {
var rez = resumeObject.rez;
var safeFormat = rez.meta.format.startsWith('FRESH') ? 'FRESH' : 'JRS';
log('Analyzing '.useful + safeFormat.useful.bold +
' resume: '.useful + resumeObject.file.useful.bold);
var info = _.mapObject( nlzrs, function(val, key) {
return val.run( resumeObject.rez );
});
console.log('Gaps: ' + info.gaps.length );
}
/**
Load inspectors.
*/
function _loadInspectors() {
return {
gaps: require('../inspectors/gap-inspector')
};
}
}());