2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Definition of the JsonYamlGenerator class.
|
2016-02-02 18:38:12 +00:00
|
|
|
@module generators/json-yaml-generator
|
2016-01-27 10:29:26 +00:00
|
|
|
@license MIT. See LICENSE.md for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
2016-02-02 18:38:12 +00:00
|
|
|
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;
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
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).
|
|
|
|
*/
|
|
|
|
|
2016-02-02 18:38:12 +00:00
|
|
|
module.exports = JsonYamlGenerator = (function(superClass) {
|
|
|
|
extend(JsonYamlGenerator, superClass);
|
|
|
|
|
|
|
|
function JsonYamlGenerator() {
|
|
|
|
JsonYamlGenerator.__super__.constructor.call(this, 'yml');
|
|
|
|
}
|
|
|
|
|
|
|
|
JsonYamlGenerator.prototype.invoke = function(rez, themeMarkup, cssInfo, opts) {
|
2016-01-27 10:29:26 +00:00
|
|
|
return YAML.stringify(JSON.parse(rez.stringify()), Infinity, 2);
|
2016-02-02 18:38:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
JsonYamlGenerator.prototype.generate = function(rez, f, opts) {
|
2016-01-27 10:29:26 +00:00
|
|
|
var data;
|
|
|
|
data = YAML.stringify(JSON.parse(rez.stringify()), Infinity, 2);
|
2016-02-02 02:14:36 +00:00
|
|
|
FS.writeFileSync(f, data, 'utf8');
|
|
|
|
return data;
|
2016-02-02 18:38:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return JsonYamlGenerator;
|
|
|
|
|
|
|
|
})(BaseGenerator);
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
}).call(this);
|
2016-02-02 02:14:36 +00:00
|
|
|
|
|
|
|
//# sourceMappingURL=json-yaml-generator.js.map
|