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

Interim changes supporting v1.3.0.

This commit is contained in:
hacksalot
2015-12-31 03:34:41 -05:00
parent 1f6d77fc28
commit 069c02ddcc
10 changed files with 234 additions and 82 deletions

View File

@ -1,3 +1,9 @@
/**
Implementation of the 'convert' verb for HackMyResume.
@module convert.js
@license MIT. See LICENSE.md for details.
*/
(function(){
var ResumeFactory = require('../core/resume-factory');
@ -5,22 +11,23 @@
/**
Convert between FRESH and JRS formats.
*/
module.exports = function convert( src, dst, opts, logger ) {
module.exports = function convert( sources, dst, opts, logger ) {
var _log = logger || console.log;
if( !src || !src.length ) { throw { fluenterror: 6 }; }
if( !sources || !sources.length ) { throw { fluenterror: 6 }; }
if( !dst || !dst.length ) {
if( src.length === 1 ) { throw { fluenterror: 5 }; }
else if( src.length === 2 ) { dst = [ src[1] ]; src = [ src[0] ]; }
if( sources.length === 1 ) { throw { fluenterror: 5 }; }
else if( sources.length === 2 ) { dst = [ sources[1] ]; sources = [ sources[0] ]; }
else { throw { fluenterror: 5 }; }
}
if( src && dst && src.length && dst.length && src.length !== dst.length ) {
if( sources && dst && sources.length && dst.length && sources.length !== dst.length ) {
throw { fluenterror: 7 };
}
var sheets = ResumeFactory.load( src, _log );
sheets.forEach(function(sheet, idx){
var sourceFormat = sheet.imp.orgFormat === 'JRS' ? 'JRS' : 'FRESH';
var sourceResumes = ResumeFactory.load( sources, _log, null, true );
sourceResumes.forEach(function( src, idx ) {
var sheet = src.rez;
var sourceFormat = ((sheet.basics && sheet.basics.imp) || sheet.imp).orgFormat === 'JRS' ? 'JRS' : 'FRESH';
var targetFormat = sourceFormat === 'JRS' ? 'FRESH' : 'JRS';
_log( 'Converting '.useful + sheet.imp.fileName.useful.bold + (' (' +
_log( 'Converting '.useful + src.file.useful.bold + (' (' +
sourceFormat + ') to ').useful + dst[0].useful.bold +
(' (' + targetFormat + ').').useful );
sheet.saveAs( dst[idx], targetFormat );