mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 09:56:22 +00:00
0f65e4c9f3
Reintroduce HackMyCore, dropping the interim submodule, and reorganize and improve tests.
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);
|