1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-07-03 17:01:05 +01:00

feat: convert: support multiple JRS versions

This commit is contained in:
hacksalot
2018-02-09 21:34:24 -05:00
parent 58fe46dc83
commit 7cfdb95a04
12 changed files with 109 additions and 22 deletions

View File

@ -94,13 +94,26 @@ class FreshResume# extends AbstractResume
###*
Save the sheet to disk in a specific format, either FRESH or JSON Resume.
###
saveAs: ( filename, format ) ->
if format != 'JRS'
saveAs: ( filename, format, version ) ->
# If format isn't specified, default to FRESH
safeFormat = (format || 'FRESH').trim()
safeVersion = version || "0"
# Validate against the FRESH version regex
# freshVersionReg = require '../utils/fresh-version-regex'
# if (not freshVersionReg().test( safeFormat ))
# throw badVer: safeFormat
parts = safeFormat.split '@'
if parts[0] == 'FRESH'
@imp.file = filename || @imp.file
FS.writeFileSync @imp.file, @stringify(), 'utf8'
else
newRep = CONVERTER.toJRS this
else if parts[0] == 'JRS'
newRep = CONVERTER.toJRS @, null, if parts.length > 1 then parts[1] else "1"
FS.writeFileSync filename, JRSResume.stringify( newRep ), 'utf8'
else
throw badVer: safeFormat
@