1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-03 04:47:07 +01:00

parseJSON has been modified to always include private fields if not otherwise instructed. This is to ensure back-compatibility. The BUILD command instead, excludes private fields by default

This commit is contained in:
Daniele Rapagnani
2016-02-14 21:50:13 +01:00
parent fed59b704e
commit 664eea752f
8 changed files with 71 additions and 57 deletions

View File

@ -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

View File

@ -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 );

View File

@ -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

View File

@ -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