2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Implementation of the 'analyze' verb for HackMyResume.
|
|
|
|
@module verbs/analyze
|
|
|
|
@license MIT. See LICENSE.md for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
2016-02-02 04:16:49 +00:00
|
|
|
var AnalyzeVerb, HMEVENT, HMSTATUS, MKDIRP, PATH, ResumeFactory, Verb, _, _analyze, _analyzeOne, _loadInspectors, chalk,
|
|
|
|
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
|
|
|
hasProp = {}.hasOwnProperty;
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
MKDIRP = require('mkdirp');
|
|
|
|
|
|
|
|
PATH = require('path');
|
|
|
|
|
|
|
|
HMEVENT = require('../core/event-codes');
|
|
|
|
|
|
|
|
HMSTATUS = require('../core/status-codes');
|
|
|
|
|
|
|
|
_ = require('underscore');
|
|
|
|
|
|
|
|
ResumeFactory = require('../core/resume-factory');
|
|
|
|
|
|
|
|
Verb = require('../verbs/verb');
|
|
|
|
|
|
|
|
chalk = require('chalk');
|
|
|
|
|
2016-02-02 02:14:36 +00:00
|
|
|
|
|
|
|
/** An invokable resume analysis command. */
|
|
|
|
|
2016-02-02 04:16:49 +00:00
|
|
|
module.exports = AnalyzeVerb = (function(superClass) {
|
|
|
|
extend(AnalyzeVerb, superClass);
|
|
|
|
|
|
|
|
function AnalyzeVerb() {
|
|
|
|
AnalyzeVerb.__super__.constructor.call(this, 'analyze', _analyze);
|
2016-01-27 10:29:26 +00:00
|
|
|
}
|
2016-02-02 04:16:49 +00:00
|
|
|
|
|
|
|
return AnalyzeVerb;
|
|
|
|
|
|
|
|
})(Verb);
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
|
2016-02-02 02:14:36 +00:00
|
|
|
/** Private workhorse for the 'analyze' command. */
|
2016-01-27 10:29:26 +00:00
|
|
|
|
2016-02-02 02:14:36 +00:00
|
|
|
_analyze = function(sources, dst, opts) {
|
|
|
|
var nlzrs, results;
|
2016-01-27 10:29:26 +00:00
|
|
|
if (!sources || !sources.length) {
|
2016-02-02 02:14:36 +00:00
|
|
|
this.err(HMSTATUS.resumeNotFound, {
|
2016-01-27 10:29:26 +00:00
|
|
|
quit: true
|
2016-02-02 02:14:36 +00:00
|
|
|
});
|
|
|
|
return null;
|
2016-01-27 10:29:26 +00:00
|
|
|
}
|
|
|
|
nlzrs = _loadInspectors();
|
2016-02-02 02:14:36 +00:00
|
|
|
results = _.map(sources, function(src) {
|
|
|
|
var r;
|
|
|
|
r = ResumeFactory.loadOne(src, {
|
2016-01-27 10:29:26 +00:00
|
|
|
format: 'FRESH',
|
2016-02-14 18:15:47 +00:00
|
|
|
objectify: true,
|
|
|
|
inner: {
|
2016-02-14 20:53:10 +00:00
|
|
|
"private": opts["private"] === true
|
2016-02-14 18:15:47 +00:00
|
|
|
}
|
2016-01-27 10:29:26 +00:00
|
|
|
}, this);
|
2016-02-02 02:14:36 +00:00
|
|
|
if (opts.assert && this.hasError()) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
if (r.fluenterror) {
|
|
|
|
r.quit = opts.assert;
|
|
|
|
this.err(r.fluenterror, r);
|
|
|
|
return r;
|
2016-01-27 10:29:26 +00:00
|
|
|
} else {
|
2016-02-02 02:14:36 +00:00
|
|
|
return _analyzeOne.call(this, r, nlzrs, opts);
|
2016-01-27 10:29:26 +00:00
|
|
|
}
|
|
|
|
}, this);
|
2016-02-02 02:14:36 +00:00
|
|
|
if (this.hasError() && !opts.assert) {
|
|
|
|
this.reject(this.errorCode);
|
|
|
|
} else if (!this.hasError()) {
|
|
|
|
this.resolve(results);
|
|
|
|
}
|
|
|
|
return results;
|
2016-01-27 10:29:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-02-02 02:14:36 +00:00
|
|
|
/** Analyze a single resume. */
|
2016-01-27 10:29:26 +00:00
|
|
|
|
2016-02-02 02:14:36 +00:00
|
|
|
_analyzeOne = function(resumeObject, nlzrs, opts) {
|
2016-01-27 10:29:26 +00:00
|
|
|
var info, rez, safeFormat;
|
|
|
|
rez = resumeObject.rez;
|
|
|
|
safeFormat = rez.meta && rez.meta.format && rez.meta.format.startsWith('FRESH') ? 'FRESH' : 'JRS';
|
|
|
|
this.stat(HMEVENT.beforeAnalyze, {
|
|
|
|
fmt: safeFormat,
|
|
|
|
file: resumeObject.file
|
|
|
|
});
|
|
|
|
info = _.mapObject(nlzrs, function(val, key) {
|
|
|
|
return val.run(rez);
|
|
|
|
});
|
2016-02-02 02:14:36 +00:00
|
|
|
this.stat(HMEVENT.afterAnalyze, {
|
2016-01-27 10:29:26 +00:00
|
|
|
info: info
|
|
|
|
});
|
2016-02-02 02:14:36 +00:00
|
|
|
return info;
|
2016-01-27 10:29:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_loadInspectors = function() {
|
|
|
|
return {
|
|
|
|
totals: require('../inspectors/totals-inspector'),
|
|
|
|
coverage: require('../inspectors/gap-inspector'),
|
|
|
|
keywords: require('../inspectors/keyword-inspector')
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}).call(this);
|
2016-02-02 02:14:36 +00:00
|
|
|
|
|
|
|
//# sourceMappingURL=analyze.js.map
|