1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-05 09:56:22 +00:00
HackMyResume/src/generators/json-yaml-generator.coffee
2016-02-02 13:38:12 -05:00

32 lines
785 B
CoffeeScript

###*
Definition of the JsonYamlGenerator class.
@module generators/json-yaml-generator
@license MIT. See LICENSE.md for details.
###
BaseGenerator = require('./base-generator')
FS = require('fs')
YAML = require('yamljs')
###*
JsonYamlGenerator takes a JSON resume object and translates it directly to
JSON without a template, producing an equivalent YAML-formatted resume. See
also YamlGenerator (yaml-generator.js).
###
module.exports = class JsonYamlGenerator extends BaseGenerator
constructor: () -> super 'yml'
invoke: ( rez, themeMarkup, cssInfo, opts ) ->
YAML.stringify JSON.parse( rez.stringify() ), Infinity, 2
generate: ( rez, f, opts ) ->
data = YAML.stringify JSON.parse( rez.stringify() ), Infinity, 2
FS.writeFileSync f, data, 'utf8'
data