1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-25 01:40:10 +00:00

Implemented private fields that can be included or excluded with cli switch

This commit is contained in:
Daniele Rapagnani 2016-02-14 19:15:47 +01:00
parent 3cf850ea0e
commit fed59b704e
14 changed files with 57 additions and 22 deletions

4
dist/cli/main.js vendored
View File

@ -76,7 +76,7 @@ Definition of the `main` function.
x = splitSrcDest.call(this); x = splitSrcDest.call(this);
execute.call(this, x.src, x.dst, this.opts(), logMsg); execute.call(this, x.src, x.dst, this.opts(), logMsg);
}); });
program.command('analyze')["arguments"]('<sources...>').description('Analyze one or more resumes.').action(function(sources) { program.command('analyze')["arguments"]('<sources...>').option('--private', 'Include resume fields marked as private', false).description('Analyze one or more resumes.').action(function(sources) {
execute.call(this, sources, [], this.opts(), logMsg); execute.call(this, sources, [], this.opts(), logMsg);
}); });
program.command('peek')["arguments"]('<sources...>').description('Peek at a resume field or section').action(function(sources, sectionOrField) { program.command('peek')["arguments"]('<sources...>').description('Peek at a resume field or section').action(function(sources, sectionOrField) {
@ -84,7 +84,7 @@ Definition of the `main` function.
dst = sources && sources.length > 1 ? [sources.pop()] : []; dst = sources && sources.length > 1 ? [sources.pop()] : [];
execute.call(this, sources, dst, this.opts(), logMsg); execute.call(this, sources, dst, this.opts(), logMsg);
}); });
program.command('build').alias('generate').option('-t --theme <theme>', 'Theme name or path').option('-n --no-prettify', 'Disable HTML prettification', true).option('-c --css <option>', 'CSS linking / embedding').option('-p --pdf <engine>', 'PDF generation engine').option('--no-sort', 'Sort resume sections by date', false).option('--tips', 'Display theme tips and warnings.', false).description('Generate resume to multiple formats').action(function(sources, targets, options) { program.command('build').alias('generate').option('-t --theme <theme>', 'Theme name or path').option('-n --no-prettify', 'Disable HTML prettification', true).option('-c --css <option>', 'CSS linking / embedding').option('-p --pdf <engine>', '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(function(sources, targets, options) {
var x; var x;
x = splitSrcDest.call(this); x = splitSrcDest.call(this);
execute.call(this, x.src, x.dst, this.opts(), logMsg); execute.call(this, x.src, x.dst, this.opts(), logMsg);

1
dist/cli/use.txt vendored
View File

@ -19,6 +19,7 @@ Available options:
--format -f The format (FRESH or JSON Resume) to use. --format -f The format (FRESH or JSON Resume) to use.
--debug -d Emit extended debugging info. --debug -d Emit extended debugging info.
--assert -a Treat resume validation warnings as errors. --assert -a Treat resume validation warnings as errors.
--private Include resume fields marked as private
--no-colors Disable terminal colors. --no-colors Disable terminal colors.
--tips Display theme messages and tips. --tips Display theme messages and tips.
--help -h Display help documentation. --help -h Display help documentation.

View File

@ -77,15 +77,19 @@ Definition of the FRESHResume class.
*/ */
FreshResume.prototype.parseJSON = function(rep, opts) { FreshResume.prototype.parseJSON = function(rep, opts) {
var ignoreList, ref, scrubbed, that, traverse; var ignoreList, privateList, ref, scrubbed, that, traverse;
that = this; that = this;
traverse = require('traverse'); traverse = require('traverse');
ignoreList = []; ignoreList = [];
privateList = [];
scrubbed = traverse(rep).map(function(x) { scrubbed = traverse(rep).map(function(x) {
if (!this.isLeaf && this.node.ignore) { if (!this.isLeaf) {
if (this.node.ignore === true || this.node.ignore === 'true') { if (this.node.ignore === true || this.node.ignore === 'true') {
ignoreList.push(this.node); ignoreList.push(this.node);
return this.remove(); 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();
} }
} }
}); });

View File

@ -71,16 +71,20 @@ Definition of the JRSResume class.
*/ */
JRSResume.prototype.parseJSON = function(rep, opts) { JRSResume.prototype.parseJSON = function(rep, opts) {
var ignoreList, ref, scrubbed, that, traverse; var ignoreList, privateList, ref, scrubbed, that, traverse;
opts = opts || {}; opts = opts || {};
that = this; that = this;
traverse = require('traverse'); traverse = require('traverse');
ignoreList = []; ignoreList = [];
privateList = [];
scrubbed = traverse(rep).map(function(x) { scrubbed = traverse(rep).map(function(x) {
if (!this.isLeaf && this.node.ignore) { if (!this.isLeaf) {
if (this.node.ignore === true || this.node.ignore === 'true') { if (this.node.ignore === true || this.node.ignore === 'true') {
ignoreList.push(this.node); ignoreList.push(this.node);
return this.remove(); 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();
} }
} }
}); });

View File

@ -56,7 +56,10 @@ Implementation of the 'analyze' verb for HackMyResume.
var r; var r;
r = ResumeFactory.loadOne(src, { r = ResumeFactory.loadOne(src, {
format: 'FRESH', format: 'FRESH',
objectify: true objectify: true,
inner: {
"private": opts["private"]
}
}, this); }, this);
if (opts.assert && this.hasError()) { if (opts.assert && this.hasError()) {
return {}; return {};

8
dist/verbs/build.js vendored
View File

@ -109,7 +109,8 @@ Implementation of the 'build' verb for HackMyResume.
objectify: false, objectify: false,
quit: true, quit: true,
inner: { inner: {
sort: _opts.sort sort: _opts.sort,
"private": _opts["private"]
} }
}, this); }, this);
problemSheets = _.filter(sheetObjects, function(so) { problemSheets = _.filter(sheetObjects, function(so) {
@ -198,7 +199,9 @@ Implementation of the 'build' verb for HackMyResume.
r: rez, r: rez,
theme: theme theme: theme
}); });
_rezObj = new RTYPES[toFormat]().parseJSON(rez); _rezObj = new RTYPES[toFormat]().parseJSON(rez, {
"private": _opts["private"]
});
targets = _expand(dst, theme); targets = _expand(dst, theme);
_.each(targets, function(t) { _.each(targets, function(t) {
var ref; var ref;
@ -233,6 +236,7 @@ Implementation of the 'build' verb for HackMyResume.
var that; var that;
_opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern'; _opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern';
_opts.prettify = opts.prettify === true; _opts.prettify = opts.prettify === true;
_opts["private"] = opts["private"] === true;
_opts.css = opts.css; _opts.css = opts.css;
_opts.pdf = opts.pdf; _opts.pdf = opts.pdf;
_opts.wrap = opts.wrap || 60; _opts.wrap = opts.wrap || 60;

View File

@ -92,7 +92,10 @@ Implementation of the 'convert' verb for HackMyResume.
var rinfo, s, srcFmt, targetFormat; var rinfo, s, srcFmt, targetFormat;
rinfo = ResumeFactory.loadOne(src, { rinfo = ResumeFactory.loadOne(src, {
format: null, format: null,
objectify: true objectify: true,
inner: {
"private": true
}
}); });
if (rinfo.fluenterror) { if (rinfo.fluenterror) {
return rinfo; return rinfo;

View File

@ -91,6 +91,7 @@ main = module.exports = ( rawArgs, exitCallback ) ->
program program
.command('analyze') .command('analyze')
.arguments('<sources...>') .arguments('<sources...>')
.option('--private', 'Include resume fields marked as private', false)
.description('Analyze one or more resumes.') .description('Analyze one or more resumes.')
.action(( sources ) -> .action(( sources ) ->
execute.call( this, sources, [], this.opts(), logMsg) execute.call( this, sources, [], this.opts(), logMsg)
@ -118,6 +119,7 @@ main = module.exports = ( rawArgs, exitCallback ) ->
.option('-p --pdf <engine>', 'PDF generation engine') .option('-p --pdf <engine>', 'PDF generation engine')
.option('--no-sort', 'Sort resume sections by date', false) .option('--no-sort', 'Sort resume sections by date', false)
.option('--tips', 'Display theme tips and warnings.', false) .option('--tips', 'Display theme tips and warnings.', false)
.option('--private', 'Include resume fields marked as private', false)
.description('Generate resume to multiple formats') .description('Generate resume to multiple formats')
.action(( sources, targets, options ) -> .action(( sources, targets, options ) ->
x = splitSrcDest.call( this ); x = splitSrcDest.call( this );

View File

@ -19,6 +19,7 @@ Available options:
--format -f The format (FRESH or JSON Resume) to use. --format -f The format (FRESH or JSON Resume) to use.
--debug -d Emit extended debugging info. --debug -d Emit extended debugging info.
--assert -a Treat resume validation warnings as errors. --assert -a Treat resume validation warnings as errors.
--private Include resume fields marked as private
--no-colors Disable terminal colors. --no-colors Disable terminal colors.
--tips Display theme messages and tips. --tips Display theme messages and tips.
--help -h Display help documentation. --help -h Display help documentation.

View File

@ -53,15 +53,20 @@ class FreshResume extends AbstractResume
### ###
parseJSON: ( rep, opts ) -> parseJSON: ( rep, opts ) ->
# Ignore any element with the 'ignore: true' designator. # Ignore any element with the 'ignore: true' or 'private: true' designator.
that = @ that = @
traverse = require 'traverse' traverse = require 'traverse'
ignoreList = [] ignoreList = []
privateList = []
scrubbed = traverse( rep ).map ( x ) -> scrubbed = traverse( rep ).map ( x ) ->
if !@isLeaf && @node.ignore if !@isLeaf
if @node.ignore == true || this.node.ignore == 'true' if @node.ignore == true || @node.ignore == 'true'
ignoreList.push this.node ignoreList.push this.node
@remove() @remove()
else if (@node.private == true || @node.private == 'true') && !opts?.private
privateList.push @node
@remove()
# Now apply the resume representation onto this object # Now apply the resume representation onto this object
extend( true, @, scrubbed ); extend( true, @, scrubbed );

View File

@ -48,15 +48,19 @@ class JRSResume extends AbstractResume
### ###
parseJSON: ( rep, opts ) -> parseJSON: ( rep, opts ) ->
opts = opts || { }; opts = opts || { };
# Ignore any element with the 'ignore: true' or 'private: true' designator.
# Ignore any element with the 'ignore: true' designator.
that = this that = this
traverse = require 'traverse' traverse = require 'traverse'
ignoreList = [] ignoreList = []
privateList = []
scrubbed = traverse( rep ).map ( x ) -> scrubbed = traverse( rep ).map ( x ) ->
if !@isLeaf && @node.ignore if !@isLeaf
if @node.ignore == true || this.node.ignore == 'true' if @node.ignore == true || @node.ignore == 'true'
ignoreList.push @node ignoreList.push this.node
@remove()
else if (@node.private == true || @node.private == 'true') && !opts?.private
privateList.push @node
@remove() @remove()
# Extend resume properties onto ourself. # Extend resume properties onto ourself.

View File

@ -33,7 +33,7 @@ _analyze = ( sources, dst, opts ) ->
nlzrs = _loadInspectors() nlzrs = _loadInspectors()
results = _.map sources, (src) -> results = _.map sources, (src) ->
r = ResumeFactory.loadOne src, format: 'FRESH', objectify: true, @ r = ResumeFactory.loadOne src, format: 'FRESH', objectify: true, inner: { private: opts.private }, @
return { } if opts.assert and @hasError() return { } if opts.assert and @hasError()
if r.fluenterror if r.fluenterror

View File

@ -63,7 +63,10 @@ _build = ( src, dst, opts ) ->
# Load input resumes as JSON... # Load input resumes as JSON...
sheetObjects = ResumeFactory.load src, 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... # Explicit check for any resume loading errors...
@ -130,7 +133,7 @@ _build = ( src, dst, opts ) ->
@stat HMEVENT.applyTheme, r: rez, theme: theme @stat HMEVENT.applyTheme, r: rez, theme: theme
# Load the resume into a FRESHResume or JRSResume object # 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... # Expand output resumes...
targets = _expand dst, theme targets = _expand dst, theme
@ -167,6 +170,7 @@ _prep = ( src, dst, opts ) ->
# Cherry-pick options //_opts = extend( true, _opts, opts ); # Cherry-pick options //_opts = extend( true, _opts, opts );
_opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern'; _opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern';
_opts.prettify = opts.prettify is true _opts.prettify = opts.prettify is true
_opts.private = opts.private is true
_opts.css = opts.css _opts.css = opts.css
_opts.pdf = opts.pdf _opts.pdf = opts.pdf
_opts.wrap = opts.wrap || 60 _opts.wrap = opts.wrap || 60

View File

@ -61,7 +61,7 @@ _convert = ( srcs, dst, opts ) ->
###* Private workhorse method. Convert a single resume. ### ###* Private workhorse method. Convert a single resume. ###
_convertOne = (src, dst, idx) -> _convertOne = (src, dst, idx) ->
# Load the resume # Load the resume
rinfo = ResumeFactory.loadOne src, format: null, objectify: true rinfo = ResumeFactory.loadOne src, format: null, objectify: true, inner: { private: true }
# If a load error occurs, report it and move on to the next file (if any) # If a load error occurs, report it and move on to the next file (if any)
if rinfo.fluenterror if rinfo.fluenterror