mirror of
				https://github.com/JuanCanham/HackMyResume.git
				synced 2025-11-04 14:57:26 +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:
		@@ -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' )
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user