mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 16:30:11 +00:00
Scrub.
This commit is contained in:
parent
13fc903b2b
commit
d8b9d86896
@ -4,35 +4,58 @@ Implementation of the 'convert' verb for HackMyResume.
|
|||||||
@license MIT. See LICENSE.md for details.
|
@license MIT. See LICENSE.md for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
var ResumeFactory = require('../core/resume-factory');
|
|
||||||
var chalk = require('chalk');
|
|
||||||
|
var ResumeFactory = require('../core/resume-factory')
|
||||||
|
, chalk = require('chalk');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Convert between FRESH and JRS formats.
|
Convert between FRESH and JRS formats.
|
||||||
*/
|
*/
|
||||||
module.exports = function convert( sources, dst, opts, logger ) {
|
module.exports = function convert( sources, dst, opts, logger ) {
|
||||||
|
|
||||||
|
// Housekeeping
|
||||||
var _log = logger || console.log;
|
var _log = logger || console.log;
|
||||||
if( !sources || !sources.length ) { throw { fluenterror: 6 }; }
|
if( !sources || !sources.length ) { throw { fluenterror: 6 }; }
|
||||||
if( !dst || !dst.length ) {
|
if( !dst || !dst.length ) {
|
||||||
if( sources.length === 1 ) { throw { fluenterror: 5 }; }
|
if( sources.length === 1 ) { throw { fluenterror: 5 }; }
|
||||||
else if( sources.length === 2 ) { dst = [ sources[1] ]; sources = [ sources[0] ]; }
|
else if( sources.length === 2 ) {
|
||||||
|
dst = [ sources[1] ]; sources = [ sources[0] ];
|
||||||
|
}
|
||||||
else { throw { fluenterror: 5 }; }
|
else { throw { fluenterror: 5 }; }
|
||||||
}
|
}
|
||||||
if( sources && dst && sources.length && dst.length && sources.length !== dst.length ) {
|
if( sources && dst && sources.length && dst.length &&
|
||||||
throw { fluenterror: 7 };
|
sources.length !== dst.length ) { throw { fluenterror: 7 }; }
|
||||||
}
|
|
||||||
var sourceResumes = ResumeFactory.load( sources, { log: _log, format: null, objectify: true, throw: true } );
|
// Load source resumes
|
||||||
|
var sourceResumes = ResumeFactory.load( sources, {
|
||||||
|
log: _log, format: null, objectify: true, throw: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Apply the conversion to each
|
||||||
sourceResumes.forEach(function( src, idx ) {
|
sourceResumes.forEach(function( src, idx ) {
|
||||||
var sheet = src.rez;
|
|
||||||
var sourceFormat = ((sheet.basics && sheet.basics.imp) || sheet.imp).orgFormat === 'JRS' ? 'JRS' : 'FRESH';
|
var s = src.rez
|
||||||
var targetFormat = sourceFormat === 'JRS' ? 'FRESH' : 'JRS';
|
, srcFmt = ((s.basics && s.basics.imp) || s.imp).orgFormat === 'JRS' ?
|
||||||
_log( chalk.green('Converting ') + chalk.green.bold(src.file) + chalk.green(' (' +
|
'JRS' : 'FRESH';
|
||||||
sourceFormat + ') to ') + chalk.green.bold(dst[0]) +
|
|
||||||
|
var targetFormat = srcFmt === 'JRS' ? 'FRESH' : 'JRS';
|
||||||
|
|
||||||
|
// TODO: Core should not log
|
||||||
|
_log( chalk.green('Converting ') + chalk.green.bold(src.file) +
|
||||||
|
chalk.green(' (' + sourceFormat + ') to ') + chalk.green.bold(dst[0]) +
|
||||||
chalk.green(' (' + targetFormat + ').'));
|
chalk.green(' (' + targetFormat + ').'));
|
||||||
sheet.saveAs( dst[idx], targetFormat );
|
|
||||||
|
s.saveAs( dst[idx], targetFormat );
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
Loading…
Reference in New Issue
Block a user