1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-12-22 13:37:21 +00:00

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.
This commit is contained in:
hacksalot 2016-02-04 18:49:16 -05:00
parent 661fb91861
commit 2758038858
14 changed files with 90 additions and 62 deletions

View File

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

4
dist/cli/out.js vendored
View File

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

View File

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

View File

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

View File

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

View File

@ -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], {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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() {

View File

@ -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() {