1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-05 01:56:21 +00:00
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 class FreshResume extends AbstractResume
###* Initialize the FreshResume from file. ### ###* Initialize the FreshResume from file. ###
open: ( file, opts ) -> open: ( file, opts ) ->
raw = FS.readFileSync file, 'utf8' raw = FS.readFileSync file, 'utf8'
@ -36,12 +38,15 @@ class FreshResume extends AbstractResume
@imp.file = file @imp.file = file
ret ret
###* Initialize the the FreshResume from JSON string data. ### ###* Initialize the the FreshResume from JSON string data. ###
parse: ( stringData, opts ) -> parse: ( stringData, opts ) ->
@imp = @imp ? raw: stringData @imp = @imp ? raw: stringData
this.parseJSON JSON.parse( stringData ), opts this.parseJSON JSON.parse( stringData ), opts
###* ###*
Initialize the FreshResume from JSON. Initialize the FreshResume from JSON.
Open and parse the specified FRESH resume. Merge the JSON object model onto 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 the sheet to disk (for environments that have disk access). ###
save: ( filename ) -> save: ( filename ) ->
@imp.file = filename || @imp.file @imp.file = filename || @imp.file
@ -114,7 +120,6 @@ class FreshResume extends AbstractResume
###* ###*
Duplicate this FreshResume instance. Duplicate this FreshResume instance.
This method first extend()s this object onto an empty, creating a deep copy, 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 @ stringify: () -> FreshResume.stringify @
###* ###*
Create a copy of this resume in which all string fields have been run through 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). 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 work experience to the sheet. ###
add: ( moniker ) -> add: ( moniker ) ->
defSheet = FreshResume.default() defSheet = FreshResume.default()
@ -258,7 +260,6 @@ class FreshResume extends AbstractResume
###* ###*
Determine if the sheet includes a specific social profile (eg, GitHub). Determine if the sheet includes a specific social profile (eg, GitHub).
### ###
@ -268,6 +269,7 @@ class FreshResume extends AbstractResume
p.network.trim().toLowerCase() == socialNetwork p.network.trim().toLowerCase() == socialNetwork
###* Return the specified network profile. ### ###* Return the specified network profile. ###
getProfile: ( socialNetwork ) -> getProfile: ( socialNetwork ) ->
socialNetwork = socialNetwork.trim().toLowerCase() socialNetwork = socialNetwork.trim().toLowerCase()
@ -275,6 +277,7 @@ class FreshResume extends AbstractResume
sn.network.trim().toLowerCase() == socialNetwork sn.network.trim().toLowerCase() == socialNetwork
###* ###*
Return an array of profiles for the specified network, for when the user Return an array of profiles for the specified network, for when the user
has multiple eg. GitHub accounts. has multiple eg. GitHub accounts.
@ -285,6 +288,7 @@ class FreshResume extends AbstractResume
sn.network.trim().toLowerCase() == socialNetwork sn.network.trim().toLowerCase() == socialNetwork
###* Determine if the sheet includes a specific skill. ### ###* Determine if the sheet includes a specific skill. ###
hasSkill: ( skill ) -> hasSkill: ( skill ) ->
skill = skill.trim().toLowerCase() skill = skill.trim().toLowerCase()
@ -308,10 +312,12 @@ class FreshResume extends AbstractResume
ret ret
duration: (unit) -> duration: (unit) ->
super('employment.history', 'start', 'end', unit) super('employment.history', 'start', 'end', unit)
###* ###*
Sort dated things on the sheet by start date descending. Assumes that dates Sort dated things on the sheet by start date descending. Assumes that dates
on the sheet have been processed with _parseDates(). 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 else ( a.safe.date.isAfter(b.safe.date) && -1 ) || 0
###* ###*
Get the default (starter) sheet. Get the default (starter) sheet.
### ###
@ -347,6 +354,7 @@ FreshResume.default = () ->
new FreshResume().parseJSON( require 'fresh-resume-starter' ) new FreshResume().parseJSON( require 'fresh-resume-starter' )
###* ###*
Convert the supplied FreshResume to a JSON string, sanitizing meta-properties Convert the supplied FreshResume to a JSON string, sanitizing meta-properties
along the way. along the way.
@ -360,6 +368,7 @@ FreshResume.stringify = ( obj ) ->
JSON.stringify obj, replacer, 2 JSON.stringify obj, replacer, 2
###* ###*
Convert human-friendly dates into formal Moment.js dates for all collections. 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 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. ### ###* Export the Sheet function/ctor. ###
module.exports = FreshResume module.exports = FreshResume
# Note 1: Adjust default date validation to allow YYYY and YYYY-MM formats # Note 1: Adjust default date validation to allow YYYY and YYYY-MM formats
# in addition to YYYY-MM-DD. The original regex: # in addition to YYYY-MM-DD. The original regex:
# #

View File

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