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('-n --no-prettify', 'Disable HTML prettification', true)
|
||||||
.option('-c --css <option>', 'CSS linking / embedding', 'embed')
|
.option('-c --css <option>', 'CSS linking / embedding', 'embed')
|
||||||
.option('-p --pdf <engine>', 'PDF generation engine')
|
.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)
|
.option('--no-tips', 'Disable theme tips and warnings.', false)
|
||||||
.description('Generate resume to multiple formats')
|
.description('Generate resume to multiple formats')
|
||||||
.action(function( sources, targets, options ) {
|
.action(function( sources, targets, options ) {
|
||||||
|
@ -38,10 +38,11 @@ Definition of the FRESHResume class.
|
|||||||
/**
|
/**
|
||||||
Initialize the FreshResume from file.
|
Initialize the FreshResume from file.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.open = function( file, title ) {
|
FreshResume.prototype.open = function( file, opts ) {
|
||||||
this.imp = { fileName: file };
|
var raw = FS.readFileSync( file, 'utf8' );
|
||||||
this.imp.raw = FS.readFileSync( file, 'utf8' );
|
var ret = this.parse( raw, opts );
|
||||||
return this.parse( this.imp.raw, title );
|
this.imp.fileName = file;
|
||||||
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -60,32 +61,46 @@ Definition of the FRESHResume class.
|
|||||||
Open and parse the specified FRESH resume. Merge the JSON object model onto
|
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 &
|
this Sheet instance with extend() and convert sheet dates to a safe &
|
||||||
consistent format. Then sort each section by startDate descending.
|
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 ) {
|
FreshResume.prototype.parseJSON = function( rep, opts ) {
|
||||||
|
|
||||||
// Convert JSON Resume to FRESH if necessary
|
// // Convert JSON Resume to FRESH if necessary
|
||||||
if( rep.basics ) {
|
// // TODO: Not sure if this code path is still executed. JRS resumes should
|
||||||
rep = CONVERTER.toFRESH( rep );
|
// // be loaded via JRSResume, not here.
|
||||||
rep.imp = rep.imp || { };
|
// if( rep.basics ) {
|
||||||
rep.imp.orgFormat = 'JRS';
|
// 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
|
// Now apply the resume representation onto this object
|
||||||
extend( true, this, rep );
|
extend( true, this, rep );
|
||||||
|
|
||||||
// Set up metadata
|
// If the resume already has a .imp object, then we are being called from
|
||||||
opts = opts || { };
|
// the .dupe method, and there's no need to do any post processing
|
||||||
if( opts.imp === undefined || opts.imp ) {
|
if( !this.imp ) {
|
||||||
this.imp = this.imp || { };
|
// Set up metadata TODO: Clean up metadata on the object model.
|
||||||
this.imp.title = (opts.title || this.imp.title) || this.name;
|
opts = opts || { };
|
||||||
|
if( opts.imp === undefined || opts.imp ) {
|
||||||
|
this.imp = this.imp || { };
|
||||||
|
this.imp.title = (opts.title || this.imp.title) || this.name;
|
||||||
|
}
|
||||||
|
// Parse dates, sort dates, and calculate computed values
|
||||||
|
(opts.date === undefined || opts.date) && _parseDates.call( this );
|
||||||
|
(opts.sort === undefined || opts.sort) && this.sort();
|
||||||
|
(opts.compute === undefined || opts.compute) && (this.computed = {
|
||||||
|
numYears: this.duration(),
|
||||||
|
keywords: this.keywords()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Parse dates, sort dates, and calculate computed values
|
|
||||||
(opts.date === undefined || opts.date) && _parseDates.call( this );
|
|
||||||
(opts.sort === undefined || opts.sort) && this.sort();
|
|
||||||
(opts.compute === undefined || opts.compute) && (this.computed = {
|
|
||||||
numYears: this.duration(),
|
|
||||||
keywords: this.keywords()
|
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,10 +137,15 @@ Definition of the FRESHResume class.
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Duplicate this FreshResume instance.
|
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() {
|
FreshResume.prototype.dupe = function() {
|
||||||
|
var jso = extend( true, { }, this );
|
||||||
var rnew = new FreshResume();
|
var rnew = new FreshResume();
|
||||||
rnew.parse( this.stringify(), { } );
|
rnew.parseJSON( jso, { } );
|
||||||
return rnew;
|
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
|
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).
|
a transformation function (such as a Markdown filter or XML encoder).
|
||||||
|
TODO: Move this out of FRESHResume.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.transformStrings = function( filt, transformer ) {
|
FreshResume.prototype.transformStrings = function( filt, transformer ) {
|
||||||
var ret = this.dupe();
|
var ret = this.dupe();
|
||||||
|
@ -31,6 +31,18 @@ Definition of the ResumeFactory class.
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Load one or more resumes from disk.
|
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 ) {
|
load: function ( sources, opts, emitter ) {
|
||||||
|
|
||||||
@ -47,7 +59,7 @@ Definition of the ResumeFactory class.
|
|||||||
*/
|
*/
|
||||||
loadOne: function( src, opts, emitter ) {
|
loadOne: function( src, opts, emitter ) {
|
||||||
|
|
||||||
var toFormat = opts.format;
|
var toFormat = opts.format; // Can be null
|
||||||
var objectify = opts.objectify;
|
var objectify = opts.objectify;
|
||||||
|
|
||||||
// Get the destination format. Can be 'fresh', 'jrs', or null/undefined.
|
// Get the destination format. Can be 'fresh', 'jrs', or null/undefined.
|
||||||
@ -73,7 +85,7 @@ Definition of the ResumeFactory class.
|
|||||||
var rez;
|
var rez;
|
||||||
if( objectify ) {
|
if( objectify ) {
|
||||||
var ResumeClass = require('../core/' + (toFormat || orgFormat) + '-resume');
|
var ResumeClass = require('../core/' + (toFormat || orgFormat) + '-resume');
|
||||||
rez = new ResumeClass().parseJSON( json );
|
rez = new ResumeClass().parseJSON( json, opts.inner );
|
||||||
rez.i().file = src;
|
rez.i().file = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +79,8 @@ Implementation of the 'build' verb for HackMyResume.
|
|||||||
// Load input resumes...
|
// Load input resumes...
|
||||||
if( !src || !src.length ) { throw { fluenterror: 3 }; }
|
if( !src || !src.length ) { throw { fluenterror: 3 }; }
|
||||||
var sheets = ResumeFactory.load(src, {
|
var sheets = ResumeFactory.load(src, {
|
||||||
log: _log, format: theme.render ? 'JRS' : 'FRESH',
|
format: theme.render ? 'JRS' : 'FRESH',
|
||||||
objectify: true, throw: true
|
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...
|
// Merge input resumes...
|
||||||
@ -122,6 +122,7 @@ Implementation of the 'build' verb for HackMyResume.
|
|||||||
_opts.tips = opts.tips;
|
_opts.tips = opts.tips;
|
||||||
_opts.noTips = opts.noTips;
|
_opts.noTips = opts.noTips;
|
||||||
_opts.debug = opts.debug;
|
_opts.debug = opts.debug;
|
||||||
|
_opts.sort = opts.sort;
|
||||||
|
|
||||||
// If two or more files are passed to the GENERATE command and the TO
|
// If two or more files are passed to the GENERATE command and the TO
|
||||||
// keyword is omitted, the last file specifies the output file.
|
// keyword is omitted, the last file specifies the output file.
|
||||||
@ -178,7 +179,8 @@ Implementation of the 'build' verb for HackMyResume.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( ex ) {
|
catch( ex ) {
|
||||||
_err( ex );
|
console.log('Exception thrown');
|
||||||
|
console.log(ex); // TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user