mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-02 12:27:08 +01:00
refactor: remove AbstractResume base class
(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.
This commit is contained in:
45
dist/utils/resume-scrubber.js
vendored
Normal file
45
dist/utils/resume-scrubber.js
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
(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
|
Reference in New Issue
Block a user