1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-10 07:47:07 +01:00
This commit is contained in:
hacksalot
2016-01-14 08:48:07 -05:00
parent 19b30d55ec
commit 7af50c51f6
9 changed files with 262 additions and 124 deletions

View File

@ -66,6 +66,7 @@ Implementation of the 'build' verb for HackMyResume.
// Load the theme...we do this first because the theme choice (FRESH or
// JSON Resume) determines what format we'll convert the resume to.
this.stat( HME.beforeTheme, { theme: _opts.theme });
var tFolder = verifyTheme( _opts.theme );
var theme = loadTheme( tFolder );
this.stat( HME.afterTheme, { theme: theme });
@ -73,15 +74,15 @@ Implementation of the 'build' verb for HackMyResume.
// Check for invalid outputs
var inv = verifyOutputs.call( this, dst, theme );
if( inv && inv.length ) {
throw {fluenterror: HACKMYSTATUS.invalidFormat, data: inv, theme: theme};
this.err( HACKMYSTATUS.invalidFormat, { data: inv, theme: theme } );
}
// Load input resumes...
if( !src || !src.length ) { throw { fluenterror: 3 }; }
if( !src || !src.length ) { this.err( HACKMYSTATUS.resumeNotFound ); }
var sheets = ResumeFactory.load(src, {
format: theme.render ? 'JRS' : 'FRESH',
objectify: true, throw: true, inner: { sort: _opts.sort }
}, this).map(function(sh){ return sh.rez; });
}, this).map( function(sh){ return sh.rez; });
// Merge input resumes...
(sheets.length > 1) && this.stat( HME.beforeMerge, { f: _.clone(sheets) });
@ -179,8 +180,10 @@ Implementation of the 'build' verb for HackMyResume.
}
}
catch( ex ) {
console.log('Exception thrown');
console.log(ex); // TODO
// Catch any errors caused by generating this file and don't let them
// propagate -- typically we want to continue processing other formats
// even if this format failed.
this.err( HME.generate, { inner: ex } );
}
}
@ -282,7 +285,7 @@ Implementation of the 'build' verb for HackMyResume.
if( !exists( tFolder ) ) {
tFolder = PATH.resolve( themeNameOrPath );
if( !exists( tFolder ) ) {
throw { fluenterror: 1, data: _opts.theme };
this.err( HACKMYSTATUS.themeNotFound, { data: _opts.theme } );
}
}
return tFolder;

View File

@ -23,15 +23,30 @@ Definition of the Verb class.
*/
var Verb = module.exports = Class.extend({
/**
Constructor. Automatically called at creation.
*/
init: function( moniker ) {
this.moniker = moniker;
this.emitter = new EVENTS.EventEmitter();
},
/**
Forward subscriptions to the event emitter.
*/
on: function() {
this.emitter.on.apply( this.emitter, arguments );
},
/**
Fire an arbitrary event, scoped to "hmr:".
*/
fire: function(evtName, payload) {
payload = payload || { };
payload.cmd = this.moniker;
@ -39,11 +54,29 @@ Definition of the Verb class.
return true;
},
/**
Fire the 'hmr:error' error event.
*/
err: function( errorCode, payload, hot ) {
payload = payload || { };
payload.sub = payload.fluenterror = errorCode;
payload.throw = hot;
this.fire('error', payload);
if( hot ) throw payload;
return true;
},
/**
Fire the 'hmr:status' error event.
*/
stat: function( subEvent, payload ) {
payload = payload || { };
payload.cmd = this.moniker;
payload.sub = subEvent;
this.emitter.emit( 'hmr:status', payload );
this.fire('status', payload);
return true;
}