diff --git a/src/fluentcmd.js b/src/fluentcmd.js index cf2c7f5..abb4e05 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -1,10 +1,11 @@ /** -Core resume generation module for FluentCMD. -@license Copyright (c) 2015 by James M. Devlin. All rights reserved. +Internal resume generation logic for FluentCMD. +@license Copyright (c) 2015 | James M. Devlin */ module.exports = function () { + // We don't mind pseudo-globals here var MD = require( 'marked' ) , XML = require( 'xml-escape' ) , HTML = require( 'html' ) @@ -14,20 +15,19 @@ module.exports = function () { , extend = require( './utils/extend' ) , _ = require('underscore') , unused = require('./utils/string') - , FLUENT = require('fluentlib'); - - var rez, _log; + , FLUENT = require('fluentlib') + , rez + , _log; /** - Core resume generation method for HMR. Given a source JSON resume file, a - destination resume spec, and a theme file, generate 0..N resumes in the - requested formats. Requires filesystem access. To perform generation without - filesystem access, use the single() method below. + Core workhorse method for FluentCMD. Given a source JSON resume, a destination + resume path, and a theme file, generate 0..N resumes in the desired formats. @param src Path to the source JSON resume file: "rez/resume.json". - @param dst Path to the destination resume file(s): "rez/resume.all". + @param dst An array of paths to the destination resume file(s): "rez/resume.all". @param theme Friendly name of the resume theme. Defaults to "default". + @param logger Optional logging override. */ - function hmr( src, dst, theme, logger ) { + function gen( src, dst, theme, logger ) { _log = logger || console.log; _opts.theme = theme; @@ -57,7 +57,7 @@ module.exports = function () { }); // Run the transformation! - var finished = targets.map( gen ); + var finished = targets.map( single ); return { sheet: rez,//.rep, @@ -71,7 +71,7 @@ module.exports = function () { @param f Full path to the destination resume to generate, for example, "/foo/bar/resume.pdf" or "c:\foo\bar\resume.txt". */ - function gen( f ) { + function single( f ) { try { // Get the output file type (pdf, html, txt, etc) @@ -113,48 +113,17 @@ module.exports = function () { ]; /** - Default options. + Default options. TODO: Some of these are no longer necessary. */ var _opts = { - prettyPrint: true, - prettyIndent: 2, - keepBreaks: true, - nSym: '&newl;', - rSym: '&retn;', theme: 'default', - sheets: [], - filters: { - out: function( txt ) { return txt; }, - raw: function( txt ) { return txt; }, - xml: function( txt ) { return XML(txt); }, - md: function( txt ) { return MD(txt); }, - mdin: function( txt ) { return MD(txt).replace(/^\s*\
|\<\/p\>\s*$/gi, ''); }, - lower: function( txt ) { return txt.toLowerCase(); } - }, - template: { - interpolate: /\{\{(.+?)\}\}/g, - escape: /\{\{\=(.+?)\}\}/g, - evaluate: /\{\%(.+?)\%\}/g, - comment: /\{\#(.+?)\#\}/g - }, - pdf: 'wkhtmltopdf' } /** - Regexes for linebreak preservation. - */ - var _reg = { - regN: new RegExp( '\n', 'g' ), - regR: new RegExp( '\r', 'g' ), - regSymN: new RegExp( _opts.nSym, 'g' ), - regSymR: new RegExp( _opts.rSym, 'g' ) - }; - - /** - Module public interface. + Module public interface. Used by FCV Desktop. */ return { - generate: hmr, + generate: gen, options: _opts, formats: _fmts }; diff --git a/src/index.js b/src/index.js index 316d1e5..6ce01f8 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,8 @@ #! /usr/bin/env node /** -Command-line resume generation logic for FluentCMD. -@license Copyright (c) 2015 by James M. Devlin. All rights reserved. +Command-line interface (CLI) for FluentCMD via Node.js. +@license Copyright (c) 2015 | James M. Devlin */ var ARGS = require( 'minimist' ) @@ -16,9 +16,8 @@ try { var args = ARGS( process.argv.slice(2) ); var src = args._.filter( function( a ) { return a.endsWith('.json'); }); var dst = args._.filter( function( a ) { return !a.endsWith('.json'); }); - FCMD.generate( src, dst, args.t || 'default' ); - - console.log('\n'); + FCMD.generate( src, dst, args.t || 'informatic' ); + process.platform !== 'win32' && console.log('\n'); } catch( ex ) { diff --git a/src/utils/extend.js b/src/utils/extend.js index 6f08191..3c13cdd 100644 --- a/src/utils/extend.js +++ b/src/utils/extend.js @@ -1,6 +1,6 @@ /** Plain JavaScript replacement of jQuery .extend based on jQuery sources. -@license Copyright (c) 2015 by James M. Devlin. All rights reserved. +@license Copyright (c) 2015 | James M. Devlin */ function _extend() { diff --git a/src/utils/string.js b/src/utils/string.js index 905fc43..2ec3a88 100644 --- a/src/utils/string.js +++ b/src/utils/string.js @@ -1,6 +1,6 @@ /** String utility functions. -@license Copyright (c) 2015 by James M. Devlin. All rights reserved. +@license Copyright (c) 2015 | James M. Devlin */ /**