mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 08:20:11 +00:00
Misc improvements.
This commit is contained in:
parent
1966b0a862
commit
1b94ada709
@ -99,6 +99,7 @@ Definition of the `main` function.
|
||||
.option('-n --no-prettify', 'Disable HTML prettification', true)
|
||||
.option('-c --css <option>', 'CSS linking / embedding', 'embed')
|
||||
.option('-p --pdf <engine>', 'PDF generation engine')
|
||||
.option('--no-sort', 'Sort resume sections by date', false)
|
||||
.option('--no-tips', 'Disable theme tips and warnings.', false)
|
||||
.description('Generate resume to multiple formats')
|
||||
.action(function( sources, targets, options ) {
|
||||
|
@ -38,10 +38,11 @@ Definition of the FRESHResume class.
|
||||
/**
|
||||
Initialize the FreshResume from file.
|
||||
*/
|
||||
FreshResume.prototype.open = function( file, title ) {
|
||||
this.imp = { fileName: file };
|
||||
this.imp.raw = FS.readFileSync( file, 'utf8' );
|
||||
return this.parse( this.imp.raw, title );
|
||||
FreshResume.prototype.open = function( file, opts ) {
|
||||
var raw = FS.readFileSync( file, 'utf8' );
|
||||
var ret = this.parse( raw, opts );
|
||||
this.imp.fileName = file;
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
@ -60,20 +61,33 @@ Definition of the FRESHResume class.
|
||||
Open and parse the specified FRESH resume. Merge the JSON object model onto
|
||||
this Sheet instance with extend() and convert sheet dates to a safe &
|
||||
consistent format. Then sort each section by startDate descending.
|
||||
@param rep The raw JSON representation.
|
||||
@param opts Resume loading and parsing options.
|
||||
{
|
||||
date: Perform safe date conversion.
|
||||
sort: Sort resume items by date.
|
||||
computer: Prepare computed resume totals.
|
||||
}
|
||||
*/
|
||||
FreshResume.prototype.parseJSON = function( rep, opts ) {
|
||||
|
||||
// Convert JSON Resume to FRESH if necessary
|
||||
if( rep.basics ) {
|
||||
rep = CONVERTER.toFRESH( rep );
|
||||
rep.imp = rep.imp || { };
|
||||
rep.imp.orgFormat = 'JRS';
|
||||
}
|
||||
// // Convert JSON Resume to FRESH if necessary
|
||||
// // TODO: Not sure if this code path is still executed. JRS resumes should
|
||||
// // be loaded via JRSResume, not here.
|
||||
// if( rep.basics ) {
|
||||
// throw "Invalid resume conversion path";
|
||||
// rep = CONVERTER.toFRESH( rep );
|
||||
// rep.imp = rep.imp || { };
|
||||
// rep.imp.orgFormat = 'JRS';
|
||||
// }
|
||||
|
||||
// Now apply the resume representation onto this object
|
||||
extend( true, this, rep );
|
||||
|
||||
// Set up metadata
|
||||
// If the resume already has a .imp object, then we are being called from
|
||||
// the .dupe method, and there's no need to do any post processing
|
||||
if( !this.imp ) {
|
||||
// Set up metadata TODO: Clean up metadata on the object model.
|
||||
opts = opts || { };
|
||||
if( opts.imp === undefined || opts.imp ) {
|
||||
this.imp = this.imp || { };
|
||||
@ -86,6 +100,7 @@ Definition of the FRESHResume class.
|
||||
numYears: this.duration(),
|
||||
keywords: this.keywords()
|
||||
});
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
@ -122,10 +137,15 @@ Definition of the FRESHResume class.
|
||||
|
||||
/**
|
||||
Duplicate this FreshResume instance.
|
||||
This method first extend()s this object onto an empty, creating a deep copy,
|
||||
and then passes the result into a new FreshResume instance via .parseJSON.
|
||||
We do it this way to create a true clone of the object without re-running any
|
||||
of the associated processing.
|
||||
*/
|
||||
FreshResume.prototype.dupe = function() {
|
||||
var jso = extend( true, { }, this );
|
||||
var rnew = new FreshResume();
|
||||
rnew.parse( this.stringify(), { } );
|
||||
rnew.parseJSON( jso, { } );
|
||||
return rnew;
|
||||
};
|
||||
|
||||
@ -160,6 +180,7 @@ Definition of the FRESHResume class.
|
||||
/**
|
||||
Create a copy of this resume in which all string fields have been run through
|
||||
a transformation function (such as a Markdown filter or XML encoder).
|
||||
TODO: Move this out of FRESHResume.
|
||||
*/
|
||||
FreshResume.prototype.transformStrings = function( filt, transformer ) {
|
||||
var ret = this.dupe();
|
||||
|
@ -31,6 +31,18 @@ Definition of the ResumeFactory class.
|
||||
|
||||
/**
|
||||
Load one or more resumes from disk.
|
||||
|
||||
@param opts An options object with settings for the factory as well as
|
||||
passthrough settings for FRESHResume or JRSResume. Structure:
|
||||
|
||||
{
|
||||
format: 'FRESH', // Format to open as. ('FRESH', 'JRS', null)
|
||||
objectify: true, // FRESH/JRSResume or raw JSON?
|
||||
inner: { // Passthru options for FRESH/JRSResume
|
||||
sort: false
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
load: function ( sources, opts, emitter ) {
|
||||
|
||||
@ -47,7 +59,7 @@ Definition of the ResumeFactory class.
|
||||
*/
|
||||
loadOne: function( src, opts, emitter ) {
|
||||
|
||||
var toFormat = opts.format;
|
||||
var toFormat = opts.format; // Can be null
|
||||
var objectify = opts.objectify;
|
||||
|
||||
// Get the destination format. Can be 'fresh', 'jrs', or null/undefined.
|
||||
@ -73,7 +85,7 @@ Definition of the ResumeFactory class.
|
||||
var rez;
|
||||
if( objectify ) {
|
||||
var ResumeClass = require('../core/' + (toFormat || orgFormat) + '-resume');
|
||||
rez = new ResumeClass().parseJSON( json );
|
||||
rez = new ResumeClass().parseJSON( json, opts.inner );
|
||||
rez.i().file = src;
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,8 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
// Load input resumes...
|
||||
if( !src || !src.length ) { throw { fluenterror: 3 }; }
|
||||
var sheets = ResumeFactory.load(src, {
|
||||
log: _log, format: theme.render ? 'JRS' : 'FRESH',
|
||||
objectify: true, throw: true
|
||||
format: theme.render ? 'JRS' : 'FRESH',
|
||||
objectify: true, throw: true, inner: { sort: _opts.sort }
|
||||
}, this).map(function(sh){ return sh.rez; });
|
||||
|
||||
// Merge input resumes...
|
||||
@ -122,6 +122,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
_opts.tips = opts.tips;
|
||||
_opts.noTips = opts.noTips;
|
||||
_opts.debug = opts.debug;
|
||||
_opts.sort = opts.sort;
|
||||
|
||||
// If two or more files are passed to the GENERATE command and the TO
|
||||
// keyword is omitted, the last file specifies the output file.
|
||||
@ -178,7 +179,8 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
}
|
||||
}
|
||||
catch( ex ) {
|
||||
_err( ex );
|
||||
console.log('Exception thrown');
|
||||
console.log(ex); // TODO
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user