mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-08-26 15:06:20 +01:00
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
|
|
||
|
/**
|
||
|
Definition of the JsonGenerator class.
|
||
|
@license MIT. See LICENSE.md for details.
|
||
|
@module generators/json-generator
|
||
|
*/
|
||
|
|
||
|
(function() {
|
||
|
var BaseGenerator, FS, JsonGenerator, _;
|
||
|
|
||
|
BaseGenerator = require('./base-generator');
|
||
|
|
||
|
FS = require('fs');
|
||
|
|
||
|
_ = require('underscore');
|
||
|
|
||
|
|
||
|
/**
|
||
|
The JsonGenerator generates a JSON resume directly.
|
||
|
*/
|
||
|
|
||
|
JsonGenerator = module.exports = BaseGenerator.extend({
|
||
|
init: function() {
|
||
|
return this._super('json');
|
||
|
},
|
||
|
keys: ['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index', 'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result', 'isModified', 'htmlPreview', 'safe'],
|
||
|
invoke: function(rez) {
|
||
|
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);
|
||
|
},
|
||
|
generate: function(rez, f) {
|
||
|
FS.writeFileSync(f, this.invoke(rez), 'utf8');
|
||
|
}
|
||
|
});
|
||
|
|
||
|
}).call(this);
|