This commit is contained in:
hacksalot 2016-02-04 15:23:47 -05:00
parent 3c551eb923
commit 661fb91861
2 changed files with 22 additions and 8 deletions

View File

@ -29,6 +29,8 @@ object is an instantiation of that JSON decorated with utility methods.
###
class FreshResume extends AbstractResume
###* Initialize the FreshResume from file. ###
open: ( file, opts ) ->
raw = FS.readFileSync file, 'utf8'
@ -36,12 +38,15 @@ class FreshResume extends AbstractResume
@imp.file = file
ret
###* Initialize the the FreshResume from JSON string data. ###
parse: ( stringData, opts ) ->
@imp = @imp ? raw: stringData
this.parseJSON JSON.parse( stringData ), opts
###*
Initialize the FreshResume from JSON.
Open and parse the specified FRESH resume. Merge the JSON object model onto
@ -92,6 +97,7 @@ class FreshResume extends AbstractResume
@
###* Save the sheet to disk (for environments that have disk access). ###
save: ( filename ) ->
@imp.file = filename || @imp.file
@ -114,7 +120,6 @@ class FreshResume extends AbstractResume
###*
Duplicate this FreshResume instance.
This method first extend()s this object onto an empty, creating a deep copy,
@ -137,6 +142,7 @@ class FreshResume extends AbstractResume
stringify: () -> FreshResume.stringify @
###*
Create a copy of this resume in which all string fields have been run through
a transformation function (such as a Markdown filter or XML encoder).
@ -232,10 +238,6 @@ class FreshResume extends AbstractResume
###* Add work experience to the sheet. ###
add: ( moniker ) ->
defSheet = FreshResume.default()
@ -258,7 +260,6 @@ class FreshResume extends AbstractResume
###*
Determine if the sheet includes a specific social profile (eg, GitHub).
###
@ -268,6 +269,7 @@ class FreshResume extends AbstractResume
p.network.trim().toLowerCase() == socialNetwork
###* Return the specified network profile. ###
getProfile: ( socialNetwork ) ->
socialNetwork = socialNetwork.trim().toLowerCase()
@ -275,6 +277,7 @@ class FreshResume extends AbstractResume
sn.network.trim().toLowerCase() == socialNetwork
###*
Return an array of profiles for the specified network, for when the user
has multiple eg. GitHub accounts.
@ -285,6 +288,7 @@ class FreshResume extends AbstractResume
sn.network.trim().toLowerCase() == socialNetwork
###* Determine if the sheet includes a specific skill. ###
hasSkill: ( skill ) ->
skill = skill.trim().toLowerCase()
@ -308,10 +312,12 @@ class FreshResume extends AbstractResume
ret
duration: (unit) ->
super('employment.history', 'start', 'end', unit)
###*
Sort dated things on the sheet by start date descending. Assumes that dates
on the sheet have been processed with _parseDates().
@ -340,6 +346,7 @@ class FreshResume extends AbstractResume
else ( a.safe.date.isAfter(b.safe.date) && -1 ) || 0
###*
Get the default (starter) sheet.
###
@ -347,6 +354,7 @@ FreshResume.default = () ->
new FreshResume().parseJSON( require 'fresh-resume-starter' )
###*
Convert the supplied FreshResume to a JSON string, sanitizing meta-properties
along the way.
@ -360,6 +368,7 @@ FreshResume.stringify = ( obj ) ->
JSON.stringify obj, replacer, 2
###*
Convert human-friendly dates into formal Moment.js dates for all collections.
We don't want to lose the raw textual date as entered by the user, so we store
@ -401,6 +410,8 @@ _parseDates = () ->
###* Export the Sheet function/ctor. ###
module.exports = FreshResume
# Note 1: Adjust default date validation to allow YYYY and YYYY-MM formats
# in addition to YYYY-MM-DD. The original regex:
#

View File

@ -34,6 +34,7 @@ class JRSResume extends AbstractResume
ret
###* Initialize the the JSResume from string. ###
parse: ( stringData, opts ) ->
@imp = @imp ? raw: stringData
@ -117,7 +118,6 @@ class JRSResume extends AbstractResume
stringify: () -> JRSResume.stringify( @ )
@ -157,7 +157,6 @@ class JRSResume extends AbstractResume
###* Add work experience to the sheet. ###
add: ( moniker ) ->
defSheet = JRSResume.default()
@ -203,10 +202,12 @@ class JRSResume extends AbstractResume
ret
duration: (unit) ->
super('work', 'startDate', 'endDate', unit)
###*
Sort dated things on the sheet by start date descending. Assumes that dates
on the sheet have been processed with _parseDates().
@ -233,6 +234,7 @@ class JRSResume extends AbstractResume
else ( a.safeReleaseDate.isAfter(b.safeReleaseDate) && -1 ) || 0
dupe: () ->
rnew = new JRSResume()
rnew.parse this.stringify(), { }
@ -310,6 +312,7 @@ JRSResume.stringify = ( obj ) ->
JSON.stringify obj, replacer, 2
###*
Convert human-friendly dates into formal Moment.js dates for all collections.
We don't want to lose the raw textual date as entered by the user, so we store