From 2758038858e58e8ef5fd107681b8a0fe18546008 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Thu, 4 Feb 2016 18:49:16 -0500 Subject: [PATCH] Cleanup and bug fixes. Remove file-based open methods from resume classes; force clients to use clean string-based or JSON overloads; fix processing glitch in validate(); tweak outputs; adjust tests; update CHANGELOG; etc. --- CHANGELOG.md | 60 +++++++++++++++++++++++ dist/cli/out.js | 4 +- dist/core/fresh-resume.js | 13 +---- dist/core/jrs-resume.js | 13 +---- dist/renderers/handlebars-generator.js | 2 +- dist/verbs/validate.js | 2 +- package.json | 4 +- src/cli/out.coffee | 7 +-- src/core/fresh-resume.coffee | 11 +---- src/core/jrs-resume.coffee | 11 +---- src/renderers/handlebars-generator.coffee | 3 +- src/verbs/validate.coffee | 3 +- test/scripts/test-fresh-sheet.js | 10 ++-- test/scripts/test-jrs-sheet.js | 9 ++-- 14 files changed, 90 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd750d1..c1b264c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,65 @@ CHANGELOG ========= +## v1.7.4 + +### Added + +- [Build instructions](https://github.com/hacksalot/HackMyResume/blob/master/BUILDING.md). + +### Changed + +- More precise date handling. + +### Fixed + +- Issue with incomplete PDF generation (#127). +- Issue with building JSON Resume themes (#128). +- Issue with generating `.json` output format by itself (#97). + +## v1.7.3 + +### Fixed + +- Issue with generated PDFs being chopped off and displaying a mysterious sequence of numbers of unknown and possibly alien origin (#127). + +- Unsightly border on Modern:PDF. + +- Modern|Positive:PDF formats now correctly reference their PDF-specific CSS files. + +- `Incorrect helper use` warning in Positive:DOC. + +## v1.7.2 + +### Changed + +- Interim release supporting FluentCV Desktop. + +### Internal + +- Moved [HackMyCore](https://github.com/hacksalot/HackMyCore) dependency to +submodule. + +## v1.7.1 + +### Changed + +- Caffeinate. CoffeeScript now used throughout +[HackMyResume](https://github.com/hacksalot/HackMyResume) and +[HackMyCore](https://github.com/hacksalot/HackMyCore); generated JavaScript +lives in `/dist`. + +### Fixed + +- Issue with generating a single PDF with the `.pdf` extension (#99). + +## v1.7.0 + +### Changed + +- [Internal] Relocated HMR processing code to the +[HackMyCore](https://github.com/hacksalot/HackMyCore) project. Shouldn't affect +normal use. + ## v1.6.0 ### Major Improvements diff --git a/dist/cli/out.js b/dist/cli/out.js index 33512c2..5fc98f5 100644 --- a/dist/cli/out.js +++ b/dist/cli/out.js @@ -135,8 +135,8 @@ Output routines for HackMyResume. style = evt.isValid ? 'green' : 'yellow'; L(M2C(this.msgs.afterValidate.msg[0], 'white') + chalk[style].bold(evt.isValid ? this.msgs.afterValidate.msg[1] : this.msgs.afterValidate.msg[2]), evt.file, evt.fmt); if (evt.errors) { - return _.each(evt.errors, function(err, idx) { - return L(chalk.yellow.bold('--> ') + chalk.yellow(err.field.replace('data.', 'resume.').toUpperCase() + ' ' + err.message)); + _.each(evt.errors, function(err, idx) { + L(chalk.yellow.bold('--> ') + chalk.yellow(err.field.replace('data.', 'resume.').toUpperCase() + ' ' + err.message)); }, this); } break; diff --git a/dist/core/fresh-resume.js b/dist/core/fresh-resume.js index f48c038..e8592e2 100644 --- a/dist/core/fresh-resume.js +++ b/dist/core/fresh-resume.js @@ -51,17 +51,6 @@ Definition of the FRESHResume class. } - /** Initialize the FreshResume from file. */ - - FreshResume.prototype.open = function(file, opts) { - var raw, ret; - raw = FS.readFileSync(file, 'utf8'); - ret = this.parse(raw, opts); - this.imp.file = file; - return ret; - }; - - /** Initialize the the FreshResume from JSON string data. */ FreshResume.prototype.parse = function(stringData, opts) { @@ -442,7 +431,7 @@ Definition of the FRESHResume class. */ FreshResume["default"] = function() { - return new FreshResume().parseJSON(require('fresh-resume-starter')); + return new FreshResume().parseJSON(require('fresh-resume-starter').fresh); }; diff --git a/dist/core/jrs-resume.js b/dist/core/jrs-resume.js index b3ebc82..96bd8fc 100644 --- a/dist/core/jrs-resume.js +++ b/dist/core/jrs-resume.js @@ -45,17 +45,6 @@ Definition of the JRSResume class. } - /** Initialize the JSResume from file. */ - - JRSResume.prototype.open = function(file, opts) { - var raw, ret; - raw = FS.readFileSync(file, 'utf8'); - ret = this.parse(raw, opts); - this.imp.file = file; - return ret; - }; - - /** Initialize the the JSResume from string. */ JRSResume.prototype.parse = function(stringData, opts) { @@ -364,7 +353,7 @@ Definition of the JRSResume class. /** Get the default (empty) sheet. */ JRSResume["default"] = function() { - return new JRSResume().open(PATH.join(__dirname, 'empty-jrs.json'), 'Empty'); + return new JRSResume().parseJSON(require('fresh-resume-starter').jrs); }; diff --git a/dist/renderers/handlebars-generator.js b/dist/renderers/handlebars-generator.js index 1409a5a..04437d8 100644 --- a/dist/renderers/handlebars-generator.js +++ b/dist/renderers/handlebars-generator.js @@ -43,7 +43,7 @@ Definition of the HandlebarsGenerator class. return template(data); } catch (_error) { throw { - fluenterror: template ? HMSTATUS.invokeTemplate : HMSTATUS.compileTemplate, + fluenterror: HMSTATUS[template ? 'invokeTemplate' : 'compileTemplate'], inner: _error }; } diff --git a/dist/verbs/validate.js b/dist/verbs/validate.js index bb8d0a8..4d47a5f 100644 --- a/dist/verbs/validate.js +++ b/dist/verbs/validate.js @@ -96,7 +96,7 @@ Implementation of the 'validate' verb for HackMyResume. }; } json = obj.json; - fmt = json.basics ? 'jrs' : 'fresh'; + fmt = json.basics ? 'jars' : 'fresh'; errors = []; try { validate = validator(schemas[fmt], { diff --git a/package.json b/package.json index cc59021..e6d2f7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hackmyresume", - "version": "1.7.4", + "version": "1.7.5", "description": "Generate polished résumés and CVs in HTML, Markdown, LaTeX, MS Word, PDF, plain text, JSON, XML, YAML, smoke signal, and carrier pigeon.", "repository": { "type": "git", @@ -53,7 +53,7 @@ "copy": "^0.1.3", "extend": "^3.0.0", "fresca": "~0.6.0", - "fresh-jrs-converter": "^0.2.0", + "fresh-jrs-converter": "^0.2.1", "fresh-resume-starter": "^0.2.2", "fresh-themes": "^0.14.1-beta", "fs-extra": "^0.26.4", diff --git a/src/cli/out.coffee b/src/cli/out.coffee index 98a7103..734c668 100644 --- a/src/cli/out.coffee +++ b/src/cli/out.coffee @@ -149,11 +149,12 @@ module.exports = class OutputHandler else this.msgs.afterValidate.msg[2] ), evt.file, evt.fmt ); - if evt.errors - _.each( evt.errors, (err,idx) -> + _.each evt.errors, (err,idx) -> L( chalk.yellow.bold('--> ') + chalk.yellow(err.field.replace('data.','resume.').toUpperCase() + ' ' + err.message)) - , @) + return + , @ + return when HME.afterPeek sty = if evt.error then 'red' else ( if evt.target != undefined then 'green' else 'yellow' ) diff --git a/src/core/fresh-resume.coffee b/src/core/fresh-resume.coffee index 37cd9d1..e91deb5 100644 --- a/src/core/fresh-resume.coffee +++ b/src/core/fresh-resume.coffee @@ -31,15 +31,6 @@ class FreshResume extends AbstractResume - ###* Initialize the FreshResume from file. ### - open: ( file, opts ) -> - raw = FS.readFileSync file, 'utf8' - ret = this.parse raw, opts - @imp.file = file - ret - - - ###* Initialize the the FreshResume from JSON string data. ### parse: ( stringData, opts ) -> @imp = @imp ? raw: stringData @@ -351,7 +342,7 @@ class FreshResume extends AbstractResume Get the default (starter) sheet. ### FreshResume.default = () -> - new FreshResume().parseJSON( require 'fresh-resume-starter' ) + new FreshResume().parseJSON require('fresh-resume-starter').fresh diff --git a/src/core/jrs-resume.coffee b/src/core/jrs-resume.coffee index a7195ad..daa9294 100644 --- a/src/core/jrs-resume.coffee +++ b/src/core/jrs-resume.coffee @@ -26,15 +26,6 @@ class JRSResume extends AbstractResume - ###* Initialize the JSResume from file. ### - open: ( file, opts ) -> - raw = FS.readFileSync file, 'utf8' - ret = this.parse raw, opts - @imp.file = file - ret - - - ###* Initialize the the JSResume from string. ### parse: ( stringData, opts ) -> @imp = @imp ? raw: stringData @@ -294,7 +285,7 @@ class JRSResume extends AbstractResume ###* Get the default (empty) sheet. ### JRSResume.default = () -> - new JRSResume().open PATH.join( __dirname, 'empty-jrs.json'), 'Empty' + new JRSResume().parseJSON require('fresh-resume-starter').jrs diff --git a/src/renderers/handlebars-generator.coffee b/src/renderers/handlebars-generator.coffee index 0e1e201..e4db745 100644 --- a/src/renderers/handlebars-generator.coffee +++ b/src/renderers/handlebars-generator.coffee @@ -33,7 +33,8 @@ HandlebarsGenerator = module.exports = return template data catch throw - fluenterror: if template then HMSTATUS.invokeTemplate else HMSTATUS.compileTemplate + fluenterror: + HMSTATUS[ if template then 'invokeTemplate' else 'compileTemplate' ] inner: _error diff --git a/src/verbs/validate.coffee b/src/verbs/validate.coffee index 3f5feb9..9150987 100644 --- a/src/verbs/validate.coffee +++ b/src/verbs/validate.coffee @@ -70,7 +70,7 @@ _validateOne = (t, validator, schemas) -> # Successfully read the resume. Now parse it as JSON. json = obj.json - fmt = if json.basics then 'jrs' else 'fresh' + fmt = if json.basics then 'jars' else 'fresh' errors = [] try @@ -78,6 +78,7 @@ _validateOne = (t, validator, schemas) -> formats: { date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/ } }; ret.isValid = validate json + if !ret.isValid errors = validate.errors catch diff --git a/test/scripts/test-fresh-sheet.js b/test/scripts/test-fresh-sheet.js index c3ef1ec..b2d206e 100644 --- a/test/scripts/test-fresh-sheet.js +++ b/test/scripts/test-fresh-sheet.js @@ -5,6 +5,7 @@ var chai = require('chai') , path = require('path') , _ = require('underscore') , FRESHResume = require('../../dist/core/fresh-resume') + , ResumeFactory = require('../../dist/core/resume-factory') , validator = require('is-my-json-valid'); chai.config.includeStack = false; @@ -17,7 +18,9 @@ function testResume(opts) { it('should open without throwing an exception', function () { function tryOpen() { - _sheet = new FRESHResume().open( opts.path ); + var res = ResumeFactory.loadOne( opts.path, { objectify: true } ); + _sheet = res.rez; + //_sheet = new FRESHResume().open( opts.path ); } tryOpen.should.not.Throw(); }); @@ -39,8 +42,9 @@ function testResume(opts) { }); it('should not be modified after saving', function() { - var savedSheet = new FRESHResume().open('test/sandbox/' + opts.title + '.json'); - _sheet.stringify().should.equal( savedSheet.stringify() ); + var savedSheet = ResumeFactory.loadOne( 'test/sandbox/' + opts.title + '.json', { objectify: true } ); + //var savedSheet = new FRESHResume().open('test/sandbox/' + opts.title + '.json'); + _sheet.stringify().should.equal( savedSheet.rez.stringify() ); }); it('should validate against the FRESH resume schema', function() { diff --git a/test/scripts/test-jrs-sheet.js b/test/scripts/test-jrs-sheet.js index db71be6..76ad314 100644 --- a/test/scripts/test-jrs-sheet.js +++ b/test/scripts/test-jrs-sheet.js @@ -5,6 +5,7 @@ var chai = require('chai') , path = require('path') , _ = require('underscore') , JRSResume = require('../../dist/core/jrs-resume') + , ResumeFactory = require('../../dist/core/resume-factory') , validator = require('is-my-json-valid'); chai.config.includeStack = false; @@ -20,8 +21,8 @@ function testResume( opts ) { it('should open without throwing an exception', function () { var that = this; function tryOpen() { - _sheet = new JRSResume().open( - path.normalize( path.join( __dirname, '/../resumes/jrs-0.0.0/' + opts.title + '.json' ) ) ) + var res = ResumeFactory.loadOne( path.normalize( path.join( __dirname, '/../resumes/jrs-0.0.0/' + opts.title + '.json' ) ), { objectify: true } ); + _sheet = res.rez; } tryOpen.should.not.Throw(); }); @@ -44,8 +45,8 @@ function testResume( opts ) { }); it('should not be modified after saving', function() { - var savedSheet = new JRSResume().open( 'test/sandbox/' + opts.title + '.json' ); - _sheet.stringify().should.equal( savedSheet.stringify() ); + var res = ResumeFactory.loadOne( 'test/sandbox/' + opts.title + '.json', { objectify: true } ); + _sheet.stringify().should.equal( res.rez.stringify() ); }); it('should ' + (opts.isValid ? '' : 'NOT ') + 'validate against the JSON Resume schema', function() {