1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 16:30:11 +00:00

Refactor generators to CoffeeScript classes.

This commit is contained in:
hacksalot 2016-02-02 13:38:12 -05:00
parent 63a0c78fc5
commit f72b02a0f4
26 changed files with 276 additions and 183 deletions

View File

@ -1,34 +1,39 @@
/** /**
Definition of the BaseGenerator class. Definition of the BaseGenerator class.
@module base-generator.js @module generators/base-generator
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
*/ */
(function() {
var BaseGenerator, Class;
Class = require('../utils/class');
/** /**
The BaseGenerator class is the root of the generator hierarchy. Functionality The BaseGenerator class is the root of the generator hierarchy. Functionality
common to ALL generators lives here. common to ALL generators lives here.
*/ */
BaseGenerator = module.exports = Class.extend({ (function() {
var BaseGenerator;
module.exports = BaseGenerator = (function() {
/** Base-class initialize. */ /** Base-class initialize. */
init: function(outputFormat) { function BaseGenerator(format) {
return this.format = outputFormat; this.format = format;
}, }
/** Status codes. */ /** Status codes. */
codes: require('../core/status-codes'),
BaseGenerator.prototype.codes = require('../core/status-codes');
/** Generator options. */ /** Generator options. */
opts: {}
}); BaseGenerator.prototype.opts = {};
return BaseGenerator;
})();
}).call(this); }).call(this);

View File

@ -1,12 +1,14 @@
/** /**
Definition of the HTMLGenerator class. Definition of the HTMLGenerator class.
@module generators/html-generator
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
@module html-generator.js
*/ */
(function() { (function() {
var FS, HTML, HtmlGenerator, PATH, TemplateGenerator; var FS, HTML, HtmlGenerator, PATH, TemplateGenerator,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
TemplateGenerator = require('./template-generator'); TemplateGenerator = require('./template-generator');
@ -18,16 +20,20 @@ Definition of the HTMLGenerator class.
require('string.prototype.endswith'); require('string.prototype.endswith');
HtmlGenerator = module.exports = TemplateGenerator.extend({ module.exports = HtmlGenerator = (function(superClass) {
init: function() { extend(HtmlGenerator, superClass);
return this._super('html');
}, function HtmlGenerator() {
HtmlGenerator.__super__.constructor.call(this, 'html');
}
/** /**
Copy satellite CSS files to the destination and optionally pretty-print Copy satellite CSS files to the destination and optionally pretty-print
the HTML resume prior to saving. the HTML resume prior to saving.
*/ */
onBeforeSave: function(info) {
HtmlGenerator.prototype.onBeforeSave = function(info) {
if (info.outputFile.endsWith('.css')) { if (info.outputFile.endsWith('.css')) {
return info.mk; return info.mk;
} }
@ -36,8 +42,11 @@ Definition of the HTMLGenerator class.
} else { } else {
return info.mk; return info.mk;
} }
} };
});
return HtmlGenerator;
})(TemplateGenerator);
}).call(this); }).call(this);

View File

@ -1,12 +1,14 @@
/** /**
Definition of the HtmlPdfCLIGenerator class. Definition of the HtmlPdfCLIGenerator class.
@module html-pdf-generator.js @module generators/html-pdf-generator.js
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
*/ */
(function() { (function() {
var FS, HMSTATUS, HtmlPdfCLIGenerator, PATH, SLASH, TemplateGenerator, _, engines; var FS, HMSTATUS, HtmlPdfCLIGenerator, PATH, SLASH, TemplateGenerator, _, engines,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
TemplateGenerator = require('./template-generator'); TemplateGenerator = require('./template-generator');
@ -27,13 +29,17 @@ Definition of the HtmlPdfCLIGenerator class.
If an engine isn't installed for a particular platform, error out gracefully. If an engine isn't installed for a particular platform, error out gracefully.
*/ */
HtmlPdfCLIGenerator = module.exports = TemplateGenerator.extend({ module.exports = HtmlPdfCLIGenerator = (function(superClass) {
init: function() { extend(HtmlPdfCLIGenerator, superClass);
return this._super('pdf', 'html');
}, function HtmlPdfCLIGenerator() {
HtmlPdfCLIGenerator.__super__.constructor.call(this, 'pdf', 'html');
}
/** Generate the binary PDF. */ /** Generate the binary PDF. */
onBeforeSave: function(info) {
HtmlPdfCLIGenerator.prototype.onBeforeSave = function(info) {
var safe_eng; var safe_eng;
safe_eng = info.opts.pdf || 'wkhtmltopdf'; safe_eng = info.opts.pdf || 'wkhtmltopdf';
if (safe_eng === 'phantom') { if (safe_eng === 'phantom') {
@ -45,22 +51,27 @@ Definition of the HtmlPdfCLIGenerator class.
engines[safe_eng].call(this, info.mk, info.outputFile, this.onError); engines[safe_eng].call(this, info.mk, info.outputFile, this.onError);
return null; return null;
} }
}, };
/* Low-level error callback for spawn(). May be called after HMR process /* Low-level error callback for spawn(). May be called after HMR process
termination, so object references may not be valid here. That's okay; if termination, so object references may not be valid here. That's okay; if
the references are invalid, the error was already logged. We could use the references are invalid, the error was already logged. We could use
spawn-watch here but that causes issues on legacy Node.js. spawn-watch here but that causes issues on legacy Node.js.
*/ */
onError: function(ex, param) {
HtmlPdfCLIGenerator.prototype.onError = function(ex, param) {
var ref; var ref;
if ((ref = param.errHandler) != null) { if ((ref = param.errHandler) != null) {
if (typeof ref.err === "function") { if (typeof ref.err === "function") {
ref.err(HMSTATUS.pdfGeneration, ex); ref.err(HMSTATUS.pdfGeneration, ex);
} }
} }
} };
});
return HtmlPdfCLIGenerator;
})(TemplateGenerator);
engines = { engines = {

View File

@ -1,12 +1,14 @@
/** /**
Definition of the HtmlPngGenerator class. Definition of the HtmlPngGenerator class.
@module generators/html-png-generator
@license MIT. See LICENSE.MD for details. @license MIT. See LICENSE.MD for details.
@module html-png-generator.js
*/ */
(function() { (function() {
var FS, HTML, HtmlPngGenerator, PATH, SLASH, SPAWN, TemplateGenerator, phantom; var FS, HTML, HtmlPngGenerator, PATH, SLASH, SPAWN, TemplateGenerator, phantom,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
TemplateGenerator = require('./template-generator'); TemplateGenerator = require('./template-generator');
@ -25,12 +27,16 @@ Definition of the HtmlPngGenerator class.
An HTML-based PNG resume generator for HackMyResume. An HTML-based PNG resume generator for HackMyResume.
*/ */
HtmlPngGenerator = module.exports = TemplateGenerator.extend({ module.exports = HtmlPngGenerator = (function(superClass) {
init: function() { extend(HtmlPngGenerator, superClass);
return this._super('png', 'html');
}, function HtmlPngGenerator() {
invoke: function(rez, themeMarkup, cssInfo, opts) {}, HtmlPngGenerator.__super__.constructor.call(this, 'png', 'html');
generate: function(rez, f, opts) { }
HtmlPngGenerator.prototype.invoke = function(rez, themeMarkup, cssInfo, opts) {};
HtmlPngGenerator.prototype.generate = function(rez, f, opts) {
var htmlFile, htmlResults; var htmlFile, htmlResults;
htmlResults = opts.targets.filter(function(t) { htmlResults = opts.targets.filter(function(t) {
return t.fmt.outFormat === 'html'; return t.fmt.outFormat === 'html';
@ -39,8 +45,11 @@ Definition of the HtmlPngGenerator class.
return fl.info.ext === 'html'; return fl.info.ext === 'html';
}); });
phantom(htmlFile[0].data, f); phantom(htmlFile[0].data, f);
} };
});
return HtmlPngGenerator;
})(TemplateGenerator);
/** /**

View File

@ -1,12 +1,14 @@
/** /**
Definition of the JsonGenerator class. Definition of the JsonGenerator class.
@license MIT. See LICENSE.md for details.
@module generators/json-generator @module generators/json-generator
@license MIT. See LICENSE.md for details.
*/ */
(function() { (function() {
var BaseGenerator, FS, JsonGenerator, _; var BaseGenerator, FS, JsonGenerator, _,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
BaseGenerator = require('./base-generator'); BaseGenerator = require('./base-generator');
@ -15,16 +17,18 @@ Definition of the JsonGenerator class.
_ = require('underscore'); _ = require('underscore');
/** /** The JsonGenerator generates a JSON resume directly. */
The JsonGenerator generates a JSON resume directly.
*/
JsonGenerator = module.exports = BaseGenerator.extend({ module.exports = JsonGenerator = (function(superClass) {
init: function() { extend(JsonGenerator, superClass);
return this._super('json');
}, function JsonGenerator() {
keys: ['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index', 'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result', 'isModified', 'htmlPreview', 'safe'], JsonGenerator.__super__.constructor.call(this, 'json');
invoke: function(rez) { }
JsonGenerator.prototype.keys = ['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index', 'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result', 'isModified', 'htmlPreview', 'safe'];
JsonGenerator.prototype.invoke = function(rez) {
var replacer; var replacer;
replacer = function(key, value) { replacer = function(key, value) {
if (_.some(this.keys, function(val) { if (_.some(this.keys, function(val) {
@ -36,11 +40,15 @@ Definition of the JsonGenerator class.
} }
}; };
return JSON.stringify(rez, replacer, 2); return JSON.stringify(rez, replacer, 2);
}, };
generate: function(rez, f) {
JsonGenerator.prototype.generate = function(rez, f) {
FS.writeFileSync(f, this.invoke(rez), 'utf8'); FS.writeFileSync(f, this.invoke(rez), 'utf8');
} };
});
return JsonGenerator;
})(BaseGenerator);
}).call(this); }).call(this);

View File

@ -1,12 +1,14 @@
/** /**
Definition of the JsonYamlGenerator class. Definition of the JsonYamlGenerator class.
@module json-yaml-generator.js @module generators/json-yaml-generator
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
*/ */
(function() { (function() {
var BaseGenerator, FS, JsonYamlGenerator, YAML; var BaseGenerator, FS, JsonYamlGenerator, YAML,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
BaseGenerator = require('./base-generator'); BaseGenerator = require('./base-generator');
@ -21,20 +23,27 @@ Definition of the JsonYamlGenerator class.
also YamlGenerator (yaml-generator.js). also YamlGenerator (yaml-generator.js).
*/ */
JsonYamlGenerator = module.exports = BaseGenerator.extend({ module.exports = JsonYamlGenerator = (function(superClass) {
init: function() { extend(JsonYamlGenerator, superClass);
return this._super('yml');
}, function JsonYamlGenerator() {
invoke: function(rez, themeMarkup, cssInfo, opts) { JsonYamlGenerator.__super__.constructor.call(this, 'yml');
}
JsonYamlGenerator.prototype.invoke = function(rez, themeMarkup, cssInfo, opts) {
return YAML.stringify(JSON.parse(rez.stringify()), Infinity, 2); return YAML.stringify(JSON.parse(rez.stringify()), Infinity, 2);
}, };
generate: function(rez, f, opts) {
JsonYamlGenerator.prototype.generate = function(rez, f, opts) {
var data; var data;
data = YAML.stringify(JSON.parse(rez.stringify()), Infinity, 2); data = YAML.stringify(JSON.parse(rez.stringify()), Infinity, 2);
FS.writeFileSync(f, data, 'utf8'); FS.writeFileSync(f, data, 'utf8');
return data; return data;
} };
});
return JsonYamlGenerator;
})(BaseGenerator);
}).call(this); }).call(this);

View File

@ -1,12 +1,14 @@
/** /**
Definition of the LaTeXGenerator class. Definition of the LaTeXGenerator class.
@license MIT. See LICENSE.md for details.
@module generators/latex-generator @module generators/latex-generator
@license MIT. See LICENSE.md for details.
*/ */
(function() { (function() {
var LaTeXGenerator, TemplateGenerator; var LaTeXGenerator, TemplateGenerator,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
TemplateGenerator = require('./template-generator'); TemplateGenerator = require('./template-generator');
@ -15,11 +17,16 @@ Definition of the LaTeXGenerator class.
LaTeXGenerator generates a LaTeX resume via TemplateGenerator. LaTeXGenerator generates a LaTeX resume via TemplateGenerator.
*/ */
LaTeXGenerator = module.exports = TemplateGenerator.extend({ module.exports = LaTeXGenerator = (function(superClass) {
init: function() { extend(LaTeXGenerator, superClass);
return this._super('latex', 'tex');
function LaTeXGenerator() {
LaTeXGenerator.__super__.constructor.call(this, 'latex', 'tex');
} }
});
return LaTeXGenerator;
})(TemplateGenerator);
}).call(this); }).call(this);

View File

@ -1,12 +1,14 @@
/** /**
Definition of the MarkdownGenerator class. Definition of the MarkdownGenerator class.
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. @module generators/markdown-generator
@module markdown-generator.js @license MIT. See LICENSE.md for details.
*/ */
(function() { (function() {
var MarkdownGenerator, TemplateGenerator; var MarkdownGenerator, TemplateGenerator,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
TemplateGenerator = require('./template-generator'); TemplateGenerator = require('./template-generator');
@ -15,11 +17,16 @@ Definition of the MarkdownGenerator class.
MarkdownGenerator generates a Markdown-formatted resume via TemplateGenerator. MarkdownGenerator generates a Markdown-formatted resume via TemplateGenerator.
*/ */
MarkdownGenerator = module.exports = TemplateGenerator.extend({ module.exports = MarkdownGenerator = (function(superClass) {
init: function() { extend(MarkdownGenerator, superClass);
return this._super('md', 'txt');
function MarkdownGenerator() {
MarkdownGenerator.__super__.constructor.call(this, 'md', 'txt');
} }
});
return MarkdownGenerator;
})(TemplateGenerator);
}).call(this); }).call(this);

View File

@ -1,12 +1,14 @@
/** /**
Definition of the TemplateGenerator class. TODO: Refactor Definition of the TemplateGenerator class. TODO: Refactor
@module generators/template-generator
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
@module template-generator.js
*/ */
(function() { (function() {
var BaseGenerator, EXTEND, FRESHTheme, FS, JRSTheme, MD, MKDIRP, PATH, TemplateGenerator, XML, _, _defaultOpts, _reg, freeze, parsePath, unfreeze; var BaseGenerator, EXTEND, FRESHTheme, FS, JRSTheme, MD, MKDIRP, PATH, TemplateGenerator, XML, _, _defaultOpts, _reg, freeze, parsePath, unfreeze,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
FS = require('fs-extra'); FS = require('fs-extra');
@ -38,16 +40,21 @@ Definition of the TemplateGenerator class. TODO: Refactor
@class TemplateGenerator @class TemplateGenerator
*/ */
TemplateGenerator = module.exports = BaseGenerator.extend({ module.exports = TemplateGenerator = (function(superClass) {
extend(TemplateGenerator, superClass);
/** Constructor. Set the output format and template format for this /** Constructor. Set the output format and template format for this
generator. Will usually be called by a derived generator such as generator. Will usually be called by a derived generator such as
HTMLGenerator or MarkdownGenerator. HTMLGenerator or MarkdownGenerator.
*/ */
init: function(outputFormat, templateFormat, cssFile) {
this._super(outputFormat); function TemplateGenerator(outputFormat, templateFormat, cssFile) {
TemplateGenerator.__super__.constructor.call(this, outputFormat);
this.tplFormat = templateFormat || outputFormat; this.tplFormat = templateFormat || outputFormat;
}, return;
}
/** Generate a resume using string-based inputs and outputs without touching /** Generate a resume using string-based inputs and outputs without touching
the filesystem. the filesystem.
@ -57,7 +64,8 @@ Definition of the TemplateGenerator class. TODO: Refactor
@returns {Array} An array of objects representing the generated output @returns {Array} An array of objects representing the generated output
files. files.
*/ */
invoke: function(rez, opts) {
TemplateGenerator.prototype.invoke = function(rez, opts) {
var curFmt, results; var curFmt, results;
opts = opts ? (this.opts = EXTEND(true, {}, _defaultOpts, opts)) : this.opts; opts = opts ? (this.opts = EXTEND(true, {}, _defaultOpts, opts)) : this.opts;
curFmt = opts.themeObj.getFormat(this.format); curFmt = opts.themeObj.getFormat(this.format);
@ -80,7 +88,8 @@ Definition of the TemplateGenerator class. TODO: Refactor
return { return {
files: results files: results
}; };
}, };
/** Generate a resume using file-based inputs and outputs. Requires access /** Generate a resume using file-based inputs and outputs. Requires access
to the local filesystem. to the local filesystem.
@ -89,7 +98,8 @@ Definition of the TemplateGenerator class. TODO: Refactor
@param f Full path to the output resume file to generate. @param f Full path to the output resume file to generate.
@param opts Generator options. @param opts Generator options.
*/ */
generate: function(rez, f, opts) {
TemplateGenerator.prototype.generate = function(rez, f, opts) {
var curFmt, genInfo, outFolder; var curFmt, genInfo, outFolder;
this.opts = EXTEND(true, {}, _defaultOpts, opts); this.opts = EXTEND(true, {}, _defaultOpts, opts);
genInfo = this.invoke(rez, null); genInfo = this.invoke(rez, null);
@ -136,7 +146,8 @@ Definition of the TemplateGenerator class. TODO: Refactor
}); });
} }
return genInfo; return genInfo;
}, };
/** Perform a single resume resume transformation using string-based inputs /** Perform a single resume resume transformation using string-based inputs
and outputs without touching the local file system. and outputs without touching the local file system.
@ -146,7 +157,8 @@ Definition of the TemplateGenerator class. TODO: Refactor
@param cssInfo Needs to be refactored. @param cssInfo Needs to be refactored.
@param opts Options and passthrough data. @param opts Options and passthrough data.
*/ */
single: function(json, jst, format, opts, theme, curFmt) {
TemplateGenerator.prototype.single = function(json, jst, format, opts, theme, curFmt) {
var eng, result; var eng, result;
if (this.opts.freezeBreaks) { if (this.opts.freezeBreaks) {
jst = freeze(jst); jst = freeze(jst);
@ -157,13 +169,11 @@ Definition of the TemplateGenerator class. TODO: Refactor
result = unfreeze(result); result = unfreeze(result);
} }
return result; return result;
} };
});
return TemplateGenerator;
/** Export the TemplateGenerator function/ctor. */ })(BaseGenerator);
module.exports = TemplateGenerator;
/** Freeze newlines for protection against errant JST parsers. */ /** Freeze newlines for protection against errant JST parsers. */

View File

@ -1,12 +1,14 @@
/** /**
Definition of the TextGenerator class. Definition of the TextGenerator class.
@module generators/text-generator
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
@module text-generator.js
*/ */
(function() { (function() {
var TemplateGenerator, TextGenerator; var TemplateGenerator, TextGenerator,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
TemplateGenerator = require('./template-generator'); TemplateGenerator = require('./template-generator');
@ -15,11 +17,16 @@ Definition of the TextGenerator class.
The TextGenerator generates a plain-text resume via the TemplateGenerator. The TextGenerator generates a plain-text resume via the TemplateGenerator.
*/ */
TextGenerator = module.exports = TemplateGenerator.extend({ module.exports = TextGenerator = (function(superClass) {
init: function() { extend(TextGenerator, superClass);
return this._super('txt');
function TextGenerator() {
TextGenerator.__super__.constructor.call(this, 'txt');
} }
});
return TextGenerator;
})(TemplateGenerator);
}).call(this); }).call(this);

View File

@ -1,20 +1,31 @@
/* /*
Definition of the WordGenerator class. Definition of the WordGenerator class.
@license MIT. See LICENSE.md for details.
@module generators/word-generator @module generators/word-generator
@license MIT. See LICENSE.md for details.
*/ */
(function() { (function() {
var TemplateGenerator, WordGenerator; var TemplateGenerator, WordGenerator,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
TemplateGenerator = require('./template-generator'); TemplateGenerator = require('./template-generator');
WordGenerator = module.exports = TemplateGenerator.extend({ module.exports = WordGenerator = (function(superClass) {
init: function() { extend(WordGenerator, superClass);
return this._super('doc', 'xml');
function WordGenerator() {
return WordGenerator.__super__.constructor.apply(this, arguments);
} }
});
WordGenerator.prototype.init = function() {
return WordGenerator.__super__.init.call(this, 'doc', 'xml');
};
return WordGenerator;
})(TemplateGenerator);
}).call(this); }).call(this);

View File

@ -6,20 +6,25 @@ Definition of the XMLGenerator class.
*/ */
(function() { (function() {
var BaseGenerator, XMLGenerator; var BaseGenerator, XMLGenerator,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
BaseGenerator = require('./base-generator'); BaseGenerator = require('./base-generator');
/** /** The XmlGenerator generates an XML resume via the TemplateGenerator. */
The XmlGenerator generates an XML resume via the TemplateGenerator.
*/
XMLGenerator = module.exports = BaseGenerator.extend({ module.exports = XMLGenerator = (function(superClass) {
init: function() { extend(XMLGenerator, superClass);
return this._super('xml');
function XMLGenerator() {
XMLGenerator.__super__.constructor.call(this, 'xml');
} }
});
return XMLGenerator;
})(BaseGenerator);
}).call(this); }).call(this);

View File

@ -6,7 +6,9 @@ Definition of the YAMLGenerator class.
*/ */
(function() { (function() {
var TemplateGenerator, YAMLGenerator; var TemplateGenerator, YAMLGenerator,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
TemplateGenerator = require('./template-generator'); TemplateGenerator = require('./template-generator');
@ -15,11 +17,16 @@ Definition of the YAMLGenerator class.
YamlGenerator generates a YAML-formatted resume via TemplateGenerator. YamlGenerator generates a YAML-formatted resume via TemplateGenerator.
*/ */
YAMLGenerator = module.exports = TemplateGenerator.extend({ module.exports = YAMLGenerator = (function(superClass) {
init: function() { extend(YAMLGenerator, superClass);
return this._super('yml', 'yml');
function YAMLGenerator() {
YAMLGenerator.__super__.constructor.call(this, 'yml', 'yml');
} }
});
return YAMLGenerator;
})(TemplateGenerator);
}).call(this); }).call(this);

View File

@ -1,25 +1,19 @@
###* ###*
Definition of the BaseGenerator class. Definition of the BaseGenerator class.
@module base-generator.js @module generators/base-generator
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
### ###
# Use J. Resig's nifty class implementation
Class = require '../utils/class'
###* ###*
The BaseGenerator class is the root of the generator hierarchy. Functionality The BaseGenerator class is the root of the generator hierarchy. Functionality
common to ALL generators lives here. common to ALL generators lives here.
### ###
BaseGenerator = module.exports = Class.extend module.exports = class BaseGenerator
###* Base-class initialize. ### ###* Base-class initialize. ###
init: ( outputFormat ) -> @format = outputFormat constructor: ( @format ) ->
###* Status codes. ### ###* Status codes. ###
codes: require '../core/status-codes' codes: require '../core/status-codes'

View File

@ -1,7 +1,7 @@
###* ###*
Definition of the HTMLGenerator class. Definition of the HTMLGenerator class.
@module generators/html-generator
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
@module html-generator.js
### ###
@ -14,9 +14,9 @@ require 'string.prototype.endswith'
HtmlGenerator = module.exports = TemplateGenerator.extend module.exports = class HtmlGenerator extends TemplateGenerator
init: -> @_super 'html' constructor: -> super 'html'
###* ###*
Copy satellite CSS files to the destination and optionally pretty-print Copy satellite CSS files to the destination and optionally pretty-print

View File

@ -1,6 +1,6 @@
###* ###*
Definition of the HtmlPdfCLIGenerator class. Definition of the HtmlPdfCLIGenerator class.
@module html-pdf-generator.js @module generators/html-pdf-generator.js
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
### ###
@ -21,11 +21,11 @@ wkhtmltopdf, and other PDF engines over a CLI (command-line interface).
If an engine isn't installed for a particular platform, error out gracefully. If an engine isn't installed for a particular platform, error out gracefully.
### ###
HtmlPdfCLIGenerator = module.exports = TemplateGenerator.extend module.exports = class HtmlPdfCLIGenerator extends TemplateGenerator
init: () -> @_super 'pdf', 'html' constructor: () -> super 'pdf', 'html'

View File

@ -1,7 +1,7 @@
###* ###*
Definition of the HtmlPngGenerator class. Definition of the HtmlPngGenerator class.
@module generators/html-png-generator
@license MIT. See LICENSE.MD for details. @license MIT. See LICENSE.MD for details.
@module html-png-generator.js
### ###
@ -17,9 +17,9 @@ PATH = require 'path'
###* ###*
An HTML-based PNG resume generator for HackMyResume. An HTML-based PNG resume generator for HackMyResume.
### ###
HtmlPngGenerator = module.exports = TemplateGenerator.extend module.exports = class HtmlPngGenerator extends TemplateGenerator
init: -> @_super 'png', 'html' constructor: -> super 'png', 'html'
invoke: ( rez, themeMarkup, cssInfo, opts ) -> invoke: ( rez, themeMarkup, cssInfo, opts ) ->
# TODO: Not currently called or callable. # TODO: Not currently called or callable.

View File

@ -1,20 +1,18 @@
###* ###*
Definition of the JsonGenerator class. Definition of the JsonGenerator class.
@license MIT. See LICENSE.md for details.
@module generators/json-generator @module generators/json-generator
@license MIT. See LICENSE.md for details.
### ###
BaseGenerator = require './base-generator' BaseGenerator = require './base-generator'
FS = require 'fs' FS = require 'fs'
_ = require 'underscore' _ = require 'underscore'
###* ###* The JsonGenerator generates a JSON resume directly. ###
The JsonGenerator generates a JSON resume directly.
###
JsonGenerator = module.exports = BaseGenerator.extend module.exports = class JsonGenerator extends BaseGenerator
init: () -> @_super 'json' constructor: () -> super 'json'
keys: ['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index', keys: ['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result', 'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',

View File

@ -1,6 +1,6 @@
###* ###*
Definition of the JsonYamlGenerator class. Definition of the JsonYamlGenerator class.
@module json-yaml-generator.js @module generators/json-yaml-generator
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
### ###
@ -18,9 +18,9 @@ JSON without a template, producing an equivalent YAML-formatted resume. See
also YamlGenerator (yaml-generator.js). also YamlGenerator (yaml-generator.js).
### ###
JsonYamlGenerator = module.exports = BaseGenerator.extend module.exports = class JsonYamlGenerator extends BaseGenerator
init: () -> @_super 'yml' constructor: () -> super 'yml'
invoke: ( rez, themeMarkup, cssInfo, opts ) -> invoke: ( rez, themeMarkup, cssInfo, opts ) ->
YAML.stringify JSON.parse( rez.stringify() ), Infinity, 2 YAML.stringify JSON.parse( rez.stringify() ), Infinity, 2

View File

@ -1,7 +1,7 @@
###* ###*
Definition of the LaTeXGenerator class. Definition of the LaTeXGenerator class.
@license MIT. See LICENSE.md for details.
@module generators/latex-generator @module generators/latex-generator
@license MIT. See LICENSE.md for details.
### ###
TemplateGenerator = require './template-generator' TemplateGenerator = require './template-generator'
@ -9,6 +9,6 @@ TemplateGenerator = require './template-generator'
###* ###*
LaTeXGenerator generates a LaTeX resume via TemplateGenerator. LaTeXGenerator generates a LaTeX resume via TemplateGenerator.
### ###
LaTeXGenerator = module.exports = TemplateGenerator.extend module.exports = class LaTeXGenerator extends TemplateGenerator
init: () -> @_super 'latex', 'tex' constructor: () -> super 'latex', 'tex'

View File

@ -1,7 +1,7 @@
###* ###*
Definition of the MarkdownGenerator class. Definition of the MarkdownGenerator class.
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. @module generators/markdown-generator
@module markdown-generator.js @license MIT. See LICENSE.md for details.
### ###
TemplateGenerator = require './template-generator' TemplateGenerator = require './template-generator'
@ -9,6 +9,6 @@ TemplateGenerator = require './template-generator'
###* ###*
MarkdownGenerator generates a Markdown-formatted resume via TemplateGenerator. MarkdownGenerator generates a Markdown-formatted resume via TemplateGenerator.
### ###
MarkdownGenerator = module.exports = TemplateGenerator.extend module.exports = class MarkdownGenerator extends TemplateGenerator
init: () -> @_super 'md', 'txt' constructor: () -> super 'md', 'txt'

View File

@ -1,7 +1,7 @@
###* ###*
Definition of the TemplateGenerator class. TODO: Refactor Definition of the TemplateGenerator class. TODO: Refactor
@module generators/template-generator
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
@module template-generator.js
### ###
@ -27,14 +27,14 @@ plain text, and XML versions of Microsoft Word, Excel, and OpenOffice.
@class TemplateGenerator @class TemplateGenerator
### ###
TemplateGenerator = module.exports = BaseGenerator.extend module.exports = class TemplateGenerator extends BaseGenerator
###* Constructor. Set the output format and template format for this ###* Constructor. Set the output format and template format for this
generator. Will usually be called by a derived generator such as generator. Will usually be called by a derived generator such as
HTMLGenerator or MarkdownGenerator. ### HTMLGenerator or MarkdownGenerator. ###
init: ( outputFormat, templateFormat, cssFile ) -> constructor: ( outputFormat, templateFormat, cssFile ) ->
@_super outputFormat super outputFormat
@tplFormat = templateFormat || outputFormat @tplFormat = templateFormat || outputFormat
return return
@ -149,11 +149,6 @@ TemplateGenerator = module.exports = BaseGenerator.extend
###* Export the TemplateGenerator function/ctor. ###
module.exports = TemplateGenerator
###* Freeze newlines for protection against errant JST parsers. ### ###* Freeze newlines for protection against errant JST parsers. ###
freeze = ( markup ) -> freeze = ( markup ) ->
markup.replace( _reg.regN, _defaultOpts.nSym ) markup.replace( _reg.regN, _defaultOpts.nSym )

View File

@ -1,7 +1,7 @@
###* ###*
Definition of the TextGenerator class. Definition of the TextGenerator class.
@module generators/text-generator
@license MIT. See LICENSE.md for details. @license MIT. See LICENSE.md for details.
@module text-generator.js
### ###
TemplateGenerator = require './template-generator' TemplateGenerator = require './template-generator'
@ -9,6 +9,6 @@ TemplateGenerator = require './template-generator'
###* ###*
The TextGenerator generates a plain-text resume via the TemplateGenerator. The TextGenerator generates a plain-text resume via the TemplateGenerator.
### ###
TextGenerator = module.exports = TemplateGenerator.extend module.exports = class TextGenerator extends TemplateGenerator
init: () -> @_super 'txt' constructor: () -> super 'txt'

View File

@ -1,11 +1,12 @@
### ###
Definition of the WordGenerator class. Definition of the WordGenerator class.
@license MIT. See LICENSE.md for details.
@module generators/word-generator @module generators/word-generator
@license MIT. See LICENSE.md for details.
### ###
TemplateGenerator = require './template-generator' TemplateGenerator = require './template-generator'
WordGenerator = module.exports = TemplateGenerator.extend module.exports = class WordGenerator extends TemplateGenerator
init: () -> @_super 'doc', 'xml'
init: () -> super 'doc', 'xml'

View File

@ -6,8 +6,7 @@ Definition of the XMLGenerator class.
BaseGenerator = require './base-generator' BaseGenerator = require './base-generator'
###* ###* The XmlGenerator generates an XML resume via the TemplateGenerator. ###
The XmlGenerator generates an XML resume via the TemplateGenerator. module.exports = class XMLGenerator extends BaseGenerator
###
XMLGenerator = module.exports = BaseGenerator.extend constructor: () -> super 'xml'
init: () -> @_super 'xml'

View File

@ -11,5 +11,6 @@ TemplateGenerator = require './template-generator'
YamlGenerator generates a YAML-formatted resume via TemplateGenerator. YamlGenerator generates a YAML-formatted resume via TemplateGenerator.
### ###
YAMLGenerator = module.exports = TemplateGenerator.extend module.exports = class YAMLGenerator extends TemplateGenerator
init: () -> @_super 'yml', 'yml'
constructor: () -> super 'yml', 'yml'