1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-07-03 00:30:05 +01:00

Merge pull request #40 from hacksalot/rel/v1.2.2

rel/v1.2.2
This commit is contained in:
hacksalot 2015-12-24 17:44:56 -05:00
commit 78a8b9c58e
6 changed files with 34 additions and 17 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "hackmyresume", "name": "hackmyresume",
"version": "1.2.1", "version": "1.2.2",
"description": "Generate polished résumés and CVs in HTML, Markdown, LaTeX, MS Word, PDF, plain text, JSON, XML, YAML, smoke signal, and carrier pigeon.", "description": "Generate polished résumés and CVs in HTML, Markdown, LaTeX, MS Word, PDF, plain text, JSON, XML, YAML, smoke signal, and carrier pigeon.",
"repository": { "repository": {
"type": "git", "type": "git",
@ -49,6 +49,7 @@
"minimist": "^1.2.0", "minimist": "^1.2.0",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"moment": "^2.10.6", "moment": "^2.10.6",
"parse-filepath": "^0.6.3",
"path-exists": "^2.1.0", "path-exists": "^2.1.0",
"recursive-readdir-sync": "^1.0.6", "recursive-readdir-sync": "^1.0.6",
"simple-html-tokenizer": "^0.2.0", "simple-html-tokenizer": "^0.2.0",

View File

@ -16,6 +16,7 @@ FRESH to JSON Resume conversion routiens.
/** /**
Convert from JSON Resume format to FRESH. Convert from JSON Resume format to FRESH.
@method toFresh @method toFresh
@todo Refactor
*/ */
toFRESH: function( src, foreign ) { toFRESH: function( src, foreign ) {
@ -67,6 +68,7 @@ FRESH to JSON Resume conversion routiens.
Convert from FRESH format to JSON Resume. Convert from FRESH format to JSON Resume.
@param foreign True if non-JSON-Resume properties should be included in @param foreign True if non-JSON-Resume properties should be included in
the result, false if those properties should be excluded. the result, false if those properties should be excluded.
@todo Refactor
*/ */
toJRS: function( src, foreign ) { toJRS: function( src, foreign ) {
@ -112,6 +114,7 @@ FRESH to JSON Resume conversion routiens.
}; };
function meta( direction, obj ) { function meta( direction, obj ) {
if( !obj ) return obj; // preserve null and undefined
if( direction ) { if( direction ) {
obj = obj || { }; obj = obj || { };
obj.format = obj.format || "FRESH@0.1.0"; obj.format = obj.format || "FRESH@0.1.0";
@ -121,6 +124,7 @@ FRESH to JSON Resume conversion routiens.
} }
function employment( obj, direction ) { function employment( obj, direction ) {
if( !obj ) return obj;
if( !direction ) { if( !direction ) {
return obj && obj.history ? return obj && obj.history ?
obj.history.map(function(emp){ obj.history.map(function(emp){
@ -157,6 +161,7 @@ FRESH to JSON Resume conversion routiens.
function education( obj, direction ) { function education( obj, direction ) {
if( !obj ) return obj;
if( direction ) { if( direction ) {
return obj && obj.length ? { return obj && obj.length ? {
history: obj.map(function(edu){ history: obj.map(function(edu){
@ -191,6 +196,7 @@ FRESH to JSON Resume conversion routiens.
} }
function service( obj, direction, foreign ) { function service( obj, direction, foreign ) {
if( !obj ) return obj;
if( direction ) { if( direction ) {
return { return {
history: obj && obj.length ? obj.map(function(vol) { history: obj && obj.length ? obj.map(function(vol) {
@ -225,6 +231,7 @@ FRESH to JSON Resume conversion routiens.
} }
function social( obj, direction ) { function social( obj, direction ) {
if( !obj ) return obj;
if( direction ) { if( direction ) {
return obj.map(function(pro){ return obj.map(function(pro){
return { return {
@ -247,6 +254,7 @@ FRESH to JSON Resume conversion routiens.
} }
function recognition( obj, direction, foreign ) { function recognition( obj, direction, foreign ) {
if( !obj ) return obj;
if( direction ) { if( direction ) {
return obj && obj.length ? obj.map( return obj && obj.length ? obj.map(
function(awd){ function(awd){
@ -275,6 +283,7 @@ FRESH to JSON Resume conversion routiens.
} }
function references( obj, direction ) { function references( obj, direction ) {
if( !obj ) return obj;
if( direction ) { if( direction ) {
return obj && obj.length && obj.map(function(ref){ return obj && obj.length && obj.map(function(ref){
return { return {
@ -296,6 +305,7 @@ FRESH to JSON Resume conversion routiens.
} }
function writing( obj, direction ) { function writing( obj, direction ) {
if( !obj ) return obj;
if( direction ) { if( direction ) {
return obj.map(function( pub ) { return obj.map(function( pub ) {
return { return {

View File

@ -11,6 +11,7 @@ Definition of the Theme class.
, validator = require('is-my-json-valid') , validator = require('is-my-json-valid')
, _ = require('underscore') , _ = require('underscore')
, PATH = require('path') , PATH = require('path')
, parsePath = require('parse-filepath')
, EXTEND = require('../utils/extend') , EXTEND = require('../utils/extend')
, moment = require('moment') , moment = require('moment')
, RECURSIVE_READ_DIR = require('recursive-readdir-sync'); , RECURSIVE_READ_DIR = require('recursive-readdir-sync');
@ -30,8 +31,8 @@ Definition of the Theme class.
// Open the [theme-name].json file; should have the same name as folder // Open the [theme-name].json file; should have the same name as folder
this.folder = themeFolder; this.folder = themeFolder;
var pathInfo = PATH.parse( themeFolder ); var pathInfo = parsePath( themeFolder );
var themeFile = PATH.join( themeFolder, pathInfo.base + '.json' ); var themeFile = PATH.join( themeFolder, pathInfo.basename + '.json' );
var themeInfo = JSON.parse( FS.readFileSync( themeFile, 'utf8' ) ); var themeInfo = JSON.parse( FS.readFileSync( themeFile, 'utf8' ) );
var that = this; var that = this;
@ -59,7 +60,7 @@ Definition of the Theme class.
this.formats = formatsHash; this.formats = formatsHash;
// Set the official theme name // Set the official theme name
this.name = PATH.parse( this.folder ).name; this.name = parsePath( this.folder ).name;
return this; return this;
}; };
@ -96,9 +97,9 @@ Definition of the Theme class.
// If this file lives in a specific format folder within the theme, // If this file lives in a specific format folder within the theme,
// such as "/latex" or "/html", then that format is the output format // such as "/latex" or "/html", then that format is the output format
// for all files within the folder. // for all files within the folder.
var pathInfo = PATH.parse(absPath); var pathInfo = parsePath(absPath);
var outFmt = '', isMajor = false; var outFmt = '', isMajor = false;
var portion = pathInfo.dir.replace(tplFolder,''); var portion = pathInfo.dirname.replace(tplFolder,'');
if( portion && portion.trim() ) { if( portion && portion.trim() ) {
if( portion[1] === '_' ) return; if( portion[1] === '_' ) return;
var reg = /^(?:\/|\\)(html|latex|doc|pdf|partials)(?:\/|\\)?/ig; var reg = /^(?:\/|\\)(html|latex|doc|pdf|partials)(?:\/|\\)?/ig;
@ -135,7 +136,7 @@ Definition of the Theme class.
path: absPath, path: absPath,
major: isMajor, major: isMajor,
orgPath: PATH.relative(tplFolder, absPath), orgPath: PATH.relative(tplFolder, absPath),
ext: pathInfo.ext.slice(1), ext: pathInfo.extname.slice(1),
title: friendlyName( outFmt ), title: friendlyName( outFmt ),
pre: outFmt, pre: outFmt,
// outFormat: outFmt || pathInfo.name, // outFormat: outFmt || pathInfo.name,
@ -186,7 +187,7 @@ Definition of the Theme class.
act = null; act = null;
// If this file is mentioned in the theme's JSON file under "transforms" // If this file is mentioned in the theme's JSON file under "transforms"
var pathInfo = PATH.parse(absPath); var pathInfo = parsePath(absPath);
var absPathSafe = absPath.trim().toLowerCase(); var absPathSafe = absPath.trim().toLowerCase();
var outFmt = _.find( Object.keys( that.formats ), function( fmtKey ) { var outFmt = _.find( Object.keys( that.formats ), function( fmtKey ) {
var fmtVal = that.formats[ fmtKey ]; var fmtVal = that.formats[ fmtKey ];
@ -203,7 +204,7 @@ Definition of the Theme class.
// such as "/latex" or "/html", then that format is the output format // such as "/latex" or "/html", then that format is the output format
// for all files within the folder. // for all files within the folder.
if( !outFmt ) { if( !outFmt ) {
var portion = pathInfo.dir.replace(tplFolder,''); var portion = pathInfo.dirname.replace(tplFolder,'');
if( portion && portion.trim() ) { if( portion && portion.trim() ) {
var reg = /^(?:\/|\\)(html|latex|doc|pdf)(?:\/|\\)?/ig; var reg = /^(?:\/|\\)(html|latex|doc|pdf)(?:\/|\\)?/ig;
var res = reg.exec( portion ); var res = reg.exec( portion );
@ -231,7 +232,7 @@ Definition of the Theme class.
action: act, action: act,
orgPath: PATH.relative(that.folder, absPath), orgPath: PATH.relative(that.folder, absPath),
path: absPath, path: absPath,
ext: pathInfo.ext.slice(1), ext: pathInfo.extname.slice(1),
title: friendlyName( outFmt ), title: friendlyName( outFmt ),
pre: outFmt, pre: outFmt,
// outFormat: outFmt || pathInfo.name, // outFormat: outFmt || pathInfo.name,

View File

@ -13,6 +13,7 @@ Definition of the TemplateGenerator class.
, MD = require( 'marked' ) , MD = require( 'marked' )
, XML = require( 'xml-escape' ) , XML = require( 'xml-escape' )
, PATH = require('path') , PATH = require('path')
, parsePath = require('parse-filepath')
, MKDIRP = require('mkdirp') , MKDIRP = require('mkdirp')
, BaseGenerator = require( './base-generator' ) , BaseGenerator = require( './base-generator' )
, EXTEND = require('../utils/extend') , EXTEND = require('../utils/extend')
@ -127,7 +128,7 @@ Definition of the TemplateGenerator class.
var theme = themeInfo.theme; var theme = themeInfo.theme;
var tFolder = themeInfo.folder; var tFolder = themeInfo.folder;
var tplFolder = PATH.join( tFolder, 'src' ); var tplFolder = PATH.join( tFolder, 'src' );
var outFolder = PATH.parse(f).dir; var outFolder = parsePath(f).dirname;
var curFmt = theme.getFormat( this.format ); var curFmt = theme.getFormat( this.format );
var that = this; var that = this;
@ -176,7 +177,7 @@ Definition of the TemplateGenerator class.
var absLoc = PATH.join(outFolder, loc); var absLoc = PATH.join(outFolder, loc);
var absTarg = PATH.join(PATH.dirname(absLoc), curFmt.symLinks[loc]); var absTarg = PATH.join(PATH.dirname(absLoc), curFmt.symLinks[loc]);
// 'file', 'dir', or 'junction' (Windows only) // 'file', 'dir', or 'junction' (Windows only)
var type = PATH.parse( absLoc ).ext ? 'file' : 'junction'; var type = parsePath( absLoc ).extname ? 'file' : 'junction';
FS.symlinkSync( absTarg, absLoc, type); FS.symlinkSync( absTarg, absLoc, type);
}); });
} }
@ -221,7 +222,7 @@ Definition of the TemplateGenerator class.
function themeFromMoniker() { function themeFromMoniker() {
// Verify the specified theme name/path // Verify the specified theme name/path
var tFolder = PATH.join( var tFolder = PATH.join(
PATH.parse( require.resolve('fluent-themes') ).dir, parsePath( require.resolve('fluent-themes') ).dirname,
this.opts.theme this.opts.theme
); );
var exists = require('path-exists').sync; var exists = require('path-exists').sync;

View File

@ -91,6 +91,7 @@ function getOpts( args ) {
}; };
} }
// TODO: refactor
function handleError( ex ) { function handleError( ex ) {
var msg = '', exitCode; var msg = '', exitCode;
@ -123,8 +124,10 @@ function handleError( ex ) {
var idx = msg.indexOf('Error: '); var idx = msg.indexOf('Error: ');
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 ); var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
if( !ex.fluenterror || ex.fluenterror < 3 ) if( !ex.fluenterror || ex.fluenterror < 3 ) { // TODO: magic #s
console.log( ('ERROR: ' + trimmed.toString()).red.bold ); console.log( ('ERROR: ' + trimmed.toString()).red.bold );
console.log( ex.stack.gray);
}
else else
console.log( trimmed.toString() ); console.log( trimmed.toString() );

View File

@ -1,6 +1,7 @@
(function() { (function() {
var PATH = require('path') var PATH = require('path')
, parsePath = require('parse-filepath')
, MKDIRP = require('mkdirp') , MKDIRP = require('mkdirp')
, _opts = require('../core/default-options') , _opts = require('../core/default-options')
, FluentTheme = require('../core/theme') , FluentTheme = require('../core/theme')
@ -60,7 +61,7 @@
} }
// Load the theme // Load the theme
var theTheme = new FluentTheme().open( tFolder ); var theTheme = (new FluentTheme()).open( tFolder );
_opts.themeObj = theTheme; _opts.themeObj = theTheme;
_log( 'Applying '.info + theTheme.name.toUpperCase().infoBold + _log( 'Applying '.info + theTheme.name.toUpperCase().infoBold +
(' theme (' + Object.keys(theTheme.formats).length + ' formats)').info); (' theme (' + Object.keys(theTheme.formats).length + ' formats)').info);
@ -70,8 +71,8 @@
( (dst && dst.length && dst) || ['resume.all'] ).forEach( function(t) { ( (dst && dst.length && dst) || ['resume.all'] ).forEach( function(t) {
var to = PATH.resolve(t), var to = PATH.resolve(t),
pa = PATH.parse(to), pa = parsePath(to),
fmat = pa.ext || '.all'; fmat = pa.extname || '.all';
targets.push.apply(targets, fmat === '.all' ? targets.push.apply(targets, fmat === '.all' ?
Object.keys( theTheme.formats ).map(function(k){ Object.keys( theTheme.formats ).map(function(k){