diff --git a/dist/cli/index.js b/dist/cli/index.js old mode 100644 new mode 100755 diff --git a/dist/core/abstract-resume.js b/dist/core/abstract-resume.js index 0d99a78..343ca78 100644 --- a/dist/core/abstract-resume.js +++ b/dist/core/abstract-resume.js @@ -62,6 +62,41 @@ Definition of the AbstractResume class. return lastDate.diff(firstDate, unit); }; + + /** + 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 + } + */ + + AbstractResume.prototype.scrubResume = function(rep, opts) { + var ignoreList, includePrivates, privateList, scrubbed, traverse; + traverse = require('traverse'); + ignoreList = []; + privateList = []; + includePrivates = (opts != null ? opts["private"] : void 0) == null ? true : opts != null ? opts["private"] : void 0; + scrubbed = traverse(rep).map(function(x) { + if (!this.isLeaf) { + if (this.node.ignore === true || this.node.ignore === 'true') { + ignoreList.push(this.node); + return this.remove(); + } else if ((this.node["private"] === true || this.node["private"] === 'true') && !includePrivates) { + privateList.push(this.node); + return this.remove(); + } + } + }); + return { + scrubbed: scrubbed, + ingoreList: ignoreList, + privateList: privateList + }; + }; + return AbstractResume; })(); diff --git a/dist/core/fresh-resume.js b/dist/core/fresh-resume.js index 487aac0..c7d2886 100644 --- a/dist/core/fresh-resume.js +++ b/dist/core/fresh-resume.js @@ -77,24 +77,11 @@ Definition of the FRESHResume class. */ FreshResume.prototype.parseJSON = function(rep, opts) { - var ignoreList, privateList, ref, scrubbed, that, traverse; + var ignoreList, privateList, ref, ref1, scrubbed, that; that = this; - traverse = require('traverse'); - ignoreList = []; - privateList = []; - scrubbed = traverse(rep).map(function(x) { - if (!this.isLeaf) { - if (this.node.ignore === true || this.node.ignore === 'true') { - ignoreList.push(this.node); - return this.remove(); - } else if ((this.node["private"] === true || this.node["private"] === 'true') && !(opts != null ? opts["private"] : void 0)) { - privateList.push(this.node); - return this.remove(); - } - } - }); + ref = this.scrubResume(rep, opts), scrubbed = ref.scrubbed, ignoreList = ref.ignoreList, privateList = ref.privateList; extend(true, this, scrubbed); - if (!((ref = this.imp) != null ? ref.processed : void 0)) { + if (!((ref1 = this.imp) != null ? ref1.processed : void 0)) { opts = opts || {}; if (opts.imp === void 0 || opts.imp) { this.imp = this.imp || {}; diff --git a/dist/core/jrs-resume.js b/dist/core/jrs-resume.js index 7a7f6a7..5b4e5e2 100644 --- a/dist/core/jrs-resume.js +++ b/dist/core/jrs-resume.js @@ -71,25 +71,12 @@ Definition of the JRSResume class. */ JRSResume.prototype.parseJSON = function(rep, opts) { - var ignoreList, privateList, ref, scrubbed, that, traverse; + var ignoreList, privateList, ref, ref1, scrubbed, that; opts = opts || {}; that = this; - traverse = require('traverse'); - ignoreList = []; - privateList = []; - scrubbed = traverse(rep).map(function(x) { - if (!this.isLeaf) { - if (this.node.ignore === true || this.node.ignore === 'true') { - ignoreList.push(this.node); - return this.remove(); - } else if ((this.node["private"] === true || this.node["private"] === 'true') && !(opts != null ? opts["private"] : void 0)) { - privateList.push(this.node); - return this.remove(); - } - } - }); + ref = this.scrubResume(rep, opts), scrubbed = ref.scrubbed, ignoreList = ref.ignoreList, privateList = ref.privateList; extend(true, this, scrubbed); - if (!((ref = this.imp) != null ? ref.processed : void 0)) { + if (!((ref1 = this.imp) != null ? ref1.processed : void 0)) { opts = opts || {}; if (opts.imp === void 0 || opts.imp) { this.imp = this.imp || {}; diff --git a/src/core/abstract-resume.coffee b/src/core/abstract-resume.coffee index 1670eda..9571457 100644 --- a/src/core/abstract-resume.coffee +++ b/src/core/abstract-resume.coffee @@ -50,4 +50,32 @@ class AbstractResume lastDate = _.last( new_e )[1]; lastDate.diff firstDate, unit + ###* + 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: (rep, opts) -> + traverse = require 'traverse' + ignoreList = [] + privateList = [] + includePrivates = if not opts?.private? then true else opts?.private + + scrubbed = traverse( rep ).map ( x ) -> + if !@isLeaf + if @node.ignore == true || @node.ignore == 'true' + ignoreList.push @node + @remove() + else if (@node.private == true || @node.private == 'true') && !includePrivates + privateList.push @node + @remove() + + scrubbed: scrubbed + ingoreList: ignoreList + privateList: privateList + module.exports = AbstractResume diff --git a/src/core/fresh-resume.coffee b/src/core/fresh-resume.coffee index 1de2cf3..6bc91ce 100644 --- a/src/core/fresh-resume.coffee +++ b/src/core/fresh-resume.coffee @@ -55,18 +55,7 @@ class FreshResume extends AbstractResume # Ignore any element with the 'ignore: true' or 'private: true' designator. that = @ - traverse = require 'traverse' - ignoreList = [] - privateList = [] - - scrubbed = traverse( rep ).map ( x ) -> - if !@isLeaf - if @node.ignore == true || @node.ignore == 'true' - ignoreList.push this.node - @remove() - else if (@node.private == true || @node.private == 'true') && !opts?.private - privateList.push @node - @remove() + { scrubbed, ignoreList, privateList } = @scrubResume rep, opts # Now apply the resume representation onto this object extend( true, @, scrubbed ); diff --git a/src/core/jrs-resume.coffee b/src/core/jrs-resume.coffee index 4038a29..42551a9 100644 --- a/src/core/jrs-resume.coffee +++ b/src/core/jrs-resume.coffee @@ -50,18 +50,7 @@ class JRSResume extends AbstractResume opts = opts || { }; # Ignore any element with the 'ignore: true' or 'private: true' designator. that = this - traverse = require 'traverse' - ignoreList = [] - privateList = [] - - scrubbed = traverse( rep ).map ( x ) -> - if !@isLeaf - if @node.ignore == true || @node.ignore == 'true' - ignoreList.push this.node - @remove() - else if (@node.private == true || @node.private == 'true') && !opts?.private - privateList.push @node - @remove() + { scrubbed, ignoreList, privateList } = @scrubResume rep, opts # Extend resume properties onto ourself. extend true, this, scrubbed diff --git a/src/verbs/build.coffee b/src/verbs/build.coffee index fc7409f..01a0128 100644 --- a/src/verbs/build.coffee +++ b/src/verbs/build.coffee @@ -166,7 +166,6 @@ _build = ( src, dst, opts ) -> Prepare for a BUILD run. ### _prep = ( src, dst, opts ) -> - # Cherry-pick options //_opts = extend( true, _opts, opts ); _opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern'; _opts.prettify = opts.prettify is true