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

CONVERT: Improve command consistency.

This commit is contained in:
hacksalot
2018-01-30 02:34:58 -05:00
parent 6b125ed907
commit c913de4bf7
19 changed files with 208 additions and 50 deletions

View File

@ -6,11 +6,11 @@ Definition of the ResumeFactory class.
*/
(function() {
var FS, HACKMYSTATUS, HME, ResumeConverter, ResumeFactory, SyntaxErrorEx, _, _parse, chalk;
var FS, HME, HMS, ResumeConverter, ResumeFactory, SyntaxErrorEx, _, _parse, chalk, resumeDetect;
FS = require('fs');
HACKMYSTATUS = require('./status-codes');
HMS = require('./status-codes');
HME = require('./event-codes');
@ -22,6 +22,8 @@ Definition of the ResumeFactory class.
_ = require('underscore');
resumeDetect = require('../utils/resume-detector');
require('string.prototype.startswith');
@ -54,7 +56,7 @@ Definition of the ResumeFactory class.
/** Load a single resume from disk. */
loadOne: function(src, opts, emitter) {
var ResumeClass, info, isFRESH, json, objectify, orgFormat, rez, toFormat;
var ResumeClass, info, json, objectify, orgFormat, reqLib, rez, toFormat;
toFormat = opts.format;
objectify = opts.objectify;
toFormat && (toFormat = toFormat.toLowerCase().trim());
@ -63,14 +65,18 @@ Definition of the ResumeFactory class.
return info;
}
json = info.json;
isFRESH = json.meta && json.meta.format && json.meta.format.startsWith('FRESH@');
orgFormat = isFRESH ? 'fresh' : 'jrs';
orgFormat = resumeDetect(json);
if (orgFormat === 'unk') {
info.fluenterror = HMS.unknownSchema;
return info;
}
if (toFormat && (orgFormat !== toFormat)) {
json = ResumeConverter['to' + toFormat.toUpperCase()](json);
}
rez = null;
if (objectify) {
ResumeClass = require('../core/' + (toFormat || orgFormat) + '-resume');
reqLib = '../core/' + (toFormat || orgFormat) + '-resume';
ResumeClass = require(reqLib);
rez = new ResumeClass().parseJSON(json, opts.inner);
rez.i().file = src;
}
@ -109,7 +115,7 @@ Definition of the ResumeFactory class.
return ret;
} catch (_error) {
return {
fluenterror: rawData ? HACKMYSTATUS.parseError : HACKMYSTATUS.readError,
fluenterror: rawData ? HMS.parseError : HMS.readError,
inner: _error,
raw: rawData,
file: fileName

View File

@ -35,7 +35,8 @@ Status codes for HackMyResume.
createError: 25,
validateError: 26,
invalidOptionsFile: 27,
optionsFileNotFound: 28
optionsFileNotFound: 28,
unknownSchema: 29
};
}).call(this);