mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-02 12:27:08 +01:00
Refactor generators to CoffeeScript classes.
This commit is contained in:
@ -1,25 +1,19 @@
|
||||
###*
|
||||
Definition of the BaseGenerator class.
|
||||
@module base-generator.js
|
||||
@module generators/base-generator
|
||||
@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
|
||||
common to ALL generators lives here.
|
||||
###
|
||||
|
||||
BaseGenerator = module.exports = Class.extend
|
||||
module.exports = class BaseGenerator
|
||||
|
||||
###* Base-class initialize. ###
|
||||
init: ( outputFormat ) -> @format = outputFormat
|
||||
constructor: ( @format ) ->
|
||||
|
||||
###* Status codes. ###
|
||||
codes: require '../core/status-codes'
|
||||
|
@ -1,7 +1,7 @@
|
||||
###*
|
||||
Definition of the HTMLGenerator class.
|
||||
@module generators/html-generator
|
||||
@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
|
||||
|
@ -1,6 +1,6 @@
|
||||
###*
|
||||
Definition of the HtmlPdfCLIGenerator class.
|
||||
@module html-pdf-generator.js
|
||||
@module generators/html-pdf-generator.js
|
||||
@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.
|
||||
###
|
||||
|
||||
HtmlPdfCLIGenerator = module.exports = TemplateGenerator.extend
|
||||
module.exports = class HtmlPdfCLIGenerator extends TemplateGenerator
|
||||
|
||||
|
||||
|
||||
init: () -> @_super 'pdf', 'html'
|
||||
constructor: () -> super 'pdf', 'html'
|
||||
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
###*
|
||||
Definition of the HtmlPngGenerator class.
|
||||
@module generators/html-png-generator
|
||||
@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.
|
||||
###
|
||||
HtmlPngGenerator = module.exports = TemplateGenerator.extend
|
||||
module.exports = class HtmlPngGenerator extends TemplateGenerator
|
||||
|
||||
init: -> @_super 'png', 'html'
|
||||
constructor: -> super 'png', 'html'
|
||||
|
||||
invoke: ( rez, themeMarkup, cssInfo, opts ) ->
|
||||
# TODO: Not currently called or callable.
|
||||
|
@ -1,20 +1,18 @@
|
||||
###*
|
||||
Definition of the JsonGenerator class.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module generators/json-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
###
|
||||
|
||||
BaseGenerator = require './base-generator'
|
||||
FS = require 'fs'
|
||||
_ = 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',
|
||||
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
||||
|
@ -1,6 +1,6 @@
|
||||
###*
|
||||
Definition of the JsonYamlGenerator class.
|
||||
@module json-yaml-generator.js
|
||||
@module generators/json-yaml-generator
|
||||
@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).
|
||||
###
|
||||
|
||||
JsonYamlGenerator = module.exports = BaseGenerator.extend
|
||||
module.exports = class JsonYamlGenerator extends BaseGenerator
|
||||
|
||||
init: () -> @_super 'yml'
|
||||
constructor: () -> super 'yml'
|
||||
|
||||
invoke: ( rez, themeMarkup, cssInfo, opts ) ->
|
||||
YAML.stringify JSON.parse( rez.stringify() ), Infinity, 2
|
||||
|
@ -1,7 +1,7 @@
|
||||
###*
|
||||
Definition of the LaTeXGenerator class.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module generators/latex-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
###
|
||||
|
||||
TemplateGenerator = require './template-generator'
|
||||
@ -9,6 +9,6 @@ TemplateGenerator = require './template-generator'
|
||||
###*
|
||||
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'
|
||||
|
@ -1,7 +1,7 @@
|
||||
###*
|
||||
Definition of the MarkdownGenerator class.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@module markdown-generator.js
|
||||
@module generators/markdown-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
###
|
||||
|
||||
TemplateGenerator = require './template-generator'
|
||||
@ -9,6 +9,6 @@ TemplateGenerator = require './template-generator'
|
||||
###*
|
||||
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'
|
||||
|
@ -1,7 +1,7 @@
|
||||
###*
|
||||
Definition of the TemplateGenerator class. TODO: Refactor
|
||||
@module generators/template-generator
|
||||
@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
|
||||
###
|
||||
|
||||
TemplateGenerator = module.exports = BaseGenerator.extend
|
||||
module.exports = class TemplateGenerator extends BaseGenerator
|
||||
|
||||
###* Constructor. Set the output format and template format for this
|
||||
generator. Will usually be called by a derived generator such as
|
||||
HTMLGenerator or MarkdownGenerator. ###
|
||||
|
||||
init: ( outputFormat, templateFormat, cssFile ) ->
|
||||
@_super outputFormat
|
||||
constructor: ( outputFormat, templateFormat, cssFile ) ->
|
||||
super outputFormat
|
||||
@tplFormat = templateFormat || outputFormat
|
||||
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 = ( markup ) ->
|
||||
markup.replace( _reg.regN, _defaultOpts.nSym )
|
||||
|
@ -1,7 +1,7 @@
|
||||
###*
|
||||
Definition of the TextGenerator class.
|
||||
@module generators/text-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module text-generator.js
|
||||
###
|
||||
|
||||
TemplateGenerator = require './template-generator'
|
||||
@ -9,6 +9,6 @@ TemplateGenerator = require './template-generator'
|
||||
###*
|
||||
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'
|
||||
|
@ -1,11 +1,12 @@
|
||||
###
|
||||
Definition of the WordGenerator class.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module generators/word-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
###
|
||||
|
||||
|
||||
TemplateGenerator = require './template-generator'
|
||||
|
||||
WordGenerator = module.exports = TemplateGenerator.extend
|
||||
init: () -> @_super 'doc', 'xml'
|
||||
module.exports = class WordGenerator extends TemplateGenerator
|
||||
|
||||
init: () -> super 'doc', 'xml'
|
||||
|
@ -6,8 +6,7 @@ Definition of the XMLGenerator class.
|
||||
|
||||
BaseGenerator = require './base-generator'
|
||||
|
||||
###*
|
||||
The XmlGenerator generates an XML resume via the TemplateGenerator.
|
||||
###
|
||||
XMLGenerator = module.exports = BaseGenerator.extend
|
||||
init: () -> @_super 'xml'
|
||||
###* The XmlGenerator generates an XML resume via the TemplateGenerator. ###
|
||||
module.exports = class XMLGenerator extends BaseGenerator
|
||||
|
||||
constructor: () -> super 'xml'
|
||||
|
@ -11,5 +11,6 @@ TemplateGenerator = require './template-generator'
|
||||
YamlGenerator generates a YAML-formatted resume via TemplateGenerator.
|
||||
###
|
||||
|
||||
YAMLGenerator = module.exports = TemplateGenerator.extend
|
||||
init: () -> @_super 'yml', 'yml'
|
||||
module.exports = class YAMLGenerator extends TemplateGenerator
|
||||
|
||||
constructor: () -> super 'yml', 'yml'
|
||||
|
Reference in New Issue
Block a user