2016-01-29 20:23:57 +00:00
|
|
|
###*
|
|
|
|
Definition of the JsonGenerator class.
|
|
|
|
@module generators/json-generator
|
2016-02-02 18:38:12 +00:00
|
|
|
@license MIT. See LICENSE.md for details.
|
2016-01-29 20:23:57 +00:00
|
|
|
###
|
|
|
|
|
|
|
|
BaseGenerator = require './base-generator'
|
|
|
|
FS = require 'fs'
|
|
|
|
_ = require 'underscore'
|
|
|
|
|
2016-02-02 18:38:12 +00:00
|
|
|
###* The JsonGenerator generates a JSON resume directly. ###
|
2016-01-29 20:23:57 +00:00
|
|
|
|
2016-02-02 18:38:12 +00:00
|
|
|
module.exports = class JsonGenerator extends BaseGenerator
|
2016-01-29 20:23:57 +00:00
|
|
|
|
2016-02-02 18:38:12 +00:00
|
|
|
constructor: () -> super 'json'
|
2016-01-29 20:23:57 +00:00
|
|
|
|
|
|
|
keys: ['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
|
|
|
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
|
|
|
'isModified', 'htmlPreview', 'safe' ]
|
|
|
|
|
|
|
|
invoke: ( rez ) ->
|
|
|
|
|
|
|
|
# TODO: merge with FCVD
|
|
|
|
replacer = ( key,value ) -> # Exclude these keys from stringification
|
|
|
|
if (_.some @keys, (val) -> key.trim() == val)
|
|
|
|
return undefined
|
|
|
|
else
|
|
|
|
value
|
|
|
|
JSON.stringify rez, replacer, 2
|
|
|
|
|
|
|
|
generate: ( rez, f ) ->
|
|
|
|
FS.writeFileSync( f, this.invoke(rez), 'utf8' )
|
|
|
|
return
|