From 87b3bbe78568814567cc893204627bf276b26512 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Sun, 20 Dec 2015 18:41:51 -0500 Subject: [PATCH 1/4] Bump version to 1.1.0. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 510cbc2..ae28a43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hackmyresume", - "version": "1.0.1", + "version": "1.1.0", "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": { "type": "git", From cdbb2640933f62e5df4ed1f7a82b03b7e9bee495 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Sun, 20 Dec 2015 18:42:02 -0500 Subject: [PATCH 2/4] Add string convenience method. --- src/utils/string.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/string.js b/src/utils/string.js index 8cee01f..9da084f 100644 --- a/src/utils/string.js +++ b/src/utils/string.js @@ -17,3 +17,7 @@ String.isNullOrWhitespace = function( input ) { String.prototype.endsWith = function(suffix) { return this.indexOf(suffix, this.length - suffix.length) !== -1; }; + +String.is = function( val ) { + return typeof val === 'string' || val instanceof String; +}; From f80c333361549b2889af9f09d4bec22cfd65ab24 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Sun, 20 Dec 2015 20:22:46 -0500 Subject: [PATCH 3/4] Scrub. --- src/eng/generic-helpers.js | 81 ++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 29 deletions(-) diff --git a/src/eng/generic-helpers.js b/src/eng/generic-helpers.js index c1f192b..167c23d 100644 --- a/src/eng/generic-helpers.js +++ b/src/eng/generic-helpers.js @@ -13,19 +13,23 @@ Generic template helper definitions for FluentCV. , _ = require('underscore'); /** - Register useful Handlebars helpers. - @method registerHelpers + Generic template helper function definitions. + @class GenericHelpers */ - module.exports = { + var GenericHelpers = module.exports = { - // Set up a date formatting helper so we can do: - // {{formatDate val 'YYYY-MM'}} + /** + Convert the input date to a specified format through Moment.js. + @method formatDate + */ formatDate: function(datetime, format) { return moment ? moment( datetime ).format( format ) : datetime; }, - // Set up a Markdown-to-WordProcessingML helper so we can do: - // {{wmpl val [true|false]}} + /** + Convert inline Markdown to inline WordProcessingML. + @method wpml + */ wpml: function( txt, inline ) { if(!txt) return ''; inline = (inline && !inline.hash) || false; @@ -36,24 +40,31 @@ Generic template helper definitions for FluentCV. return txt; }, - // Set up a last-word helper so we can do: - // {{lastWord val [true|false]}} + /** + Emit a conditional link. + @method link + */ link: function( text, url ) { return url && url.trim() ? ('' + text + '') : text; }, - // Set up a last-word helper so we can do: - // {{lastWord val [true|false]}} + /** + Return the last word of the specified text. + @method lastWord + */ lastWord: function( txt ) { return txt && txt.trim() ? _.last( txt.split(' ') ) : ''; }, - // Set up a skill colorizing helper: - // {{skillColor val}} - // Skill level can be expressed as a string ("beginner", "intermediate", - // etc.), as an integer (1,5,etc), as a string integer ("1", "5", etc.), - // or as an RRGGBB color triplet ('#C00000', '#FFFFAA'). + /** + Convert a skill level to an RGB color triplet. + @method skillColor + @param lvl Input skill level. Skill level can be expressed as a string + ("beginner", "intermediate", etc.), as an integer (1,5,etc), as a string + integer ("1", "5", etc.), or as an RRGGBB color triplet ('#C00000', + '#FFFFAA'). + */ skillColor: function( lvl ) { var idx = skillLevelToIndex( lvl ); var skillColors = (this.theme && this.theme.palette && @@ -62,40 +73,52 @@ Generic template helper definitions for FluentCV. return skillColors[idx]; }, - // Set up a skill colorizing helper: - // {{skillColor val}} + /** + Return an appropriate height. + @method lastWord + */ skillHeight: function( lvl ) { var idx = skillLevelToIndex( lvl ); return ['38.25', '30', '16', '8', '0'][idx]; }, - // Set up a Markdown-to-WordProcessingML helper so we can do: - // {{initialWords val [true|false]}} + /** + Return all but the last word of the input text. + @method initialWords + */ initialWords: function( txt ) { return txt && txt.trim() ? _.initial( txt.split(' ') ).join(' ') : ''; }, - // Set up a URL-trimming helper to drop the protocol so we can do: - // {{trimURL url}} + /** + Trim the protocol (http or https) from a URL/ + @method trimURL + */ trimURL: function( url ) { return url && url.trim() ? url.trim().replace(/^https?:\/\//i, '') : ''; }, - // Set up a URL-trimming helper to drop the protocol so we can do: - // {{trimURL url}} + /** + Convert text to lowercase. + @method toLower + */ toLower: function( txt ) { return txt && txt.trim() ? txt.toLowerCase() : ''; }, - // Set up a Markdown-to-WordProcessingML helper so we can do: - // {{either A B}} + /** + Return true if either value is truthy. + @method either + */ either: function( lhs, rhs, options ) { if (lhs || rhs) return options.fn(this); }, - // Set up a generic conditional helper so we can do: - // {{compare val otherVal operator="<"}} - // http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/ + /** + Perform a generic comparison. + See: http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates + @method compare + */ compare: function(lvalue, rvalue, options) { if (arguments.length < 3) throw new Error("Handlerbars Helper 'compare' needs 2 parameters"); From 43cd1c7e529c73180c703d07b60ffa3b628a69ed Mon Sep 17 00:00:00 2001 From: hacksalot Date: Sun, 20 Dec 2015 20:53:21 -0500 Subject: [PATCH 4/4] Allow TO keyword to be omitted. If the TO keyword is missing, assume the last file passed in is the destination file. --- src/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 233b43c..68d5c94 100644 --- a/src/index.js +++ b/src/index.js @@ -47,7 +47,6 @@ function main() { opts = getOpts( a ); logMsg( title ); - // Get the action to be performed var params = a._.map( function(p){ return p.toLowerCase().trim(); }); var verb = params[0]; @@ -56,7 +55,7 @@ function main() { return; } - // Get source and dest params + // Find the TO keyword, if any var splitAt = _.indexOf( params, 'to' ); if( splitAt === a._.length - 1 ) { // 'TO' cannot be the last argument @@ -66,8 +65,10 @@ function main() { return; } + // Massage inputs and outputs var src = a._.slice(1, splitAt === -1 ? undefined : splitAt ); var dst = splitAt === -1 ? [] : a._.slice( splitAt + 1 ); + ( splitAt === -1 ) && dst.push( src.pop() ); // Allow omitting TO keyword var parms = [ src, dst, opts, logMsg ]; // Invoke the action