diff --git a/src/cli/main.coffee b/src/cli/main.coffee index 15e3d92..e2a7ba1 100644 --- a/src/cli/main.coffee +++ b/src/cli/main.coffee @@ -91,6 +91,7 @@ main = module.exports = ( rawArgs, exitCallback ) -> program .command('analyze') .arguments('') + .option('--private', 'Include resume fields marked as private', false) .description('Analyze one or more resumes.') .action(( sources ) -> execute.call( this, sources, [], this.opts(), logMsg) @@ -118,6 +119,7 @@ main = module.exports = ( rawArgs, exitCallback ) -> .option('-p --pdf ', 'PDF generation engine') .option('--no-sort', 'Sort resume sections by date', false) .option('--tips', 'Display theme tips and warnings.', false) + .option('--private', 'Include resume fields marked as private', false) .description('Generate resume to multiple formats') .action(( sources, targets, options ) -> x = splitSrcDest.call( this ); diff --git a/src/cli/use.txt b/src/cli/use.txt index a799233..fd73d38 100644 --- a/src/cli/use.txt +++ b/src/cli/use.txt @@ -19,6 +19,7 @@ Available options: --format -f The format (FRESH or JSON Resume) to use. --debug -d Emit extended debugging info. --assert -a Treat resume validation warnings as errors. + --private Include resume fields marked as private --no-colors Disable terminal colors. --tips Display theme messages and tips. --help -h Display help documentation. 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 e91deb5..6bc91ce 100644 --- a/src/core/fresh-resume.coffee +++ b/src/core/fresh-resume.coffee @@ -53,15 +53,9 @@ class FreshResume extends AbstractResume ### parseJSON: ( rep, opts ) -> - # Ignore any element with the 'ignore: true' designator. + # Ignore any element with the 'ignore: true' or 'private: true' designator. that = @ - traverse = require 'traverse' - ignoreList = [] - scrubbed = traverse( rep ).map ( x ) -> - if !@isLeaf && @node.ignore - if @node.ignore == true || this.node.ignore == 'true' - ignoreList.push this.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 14e49d5..42551a9 100644 --- a/src/core/jrs-resume.coffee +++ b/src/core/jrs-resume.coffee @@ -48,16 +48,9 @@ class JRSResume extends AbstractResume ### parseJSON: ( rep, opts ) -> opts = opts || { }; - - # Ignore any element with the 'ignore: true' designator. + # Ignore any element with the 'ignore: true' or 'private: true' designator. that = this - traverse = require 'traverse' - ignoreList = [] - scrubbed = traverse( rep ).map ( x ) -> - if !@isLeaf && @node.ignore - if @node.ignore == true || this.node.ignore == 'true' - ignoreList.push @node - @remove() + { scrubbed, ignoreList, privateList } = @scrubResume rep, opts # Extend resume properties onto ourself. extend true, this, scrubbed diff --git a/src/verbs/analyze.coffee b/src/verbs/analyze.coffee index 688d5c8..8905ba5 100644 --- a/src/verbs/analyze.coffee +++ b/src/verbs/analyze.coffee @@ -33,7 +33,9 @@ _analyze = ( sources, dst, opts ) -> nlzrs = _loadInspectors() results = _.map sources, (src) -> - r = ResumeFactory.loadOne src, format: 'FRESH', objectify: true, @ + r = ResumeFactory.loadOne src, format: 'FRESH', objectify: true, inner: { + private: opts.private is true + }, @ return { } if opts.assert and @hasError() if r.fluenterror diff --git a/src/verbs/build.coffee b/src/verbs/build.coffee index 1214da1..01a0128 100644 --- a/src/verbs/build.coffee +++ b/src/verbs/build.coffee @@ -63,7 +63,10 @@ _build = ( src, dst, opts ) -> # Load input resumes as JSON... sheetObjects = ResumeFactory.load src, - format: null, objectify: false, quit: true, inner: { sort: _opts.sort } + format: null, objectify: false, quit: true, inner: { + sort: _opts.sort + private: _opts.private + } , @ # Explicit check for any resume loading errors... @@ -130,7 +133,7 @@ _build = ( src, dst, opts ) -> @stat HMEVENT.applyTheme, r: rez, theme: theme # Load the resume into a FRESHResume or JRSResume object - _rezObj = new (RTYPES[ toFormat ])().parseJSON( rez ); + _rezObj = new (RTYPES[ toFormat ])().parseJSON( rez, private: _opts.private ); # Expand output resumes... targets = _expand dst, theme @@ -163,10 +166,10 @@ _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 + _opts.private = opts.private is true _opts.css = opts.css _opts.pdf = opts.pdf _opts.wrap = opts.wrap || 60