2016-01-27 10:29:26 +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-27 10:29:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
2016-02-02 18:38:12 +00:00
|
|
|
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;
|
2016-01-27 10:29:26 +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. */
|
|
|
|
|
|
|
|
module.exports = JsonGenerator = (function(superClass) {
|
|
|
|
extend(JsonGenerator, superClass);
|
|
|
|
|
|
|
|
function JsonGenerator() {
|
|
|
|
JsonGenerator.__super__.constructor.call(this, 'json');
|
|
|
|
}
|
|
|
|
|
|
|
|
JsonGenerator.prototype.keys = ['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index', 'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result', 'isModified', 'htmlPreview', 'safe'];
|
2016-01-27 10:29:26 +00:00
|
|
|
|
2016-02-02 18:38:12 +00:00
|
|
|
JsonGenerator.prototype.invoke = function(rez) {
|
2016-01-27 10:29:26 +00:00
|
|
|
var replacer;
|
|
|
|
replacer = function(key, value) {
|
|
|
|
if (_.some(this.keys, function(val) {
|
|
|
|
return key.trim() === val;
|
|
|
|
})) {
|
|
|
|
return void 0;
|
|
|
|
} else {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return JSON.stringify(rez, replacer, 2);
|
2016-02-02 18:38:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
JsonGenerator.prototype.generate = function(rez, f) {
|
2016-01-27 10:29:26 +00:00
|
|
|
FS.writeFileSync(f, this.invoke(rez), 'utf8');
|
2016-02-02 18:38:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return JsonGenerator;
|
|
|
|
|
|
|
|
})(BaseGenerator);
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
}).call(this);
|
2016-02-02 02:14:36 +00:00
|
|
|
|
|
|
|
//# sourceMappingURL=json-generator.js.map
|