mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 09:56:22 +00:00
8dca5b76e7
(1) AbstractResume adds complexity without contributing utility. There's not really a clean "class" abstraction in JavaScript to begin with; CoffeeScript classes, as nice as they are syntactically, occlude the issue even further. (2) AbstractResume currently functions as a container for exactly two functions which arguably should live outside the resume class anyway.
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
(function() {
|
|
module.exports = {
|
|
|
|
/**
|
|
Removes ignored or private fields from a resume object
|
|
@returns an object with the following structure:
|
|
{
|
|
scrubbed: the processed resume object
|
|
ignoreList: an array of ignored nodes that were removed
|
|
privateList: an array of private nodes that were removed
|
|
}
|
|
*/
|
|
scrubResume: function(rep, opts) {
|
|
var ignoreList, includePrivates, privateList, scrubbed, traverse;
|
|
traverse = require('traverse');
|
|
ignoreList = [];
|
|
privateList = [];
|
|
includePrivates = opts && opts["private"];
|
|
scrubbed = traverse(rep).map(function() {
|
|
if (!this.isLeaf) {
|
|
if (this.node.ignore === true || this.node.ignore === 'true') {
|
|
ignoreList.push(this.node);
|
|
this["delete"]();
|
|
} else if ((this.node["private"] === true || this.node["private"] === 'true') && !includePrivates) {
|
|
privateList.push(this.node);
|
|
this["delete"]();
|
|
}
|
|
}
|
|
if (_.isArray(this.node)) {
|
|
this.after(function() {
|
|
this.update(_.compact(this.node));
|
|
});
|
|
}
|
|
});
|
|
return {
|
|
scrubbed: scrubbed,
|
|
ingoreList: ignoreList,
|
|
privateList: privateList
|
|
};
|
|
}
|
|
};
|
|
|
|
}).call(this);
|
|
|
|
//# sourceMappingURL=resume-scrubber.js.map
|