(function() { /** Implementation of the 'analyze' verb for HackMyResume. @module verbs/analyze @license MIT. See LICENSE.md for details. */ /** Private workhorse for the 'analyze' command. */ /** Analyze a single resume. */ var AnalyzeVerb, HMEVENT, HMSTATUS, MKDIRP, PATH, ResumeFactory, Verb, _, _analyze, _analyzeOne, _loadInspectors, chalk; 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'); /** An invokable resume analysis command. */ module.exports = AnalyzeVerb = class AnalyzeVerb extends Verb { constructor() { super('analyze', _analyze); } }; _analyze = function(sources, dst, opts) { var nlzrs, results; if (!sources || !sources.length) { this.err(HMSTATUS.resumeNotFound, { quit: true }); return null; } nlzrs = _loadInspectors(); results = _.map(sources, function(src) { var r; r = ResumeFactory.loadOne(src, { format: 'FRESH', objectify: true, inner: { private: opts.private === true } }, this); if (opts.assert && this.hasError()) { return {}; } if (r.fluenterror) { r.quit = opts.assert; this.err(r.fluenterror, r); return r; } else { return _analyzeOne.call(this, r, nlzrs, opts); } }, this); if (this.hasError() && !opts.assert) { this.reject(this.errorCode); } else if (!this.hasError()) { this.resolve(results); } return results; }; _analyzeOne = function(resumeObject, nlzrs, opts) { 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); }); this.stat(HMEVENT.afterAnalyze, { info: info }); return info; }; _loadInspectors = function() { return { totals: require('../inspectors/totals-inspector'), coverage: require('../inspectors/gap-inspector'), keywords: require('../inspectors/keyword-inspector') }; }; }).call(this); //# sourceMappingURL=analyze.js.map