mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 09:56:22 +00:00
Continue moving logging out of core.
This commit is contained in:
parent
732bc9809a
commit
3aabb5028d
@ -34,7 +34,13 @@ Event code definitions.
|
|||||||
afterMerge: 10,
|
afterMerge: 10,
|
||||||
|
|
||||||
beforeGenerate: 11,
|
beforeGenerate: 11,
|
||||||
afterGenerate: 12
|
afterGenerate: 12,
|
||||||
|
|
||||||
|
beforeAnalyze: 13,
|
||||||
|
afterAnalyze: 14,
|
||||||
|
|
||||||
|
beforeConvert: 15,
|
||||||
|
afterConvert: 16
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
53
src/out.js
53
src/out.js
@ -121,6 +121,59 @@ Output routines for HackMyResume.
|
|||||||
chalk.green(' resume') + suffix + chalk.green(': ') +
|
chalk.green(' resume') + suffix + chalk.green(': ') +
|
||||||
chalk.green.bold( PATH.relative(process.cwd(), evt.file )) );
|
chalk.green.bold( PATH.relative(process.cwd(), evt.file )) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HME.beforeAnalyze:
|
||||||
|
this.log(chalk.cyan('Analyzing ') + chalk.cyan.bold(evt.fmt) +
|
||||||
|
chalk.cyan(' resume: ') + chalk.cyan.bold(evt.file));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HME.afterAnalyze:
|
||||||
|
var info = evt.info;
|
||||||
|
var padding = 20;
|
||||||
|
this.log(chalk.cyan.bold('\nSECTIONS') + chalk.cyan(' (') +
|
||||||
|
chalk.white.bold(_.keys(info.totals).length) + chalk.cyan('):\n'));
|
||||||
|
|
||||||
|
_.each( info.totals, function(tot, key) {
|
||||||
|
this.log(chalk.cyan(pad(key + ': ',20)) +
|
||||||
|
chalk.cyan.bold(pad(tot.toString(),5)));
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.log();
|
||||||
|
this.log(chalk.cyan.bold('COVERAGE') + chalk.cyan(' (') + chalk.white.bold( info.coverage.pct ) + chalk.cyan('):\n'));
|
||||||
|
this.log(chalk.cyan(pad('Total Days: ', padding)) + chalk.cyan.bold( pad(info.coverage.duration.total.toString(),5) ));
|
||||||
|
this.log(chalk.cyan(pad('Employed: ', padding)) + chalk.cyan.bold( pad((info.coverage.duration.total - info.coverage.duration.gaps).toString(),5) ));
|
||||||
|
this.log(chalk.cyan(pad('Gaps: ', padding + 4)) + chalk.cyan.bold(info.coverage.gaps.length) + chalk.cyan(' [') + info.coverage.gaps.map(function(g) {
|
||||||
|
var clr = 'green';
|
||||||
|
if( g.duration > 35 ) clr = 'yellow';
|
||||||
|
if( g.duration > 90 ) clr = 'red';
|
||||||
|
return chalk[clr].bold( g.duration) ;
|
||||||
|
}).join(', ') + chalk.cyan(']') );
|
||||||
|
|
||||||
|
this.log(chalk.cyan(pad('Overlaps: ', padding + 4)) + chalk.cyan.bold(info.coverage.overlaps.length) + chalk.cyan(' [') + info.coverage.overlaps.map(function(ol) {
|
||||||
|
var clr = 'green';
|
||||||
|
if( ol.duration > 35 ) clr = 'yellow';
|
||||||
|
if( ol.duration > 90 ) clr = 'red';
|
||||||
|
return chalk[clr].bold( ol.duration) ;
|
||||||
|
}).join(', ') + chalk.cyan(']') );
|
||||||
|
|
||||||
|
var tot = 0;
|
||||||
|
this.log();
|
||||||
|
this.log( chalk.cyan.bold('KEYWORDS') + chalk.cyan(' (') + chalk.white.bold( info.keywords.length ) +
|
||||||
|
chalk.cyan('):\n\n') +
|
||||||
|
info.keywords.map(function(g) {
|
||||||
|
tot += g.count;
|
||||||
|
return chalk.cyan( pad(g.name + ': ', padding) ) + chalk.cyan.bold( pad( g.count.toString(), 5 )) + chalk.cyan(' mentions');
|
||||||
|
}).join('\n'));
|
||||||
|
|
||||||
|
this.log(chalk.cyan( pad('TOTAL: ', padding) ) + chalk.white.bold( pad( tot.toString(), 5 )) + chalk.cyan(' mentions'));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HME.beforeConvert:
|
||||||
|
// TODO: Core should not log
|
||||||
|
this.log( chalk.green('Converting ') + chalk.green.bold(evt.srcFile) +
|
||||||
|
chalk.green(' (' + evt.srcFmt + ') to ') + chalk.green.bold(evt.dstFile) +
|
||||||
|
chalk.green(' (' + evt.dstFmt + ').'));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,15 +12,20 @@ Implementation of the 'analyze' verb for HackMyResume.
|
|||||||
|
|
||||||
var MKDIRP = require('mkdirp')
|
var MKDIRP = require('mkdirp')
|
||||||
, PATH = require('path')
|
, PATH = require('path')
|
||||||
|
, HME = require('../core/event-codes')
|
||||||
, _ = require('underscore')
|
, _ = require('underscore')
|
||||||
, ResumeFactory = require('../core/resume-factory')
|
, ResumeFactory = require('../core/resume-factory')
|
||||||
, Verb = require('../core/verb')
|
, Verb = require('../core/verb')
|
||||||
, chalk = require('chalk');
|
, chalk = require('chalk');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var AnalyzeVerb = module.exports = Verb.extend({
|
var AnalyzeVerb = module.exports = Verb.extend({
|
||||||
|
|
||||||
|
init: function() {
|
||||||
|
this._super('analyze');
|
||||||
|
},
|
||||||
|
|
||||||
invoke: function() {
|
invoke: function() {
|
||||||
analyze.apply( this, arguments );
|
analyze.apply( this, arguments );
|
||||||
}
|
}
|
||||||
@ -33,17 +38,17 @@ Implementation of the 'analyze' verb for HackMyResume.
|
|||||||
Run the 'analyze' command.
|
Run the 'analyze' command.
|
||||||
*/
|
*/
|
||||||
function analyze( sources, dst, opts, logger ) {
|
function analyze( sources, dst, opts, logger ) {
|
||||||
|
this.stat('begin');
|
||||||
var _log = logger || console.log;
|
var _log = logger || console.log;
|
||||||
if( !sources || !sources.length ) throw { fluenterror: 3 };
|
if( !sources || !sources.length ) throw { fluenterror: 3 };
|
||||||
|
|
||||||
var nlzrs = _loadInspectors();
|
var nlzrs = _loadInspectors();
|
||||||
|
_.each(sources, function(src) {
|
||||||
sources.forEach( function(src) {
|
|
||||||
var result = ResumeFactory.loadOne( src, {
|
var result = ResumeFactory.loadOne( src, {
|
||||||
log: _log, format: 'FRESH', objectify: true, throw: false
|
log: _log, format: 'FRESH', objectify: true, throw: false
|
||||||
});
|
});
|
||||||
result.error || _analyze( result, nlzrs, opts, _log );
|
result.error || _analyze.call(this, result, nlzrs, opts, _log );
|
||||||
});
|
}, this);
|
||||||
|
this.stat('end');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -58,45 +63,11 @@ Implementation of the 'analyze' verb for HackMyResume.
|
|||||||
'FRESH' : 'JRS';
|
'FRESH' : 'JRS';
|
||||||
|
|
||||||
var padding = 20;
|
var padding = 20;
|
||||||
log(chalk.cyan('Analyzing ') + chalk.cyan.bold(safeFormat) +
|
this.stat( HME.beforeAnalyze, { fmt: safeFormat, file: resumeObject.file });
|
||||||
chalk.cyan(' resume: ') + chalk.cyan.bold(resumeObject.file));
|
|
||||||
var info = _.mapObject( nlzrs, function(val, key) {
|
var info = _.mapObject( nlzrs, function(val, key) {
|
||||||
return val.run( resumeObject.rez );
|
return val.run( resumeObject.rez );
|
||||||
});
|
});
|
||||||
|
this.stat( HME.afterAnalyze, { info: info } );
|
||||||
log(chalk.cyan.bold('\nSECTIONS') + chalk.cyan(' (') + chalk.white.bold(_.keys(info.totals).length) + chalk.cyan('):\n'));
|
|
||||||
var pad = require('string-padding');
|
|
||||||
_.each( info.totals, function(tot, key) {
|
|
||||||
log(chalk.cyan(pad(key + ': ',20)) + chalk.cyan.bold(pad(tot.toString(),5)));
|
|
||||||
});
|
|
||||||
|
|
||||||
log();
|
|
||||||
log(chalk.cyan.bold('COVERAGE') + chalk.cyan(' (') + chalk.white.bold( info.coverage.pct ) + chalk.cyan('):\n'));
|
|
||||||
log(chalk.cyan(pad('Total Days: ', padding)) + chalk.cyan.bold( pad(info.coverage.duration.total.toString(),5) ));
|
|
||||||
log(chalk.cyan(pad('Employed: ', padding)) + chalk.cyan.bold( pad((info.coverage.duration.total - info.coverage.duration.gaps).toString(),5) ));
|
|
||||||
log(chalk.cyan(pad('Gaps: ', padding + 4)) + chalk.cyan.bold(info.coverage.gaps.length) + chalk.cyan(' [') + info.coverage.gaps.map(function(g) {
|
|
||||||
var clr = 'green';
|
|
||||||
if( g.duration > 35 ) clr = 'yellow';
|
|
||||||
if( g.duration > 90 ) clr = 'red';
|
|
||||||
return chalk[clr].bold( g.duration) ;
|
|
||||||
}).join(', ') + chalk.cyan(']') );
|
|
||||||
log(chalk.cyan(pad('Overlaps: ', padding + 4)) + chalk.cyan.bold(info.coverage.overlaps.length) + chalk.cyan(' [') + info.coverage.overlaps.map(function(ol) {
|
|
||||||
var clr = 'green';
|
|
||||||
if( ol.duration > 35 ) clr = 'yellow';
|
|
||||||
if( ol.duration > 90 ) clr = 'red';
|
|
||||||
return chalk[clr].bold( ol.duration) ;
|
|
||||||
}).join(', ') + chalk.cyan(']') );
|
|
||||||
|
|
||||||
var tot = 0;
|
|
||||||
log();
|
|
||||||
log( chalk.cyan.bold('KEYWORDS') + chalk.cyan(' (') + chalk.white.bold( info.keywords.length ) +
|
|
||||||
chalk.cyan('):\n\n') +
|
|
||||||
info.keywords.map(function(g) {
|
|
||||||
tot += g.count;
|
|
||||||
return chalk.cyan( pad(g.name + ': ', padding) ) + chalk.cyan.bold( pad( g.count.toString(), 5 )) + chalk.cyan(' mentions');
|
|
||||||
}).join('\n'));
|
|
||||||
|
|
||||||
log(chalk.cyan( pad('TOTAL: ', padding) ) + chalk.white.bold( pad( tot.toString(), 5 )) + chalk.cyan(' mentions'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,12 +12,18 @@ Implementation of the 'convert' verb for HackMyResume.
|
|||||||
|
|
||||||
var ResumeFactory = require('../core/resume-factory')
|
var ResumeFactory = require('../core/resume-factory')
|
||||||
, chalk = require('chalk')
|
, chalk = require('chalk')
|
||||||
, Verb = require('../core/verb')
|
, Verb = require('../core/verb')
|
||||||
, HACKMYSTATUS = require('../core/status-codes');
|
, HACKMYSTATUS = require('../core/status-codes')
|
||||||
|
, _ = require('underscore')
|
||||||
|
, HME = require('../core/event-codes');
|
||||||
|
|
||||||
|
|
||||||
var ConvertVerb = module.exports = Verb.extend({
|
var ConvertVerb = module.exports = Verb.extend({
|
||||||
|
|
||||||
|
init: function() {
|
||||||
|
this._super('convert');
|
||||||
|
},
|
||||||
|
|
||||||
invoke: function() {
|
invoke: function() {
|
||||||
convert.apply( this, arguments );
|
convert.apply( this, arguments );
|
||||||
}
|
}
|
||||||
@ -50,7 +56,7 @@ Implementation of the 'convert' verb for HackMyResume.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load source resumes
|
// Load source resumes
|
||||||
srcs.forEach( function( src, idx ) {
|
_.each(srcs, function( src, idx ) {
|
||||||
|
|
||||||
// Load the resume
|
// Load the resume
|
||||||
var rinfo = ResumeFactory.loadOne( src, {
|
var rinfo = ResumeFactory.loadOne( src, {
|
||||||
@ -62,15 +68,12 @@ Implementation of the 'convert' verb for HackMyResume.
|
|||||||
'JRS' : 'FRESH'
|
'JRS' : 'FRESH'
|
||||||
, targetFormat = srcFmt === 'JRS' ? 'FRESH' : 'JRS';
|
, targetFormat = srcFmt === 'JRS' ? 'FRESH' : 'JRS';
|
||||||
|
|
||||||
// TODO: Core should not log
|
this.stat(HME.beforeConvert, { srcFile: rinfo.file, srcFmt: srcFmt, dstFile: dst[idx], dstFmt: targetFormat });
|
||||||
_log( chalk.green('Converting ') + chalk.green.bold(rinfo.file) +
|
|
||||||
chalk.green(' (' + srcFmt + ') to ') + chalk.green.bold(dst[idx]) +
|
|
||||||
chalk.green(' (' + targetFormat + ').'));
|
|
||||||
|
|
||||||
// Save it to the destination format
|
// Save it to the destination format
|
||||||
s.saveAs( dst[idx], targetFormat );
|
s.saveAs( dst[idx], targetFormat );
|
||||||
|
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,10 @@ Implementation of the 'validate' verb for HackMyResume.
|
|||||||
|
|
||||||
var ValidateVerb = module.exports = Verb.extend({
|
var ValidateVerb = module.exports = Verb.extend({
|
||||||
|
|
||||||
|
init: function() {
|
||||||
|
this._super('validate');
|
||||||
|
},
|
||||||
|
|
||||||
invoke: function() {
|
invoke: function() {
|
||||||
validate.apply( this, arguments );
|
validate.apply( this, arguments );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user