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

chore: update project dependencies

This commit is contained in:
hacksalot
2018-02-12 00:05:29 -05:00
parent 7144126175
commit c4f7350528
71 changed files with 1600 additions and 1737 deletions

View File

@ -1,55 +1,59 @@
/*
Event code definitions.
@module core/default-formats
@license MIT. See LICENSE.md for details.
*/
/** Supported resume formats. */
(function() {
/*
Event code definitions.
@module core/default-formats
@license MIT. See LICENSE.md for details.
*/
/** Supported resume formats. */
module.exports = [
{
name: 'html',
ext: 'html',
gen: new (require('../generators/html-generator'))()
}, {
},
{
name: 'txt',
ext: 'txt',
gen: new (require('../generators/text-generator'))()
}, {
},
{
name: 'doc',
ext: 'doc',
fmt: 'xml',
gen: new (require('../generators/word-generator'))()
}, {
},
{
name: 'pdf',
ext: 'pdf',
fmt: 'html',
is: false,
gen: new (require('../generators/html-pdf-cli-generator'))()
}, {
},
{
name: 'png',
ext: 'png',
fmt: 'html',
is: false,
gen: new (require('../generators/html-png-generator'))()
}, {
},
{
name: 'md',
ext: 'md',
fmt: 'txt',
gen: new (require('../generators/markdown-generator'))()
}, {
},
{
name: 'json',
ext: 'json',
gen: new (require('../generators/json-generator'))()
}, {
},
{
name: 'yml',
ext: 'yml',
fmt: 'yml',
gen: new (require('../generators/json-yaml-generator'))()
}, {
},
{
name: 'latex',
ext: 'tex',
fmt: 'latex',

View File

@ -1,20 +1,20 @@
/*
Event code definitions.
@module core/default-options
@license MIT. See LICENSE.md for details.
*/
(function() {
/*
Event code definitions.
@module core/default-options
@license MIT. See LICENSE.md for details.
*/
module.exports = {
theme: 'modern',
prettify: {
indent_size: 2,
unformatted: ['em', 'strong'],
max_char: 80
max_char: 80 // ← See lib/html.js in above-linked repo
}
};
// wrap_line_length: 120, ← Don't use this
}).call(this);
//# sourceMappingURL=default-options.js.map

View File

@ -1,11 +1,9 @@
/*
Event code definitions.
@module core/event-codes
@license MIT. See LICENSE.md for details.
*/
(function() {
/*
Event code definitions.
@module core/event-codes
@license MIT. See LICENSE.md for details.
*/
module.exports = {
error: -1,
success: 0,

View File

@ -1,18 +1,15 @@
/**
The HackMyResume date representation.
@license MIT. See LICENSE.md for details.
@module core/fluent-date
*/
(function() {
/**
The HackMyResume date representation.
@license MIT. See LICENSE.md for details.
@module core/fluent-date
*/
var FluentDate, abbr, moment, months;
moment = require('moment');
require('../utils/string');
/**
Create a FluentDate from a string or Moment date object. There are a few date
formats to be aware of here.
@ -28,20 +25,17 @@ The HackMyResume date representation.
deprecation warnings, it's recommended to either a) explicitly specify the date
format or b) use an ISO format. For clarity, we handle these cases explicitly.
@class FluentDate
*/
FluentDate = (function() {
function FluentDate(dt) {
*/
FluentDate = class FluentDate {
constructor(dt) {
this.rep = this.fmt(dt);
}
FluentDate.isCurrent = function(dt) {
static isCurrent(dt) {
return !dt || (String.is(dt) && /^(present|now|current)$/.test(dt));
};
}
return FluentDate;
})();
};
months = {};
@ -64,20 +58,20 @@ The HackMyResume date representation.
throws = (throws === void 0 || throws === null) || throws;
if (typeof dt === 'string' || dt instanceof String) {
dt = dt.toLowerCase().trim();
if (/^(present|now|current)$/.test(dt)) {
if (/^(present|now|current)$/.test(dt)) { // "Present", "Now"
return moment();
} else if (/^\D+\s+\d{4}$/.test(dt)) {
} else if (/^\D+\s+\d{4}$/.test(dt)) { // "Mar 2015"
parts = dt.split(' ');
month = months[parts[0]] || abbr[parts[0]];
temp = parts[1] + '-' + ((ref = month < 10) != null ? ref : '0' + {
month: month.toString()
});
return moment(temp, 'YYYY-MM');
} else if (/^\d{4}-\d{1,2}$/.test(dt)) {
} else if (/^\d{4}-\d{1,2}$/.test(dt)) { // "2015-03", "1998-4"
return moment(dt, 'YYYY-MM');
} else if (/^\s*\d{4}\s*$/.test(dt)) {
} else if (/^\s*\d{4}\s*$/.test(dt)) { // "2015"
return moment(dt, 'YYYY');
} else if (/^\s*$/.test(dt)) {
} else if (/^\s*$/.test(dt)) { // "", " "
return moment();
} else {
mt = moment(dt);

View File

@ -1,11 +1,16 @@
/**
Definition of the FRESHResume class.
@license MIT. See LICENSE.md for details.
@module core/fresh-resume
*/
(function() {
/**
Definition of the FRESHResume class.
@license MIT. See LICENSE.md for details.
@module core/fresh-resume
*/
/**
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
the Moment-ified date as a separate property with a prefix of .safe. For ex:
job.startDate is the date as entered by the user. job.safeStartDate is the
parsed Moment.js date that we actually use in processing.
*/
var CONVERTER, FS, FluentDate, FreshResume, JRSResume, MD, PATH, XML, _, __, _parseDates, extend, moment, validator;
FS = require('fs');
@ -32,27 +37,20 @@ Definition of the FRESHResume class.
FluentDate = require('./fluent-date');
/**
A FRESH resume or CV. FRESH resumes are backed by JSON, and each FreshResume
object is an instantiation of that JSON decorated with utility methods.
@constructor
*/
FreshResume = (function() {
function FreshResume() {}
*/
FreshResume = class FreshResume { // extends AbstractResume
/** Initialize the the FreshResume from JSON string data. */
FreshResume.prototype.parse = function(stringData, opts) {
parse(stringData, opts) {
var ref;
this.imp = (ref = this.imp) != null ? ref : {
raw: stringData
};
return this.parseJSON(JSON.parse(stringData), opts);
};
}
/**
Initialize the FreshResume from JSON.
@ -62,20 +60,22 @@ Definition of the FRESHResume class.
@param rep {Object} The raw JSON representation.
@param opts {Object} Resume loading and parsing options.
{
date: Perform safe date conversion.
sort: Sort resume items by date.
compute: Prepare computed resume totals.
date: Perform safe date conversion.
sort: Sort resume items by date.
compute: Prepare computed resume totals.
}
*/
FreshResume.prototype.parseJSON = function(rep, opts) {
var ignoreList, privateList, ref, ref1, scrubbed, scrubber;
*/
parseJSON(rep, opts) {
var ignoreList, privateList, ref, scrubbed, scrubber;
if (opts && opts.privatize) {
// Ignore any element with the 'ignore: true' or 'private: true' designator.
scrubber = require('../utils/resume-scrubber');
ref = scrubber.scrubResume(rep, opts), scrubbed = ref.scrubbed, ignoreList = ref.ignoreList, privateList = ref.privateList;
({scrubbed, ignoreList, privateList} = scrubber.scrubResume(rep, opts));
}
// Now apply the resume representation onto this object
extend(true, this, opts && opts.privatize ? scrubbed : rep);
if (!((ref1 = this.imp) != null ? ref1.processed : void 0)) {
if (!((ref = this.imp) != null ? ref.processed : void 0)) {
// Set up metadata TODO: Clean up metadata on the object model.
opts = opts || {};
if (opts.imp === void 0 || opts.imp) {
this.imp = this.imp || {};
@ -85,6 +85,7 @@ Definition of the FRESHResume class.
}
}
this.imp.processed = true;
// Parse dates, sort dates, and calculate computed values
(opts.date === void 0 || opts.date) && _parseDates.call(this);
(opts.sort === void 0 || opts.sort) && this.sort();
(opts.compute === void 0 || opts.compute) && (this.computed = {
@ -93,25 +94,26 @@ Definition of the FRESHResume class.
});
}
return this;
};
}
/** Save the sheet to disk (for environments that have disk access). */
FreshResume.prototype.save = function(filename) {
save(filename) {
this.imp.file = filename || this.imp.file;
FS.writeFileSync(this.imp.file, this.stringify(), 'utf8');
return this;
};
}
/**
Save the sheet to disk in a specific format, either FRESH or JSON Resume.
*/
FreshResume.prototype.saveAs = function(filename, format) {
*/
saveAs(filename, format) {
var newRep, parts, safeFormat, useEdgeSchema;
// If format isn't specified, default to FRESH
safeFormat = (format && format.trim()) || 'FRESH';
// 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') {
this.imp.file = filename || this.imp.file;
@ -128,8 +130,7 @@ Definition of the FRESHResume class.
};
}
return this;
};
}
/**
Duplicate this FreshResume instance.
@ -137,47 +138,40 @@ Definition of the FRESHResume class.
and then passes the result into a new FreshResume instance via .parseJSON.
We do it this way to create a true clone of the object without re-running any
of the associated processing.
*/
FreshResume.prototype.dupe = function() {
*/
dupe() {
var jso, rnew;
jso = extend(true, {}, this);
rnew = new FreshResume();
rnew.parseJSON(jso, {});
return rnew;
};
}
/**
Convert this object to a JSON string, sanitizing meta-properties along the
way.
*/
FreshResume.prototype.stringify = function() {
*/
stringify() {
return FreshResume.stringify(this);
};
}
/**
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).
TODO: Move this out of FRESHResume.
*/
FreshResume.prototype.transformStrings = function(filt, transformer) {
*/
transformStrings(filt, transformer) {
var ret, trx;
ret = this.dupe();
trx = require('../utils/string-transformer');
return trx(ret, filt, transformer);
};
}
/**
Create a copy of this resume in which all fields have been interpreted as
Markdown.
*/
FreshResume.prototype.markdownify = function() {
*/
markdownify() {
var MDIN, trx;
MDIN = function(txt) {
return MD(txt || '').replace(/^\s*<p>|<\/p>\s*$/gi, '');
@ -189,44 +183,49 @@ Definition of the FRESHResume class.
return MDIN(val);
};
return this.transformStrings(['skills', 'url', 'start', 'end', 'date'], trx);
};
}
/**
Create a copy of this resume in which all fields have been interpreted as
Markdown.
*/
FreshResume.prototype.xmlify = function() {
*/
xmlify() {
var trx;
trx = function(key, val) {
return XML(val);
};
return this.transformStrings([], trx);
};
}
/** Return the resume format. */
FreshResume.prototype.format = function() {
format() {
return 'FRESH';
};
}
/**
Return internal metadata. Create if it doesn't exist.
*/
FreshResume.prototype.i = function() {
*/
i() {
return this.imp = this.imp || {};
};
}
/**
Return a unique list of all skills declared in the resume.
*/
*/
// TODO: Several problems here:
// 1) Confusing name. Easily confused with the keyword-inspector module, which
// parses resume body text looking for these same keywords. This should probably
// be renamed.
FreshResume.prototype.keywords = function() {
// 2) Doesn't bother trying to integrate skills.list with skills.sets if they
// happen to declare different skills, and if skills.sets declares ONE skill and
// skills.list declared 50, only 1 skill will be registered.
// 3) In the future, skill.sets should only be able to use skills declared in
// skills.list. That is, skills.list is the official record of a candidate's
// declared skills. skills.sets is just a way of grouping those into skillsets
// for easier consumption.
keywords() {
var flatSkills;
flatSkills = [];
if (this.skills) {
@ -244,19 +243,17 @@ Definition of the FRESHResume class.
flatSkills = _.uniq(flatSkills);
}
return flatSkills;
};
}
/**
Reset the sheet to an empty state. TODO: refactor/review
*/
FreshResume.prototype.clear = function(clearMeta) {
*/
clear(clearMeta) {
clearMeta = ((clearMeta === void 0) && true) || clearMeta;
if (clearMeta) {
delete this.imp;
}
delete this.computed;
delete this.computed; // Don't use Object.keys() here
delete this.employment;
delete this.service;
delete this.education;
@ -266,14 +263,12 @@ Definition of the FRESHResume class.
delete this.interests;
delete this.skills;
return delete this.social;
};
}
/**
Get a safe count of the number of things in a section.
*/
FreshResume.prototype.count = function(obj) {
*/
count(obj) {
if (!obj) {
return 0;
}
@ -284,14 +279,11 @@ Definition of the FRESHResume class.
return obj.sets.length;
}
return obj.length || 0;
};
}
/** Add work experience to the sheet. */
FreshResume.prototype.add = function(moniker) {
add(moniker) {
var defSheet, newObject;
defSheet = FreshResume["default"]();
defSheet = FreshResume.default();
newObject = defSheet[moniker].history ? $.extend(true, {}, defSheet[moniker].history[0]) : moniker === 'skills' ? $.extend(true, {}, defSheet.skills.sets[0]) : $.extend(true, {}, defSheet[moniker][0]);
this[moniker] = this[moniker] || [];
if (this[moniker].history) {
@ -302,63 +294,53 @@ Definition of the FRESHResume class.
this[moniker].push(newObject);
}
return newObject;
};
}
/**
Determine if the sheet includes a specific social profile (eg, GitHub).
*/
FreshResume.prototype.hasProfile = function(socialNetwork) {
*/
hasProfile(socialNetwork) {
socialNetwork = socialNetwork.trim().toLowerCase();
return this.social && _.some(this.social, function(p) {
return p.network.trim().toLowerCase() === socialNetwork;
});
};
}
/** Return the specified network profile. */
FreshResume.prototype.getProfile = function(socialNetwork) {
getProfile(socialNetwork) {
socialNetwork = socialNetwork.trim().toLowerCase();
return this.social && _.find(this.social, function(sn) {
return sn.network.trim().toLowerCase() === socialNetwork;
});
};
}
/**
Return an array of profiles for the specified network, for when the user
has multiple eg. GitHub accounts.
*/
FreshResume.prototype.getProfiles = function(socialNetwork) {
*/
getProfiles(socialNetwork) {
socialNetwork = socialNetwork.trim().toLowerCase();
return this.social && _.filter(this.social, function(sn) {
return sn.network.trim().toLowerCase() === socialNetwork;
});
};
}
/** Determine if the sheet includes a specific skill. */
FreshResume.prototype.hasSkill = function(skill) {
hasSkill(skill) {
skill = skill.trim().toLowerCase();
return this.skills && _.some(this.skills, function(sk) {
return sk.keywords && _.some(sk.keywords, function(kw) {
return kw.trim().toLowerCase() === skill;
});
});
};
}
/** Validate the sheet against the FRESH Resume schema. */
FreshResume.prototype.isValid = function(info) {
isValid(info) {
var ret, schemaObj, validate;
schemaObj = require('fresh-resume-schema');
validator = require('is-my-json-valid');
validate = validator(schemaObj, {
validate = validator(schemaObj, { // See Note [1].
formats: {
date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/
}
@ -369,21 +351,19 @@ Definition of the FRESHResume class.
this.imp.validationErrors = validate.errors;
}
return ret;
};
}
FreshResume.prototype.duration = function(unit) {
duration(unit) {
var inspector;
inspector = require('../inspectors/duration-inspector');
return inspector.run(this, '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().
*/
FreshResume.prototype.sort = function() {
*/
sort() {
var byDateDesc, sortSection;
byDateDesc = function(a, b) {
if (a.safe.start.isBefore(b.safe.start)) {
@ -417,30 +397,24 @@ Definition of the FRESHResume class.
return (a.safe.date.isAfter(b.safe.date) && -1) || 0;
}
});
};
return FreshResume;
})();
}
};
/**
Get the default (starter) sheet.
*/
FreshResume["default"] = function() {
*/
FreshResume.default = function() {
return new FreshResume().parseJSON(require('fresh-resume-starter').fresh);
};
/**
Convert the supplied FreshResume to a JSON string, sanitizing meta-properties
along the way.
*/
*/
FreshResume.stringify = function(obj) {
var replacer;
replacer = function(key, value) {
replacer = function(key, value) { // Exclude these keys from stringification
var exKeys;
exKeys = ['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index', 'safe', 'result', 'isModified', 'htmlPreview', 'display_progress_bar'];
if (_.some(exKeys, function(val) {
@ -454,19 +428,11 @@ Definition of the FRESHResume class.
return 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
the Moment-ified date as a separate property with a prefix of .safe. For ex:
job.startDate is the date as entered by the user. job.safeStartDate is the
parsed Moment.js date that we actually use in processing.
*/
_parseDates = function() {
var _fmt, replaceDatesInObject, that;
_fmt = require('./fluent-date').fmt;
that = this;
// TODO: refactor recursion
replaceDatesInObject = function(obj) {
if (!obj) {
return;
@ -498,11 +464,15 @@ Definition of the FRESHResume class.
});
};
/** 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:
// /^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}$/
}).call(this);
//# sourceMappingURL=fresh-resume.js.map

View File

@ -1,11 +1,12 @@
/**
Definition of the FRESHTheme class.
@module core/fresh-theme
@license MIT. See LICENSE.md for details.
*/
(function() {
/**
Definition of the FRESHTheme class.
@module core/fresh-theme
@license MIT. See LICENSE.md for details.
*/
/* Load and parse theme source files. */
/* Load a single theme file. */
/* Return a more friendly name for certain formats. */
var EXTEND, FRESHTheme, FS, HMSTATUS, PATH, READFILES, _, _load, _loadOne, friendlyName, loadSafeJson, moment, parsePath, pathExists, validator;
FS = require('fs');
@ -30,39 +31,47 @@ Definition of the FRESHTheme class.
READFILES = require('recursive-readdir-sync');
/* A representation of a FRESH theme asset.
@class FRESHTheme
*/
FRESHTheme = (function() {
function FRESHTheme() {
@class FRESHTheme */
FRESHTheme = class FRESHTheme {
constructor() {
this.baseFolder = 'src';
return;
}
/* Open and parse the specified theme. */
FRESHTheme.prototype.open = function(themeFolder) {
open(themeFolder) {
var cached, formatsHash, pathInfo, that, themeFile, themeInfo;
this.folder = themeFolder;
// Open the [theme-name].json file; should have the same name as folder
pathInfo = parsePath(themeFolder);
// Set up a formats hash for the theme
formatsHash = {};
// Load the theme
themeFile = PATH.join(themeFolder, 'theme.json');
themeInfo = loadSafeJson(themeFile);
if (themeInfo.ex) {
throw {
fluenterror: themeInfo.ex.op === 'parse' ? HMSTATUS.parseError : HMSTATUS.readError,
inner: themeInfo.ex.inner
fluenterror: themeInfo.ex.op === 'parse' ? HMSTATUS.parseError : HMSTATUS.readError
};
({
inner: themeInfo.ex.inner
});
}
that = this;
// Move properties from the theme JSON file to the theme object
EXTEND(true, this, themeInfo.json);
// Check for an "inherits" entry in the theme JSON.
if (this.inherits) {
cached = {};
_.each(this.inherits, function(th, key) {
var d, themePath, themesObj;
// First, see if this is one of the predefined FRESH themes. There are
// only a handful of these, but they may change over time, so we need to
// query the official source of truth: the fresh-themes repository, which
// mounts the themes conveniently by name to the module object, and which
// is embedded locally inside the HackMyResume installation.
// TODO: merge this code with
themesObj = require('fresh-themes');
if (_.has(themesObj.themes, th)) {
themePath = PATH.join(parsePath(require.resolve('fresh-themes')).dirname, '/themes/', th);
@ -74,32 +83,26 @@ Definition of the FRESHTheme class.
return formatsHash[key] = cached[th].getFormat(key);
});
}
// Load theme files
formatsHash = _load.call(this, formatsHash);
// Cache
this.formats = formatsHash;
// Set the official theme name
this.name = parsePath(this.folder).name;
return this;
};
}
/* Determine if the theme supports the specified output format. */
FRESHTheme.prototype.hasFormat = function(fmt) {
hasFormat(fmt) {
return _.has(this.formats, fmt);
};
}
/* Determine if the theme supports the specified output format. */
FRESHTheme.prototype.getFormat = function(fmt) {
getFormat(fmt) {
return this.formats[fmt];
};
}
return FRESHTheme;
})();
/* Load and parse theme source files. */
};
_load = function(formatsHash) {
var copyOnly, fmts, jsFiles, major, that, tplFolder;
@ -107,12 +110,19 @@ Definition of the FRESHTheme class.
major = false;
tplFolder = PATH.join(this.folder, this.baseFolder);
copyOnly = ['.ttf', '.otf', '.png', '.jpg', '.jpeg', '.pdf'];
// Iterate over all files in the theme folder, producing an array, fmts,
// containing info for each file. While we're doing that, also build up
// the formatsHash object.
fmts = READFILES(tplFolder).map(function(absPath) {
return _loadOne.call(this, absPath, formatsHash, tplFolder);
}, this);
// Now, get all the CSS files...
this.cssFiles = fmts.filter(function(fmt) {
return fmt && (fmt.ext === 'css');
});
// For each CSS file, get its corresponding HTML file. It's possible that
// a theme can have a CSS file but *no* HTML file, as when a theme author
// creates a pure CSS override of an existing theme.
this.cssFiles.forEach(function(cssf) {
var idx;
idx = _.findIndex(fmts, function(fmt) {
@ -124,6 +134,8 @@ Definition of the FRESHTheme class.
return fmts[idx].cssPath = cssf.path;
} else {
if (that.inherits) {
// Found a CSS file without an HTML file in a theme that inherits
// from another theme. This is the override CSS file.
return that.overrides = {
file: cssf.path,
data: cssf.data
@ -131,6 +143,7 @@ Definition of the FRESHTheme class.
}
}
});
// Now, save all the javascript file paths to a theme property.
jsFiles = fmts.filter(function(fmt) {
return fmt && (fmt.ext === 'js');
});
@ -140,9 +153,6 @@ Definition of the FRESHTheme class.
return formatsHash;
};
/* Load a single theme file. */
_loadOne = function(absPath, formatsHash, tplFolder) {
var absPathSafe, act, defFormats, idx, isPrimary, obj, outFmt, pathInfo, portion, ref, ref1, reg, res;
pathInfo = parsePath(absPath);
@ -153,6 +163,8 @@ Definition of the FRESHTheme class.
outFmt = '';
act = 'copy';
isPrimary = false;
// If this is an "explicit" theme, all files of importance are specified in
// the "transform" section of the theme.json file.
if (this.explicit) {
outFmt = _.find(Object.keys(this.formats), function(fmtKey) {
var fmtVal;
@ -168,6 +180,9 @@ Definition of the FRESHTheme class.
}
}
if (!outFmt) {
// If this file lives in a specific format folder within the theme,
// such as "/latex" or "/html", then that format is the implicit output
// format for all files within the folder
portion = pathInfo.dirname.replace(tplFolder, '');
if (portion && portion.trim()) {
if (portion[1] === '_') {
@ -203,13 +218,16 @@ Definition of the FRESHTheme class.
return form.name === outFmt && pathInfo.extname !== '.css';
});
}
// Make sure we have a valid formatsHash
formatsHash[outFmt] = formatsHash[outFmt] || {
outFormat: outFmt,
files: []
};
// Move symlink descriptions from theme.json to the format
if ((ref = this.formats) != null ? (ref1 = ref[outFmt]) != null ? ref1.symLinks : void 0 : void 0) {
formatsHash[outFmt].symLinks = this.formats[outFmt].symLinks;
}
// Create the file representation object
obj = {
action: act,
primary: isPrimary,
@ -218,16 +236,15 @@ Definition of the FRESHTheme class.
ext: pathInfo.extname.slice(1),
title: friendlyName(outFmt),
pre: outFmt,
// outFormat: outFmt || pathInfo.name,
data: FS.readFileSync(absPath, 'utf8'),
css: null
};
// Add this file to the list of files for this format type.
formatsHash[outFmt].files.push(obj);
return obj;
};
/* Return a more friendly name for certain formats. */
friendlyName = function(val) {
var friendly;
val = (val && val.trim().toLowerCase()) || '';

View File

@ -1,11 +1,16 @@
/**
Definition of the JRSResume class.
@license MIT. See LICENSE.md for details.
@module core/jrs-resume
*/
(function() {
/**
Definition of the JRSResume class.
@license MIT. See LICENSE.md for details.
@module core/jrs-resume
*/
/**
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
the Moment-ified date as a separate property with a prefix of .safe. For ex:
job.startDate is the date as entered by the user. job.safeStartDate is the
parsed Moment.js date that we actually use in processing.
*/
var CONVERTER, FS, JRSResume, MD, PATH, _, _parseDates, extend, moment, validator;
FS = require('fs');
@ -24,145 +29,247 @@ Definition of the JRSResume class.
moment = require('moment');
/**
A JRS resume or CV. JRS resumes are backed by JSON, and each JRSResume object
is an instantiation of that JSON decorated with utility methods.
@class JRSResume
*/
JRSResume = (function() {
/** Reset the sheet to an empty state. */
var clear;
function JRSResume() {}
/** Initialize the the JSResume from string. */
JRSResume.prototype.parse = function(stringData, opts) {
var ref;
this.imp = (ref = this.imp) != null ? ref : {
raw: stringData
};
return this.parseJSON(JSON.parse(stringData), opts);
};
/**
Initialize the JRSResume object from JSON.
Open and parse the specified JRS resume. Merge the JSON object model onto
this Sheet instance with extend() and convert sheet dates to a safe &
consistent format. Then sort each section by startDate descending.
@param rep {Object} The raw JSON representation.
@param opts {Object} Resume loading and parsing options.
{
A JRS resume or CV. JRS resumes are backed by JSON, and each JRSResume object
is an instantiation of that JSON decorated with utility methods.
@class JRSResume
*/
class JRSResume { // extends AbstractResume
/** Initialize the the JSResume from string. */
parse(stringData, opts) {
var ref;
this.imp = (ref = this.imp) != null ? ref : {
raw: stringData
};
return this.parseJSON(JSON.parse(stringData), opts);
}
/**
Initialize the JRSResume object from JSON.
Open and parse the specified JRS resume. Merge the JSON object model onto
this Sheet instance with extend() and convert sheet dates to a safe &
consistent format. Then sort each section by startDate descending.
@param rep {Object} The raw JSON representation.
@param opts {Object} Resume loading and parsing options.
{
date: Perform safe date conversion.
sort: Sort resume items by date.
compute: Prepare computed resume totals.
}
*/
JRSResume.prototype.parseJSON = function(rep, opts) {
var ignoreList, privateList, ref, ref1, scrubbed, scrubber;
opts = opts || {};
if (opts.privatize) {
scrubber = require('../utils/resume-scrubber');
ref = scrubber.scrubResume(rep, opts), scrubbed = ref.scrubbed, ignoreList = ref.ignoreList, privateList = ref.privateList;
}
extend(true, this, opts.privatize ? scrubbed : rep);
if (!((ref1 = this.imp) != null ? ref1.processed : void 0)) {
*/
parseJSON(rep, opts) {
var ignoreList, privateList, ref, scrubbed, scrubber;
opts = opts || {};
if (opts.imp === void 0 || opts.imp) {
this.imp = this.imp || {};
this.imp.title = (opts.title || this.imp.title) || this.basics.name;
if (!this.imp.raw) {
this.imp.raw = JSON.stringify(rep);
}
if (opts.privatize) {
scrubber = require('../utils/resume-scrubber');
// Ignore any element with the 'ignore: true' or 'private: true' designator.
({scrubbed, ignoreList, privateList} = scrubber.scrubResume(rep, opts));
}
this.imp.processed = true;
// Extend resume properties onto ourself.
extend(true, this, opts.privatize ? scrubbed : rep);
if (!((ref = this.imp) != null ? ref.processed : void 0)) {
// Set up metadata TODO: Clean up metadata on the object model.
opts = opts || {};
if (opts.imp === void 0 || opts.imp) {
this.imp = this.imp || {};
this.imp.title = (opts.title || this.imp.title) || this.basics.name;
if (!this.imp.raw) {
this.imp.raw = JSON.stringify(rep);
}
}
this.imp.processed = true;
}
// Parse dates, sort dates, and calculate computed values
(opts.date === void 0 || opts.date) && _parseDates.call(this);
(opts.sort === void 0 || opts.sort) && this.sort();
if (opts.compute === void 0 || opts.compute) {
this.basics.computed = {
numYears: this.duration(),
keywords: this.keywords()
};
}
return this;
}
(opts.date === void 0 || opts.date) && _parseDates.call(this);
(opts.sort === void 0 || opts.sort) && this.sort();
if (opts.compute === void 0 || opts.compute) {
this.basics.computed = {
numYears: this.duration(),
keywords: this.keywords()
};
}
return this;
};
/** Save the sheet to disk (for environments that have disk access). */
JRSResume.prototype.save = function(filename) {
this.imp.file = filename || this.imp.file;
FS.writeFileSync(this.imp.file, this.stringify(this), 'utf8');
return this;
};
/** Save the sheet to disk in a specific format, either FRESH or JRS. */
JRSResume.prototype.saveAs = function(filename, format) {
var newRep, stringRep;
if (format === 'JRS') {
/** Save the sheet to disk (for environments that have disk access). */
save(filename) {
this.imp.file = filename || this.imp.file;
FS.writeFileSync(this.imp.file, this.stringify(), 'utf8');
} else {
newRep = CONVERTER.toFRESH(this);
stringRep = CONVERTER.toSTRING(newRep);
FS.writeFileSync(filename, stringRep, 'utf8');
FS.writeFileSync(this.imp.file, this.stringify(this), 'utf8');
return this;
}
return this;
};
/** Save the sheet to disk in a specific format, either FRESH or JRS. */
saveAs(filename, format) {
var newRep, stringRep;
if (format === 'JRS') {
this.imp.file = filename || this.imp.file;
FS.writeFileSync(this.imp.file, this.stringify(), 'utf8');
} else {
newRep = CONVERTER.toFRESH(this);
stringRep = CONVERTER.toSTRING(newRep);
FS.writeFileSync(filename, stringRep, 'utf8');
}
return this;
}
/** Return the resume format. */
/** Return the resume format. */
format() {
return 'JRS';
}
JRSResume.prototype.format = function() {
return 'JRS';
};
stringify() {
return JRSResume.stringify(this);
}
JRSResume.prototype.stringify = function() {
return JRSResume.stringify(this);
};
/** Return a unique list of all keywords across all skills. */
keywords() {
var flatSkills;
flatSkills = [];
if (this.skills && this.skills.length) {
this.skills.forEach(function(s) {
return flatSkills = _.union(flatSkills, s.keywords);
});
}
return flatSkills;
}
/**
Return internal metadata. Create if it doesn't exist.
JSON Resume v0.0.0 doesn't allow additional properties at the root level,
so tuck this into the .basic sub-object.
*/
i() {
var ref;
return this.imp = (ref = this.imp) != null ? ref : {};
}
/** Return a unique list of all keywords across all skills. */
/** Add work experience to the sheet. */
add(moniker) {
var defSheet, newObject;
defSheet = JRSResume.default();
newObject = $.extend(true, {}, defSheet[moniker][0]);
this[moniker] = this[moniker] || [];
this[moniker].push(newObject);
return newObject;
}
JRSResume.prototype.keywords = function() {
var flatSkills;
flatSkills = [];
if (this.skills && this.skills.length) {
this.skills.forEach(function(s) {
return flatSkills = _.union(flatSkills, s.keywords);
/** Determine if the sheet includes a specific social profile (eg, GitHub). */
hasProfile(socialNetwork) {
socialNetwork = socialNetwork.trim().toLowerCase();
return this.basics.profiles && _.some(this.basics.profiles, function(p) {
return p.network.trim().toLowerCase() === socialNetwork;
});
}
return flatSkills;
/** Determine if the sheet includes a specific skill. */
hasSkill(skill) {
skill = skill.trim().toLowerCase();
return this.skills && _.some(this.skills, function(sk) {
return sk.keywords && _.some(sk.keywords, function(kw) {
return kw.trim().toLowerCase() === skill;
});
});
}
/** Validate the sheet against the JSON Resume schema. */
isValid() { // TODO: ↓ fix this path ↓
var ret, schema, schemaObj, temp, validate;
schema = FS.readFileSync(PATH.join(__dirname, 'resume.json'), 'utf8');
schemaObj = JSON.parse(schema);
validator = require('is-my-json-valid');
validate = validator(schemaObj, { // Note [1]
formats: {
date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/
}
});
temp = this.imp;
delete this.imp;
ret = validate(this);
this.imp = temp;
if (!ret) {
this.imp = this.imp || {};
this.imp.validationErrors = validate.errors;
}
return ret;
}
duration(unit) {
var inspector;
inspector = require('../inspectors/duration-inspector');
return inspector.run(this, '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().
*/
sort() {
var byDateDesc;
byDateDesc = function(a, b) {
if (a.safeStartDate.isBefore(b.safeStartDate)) {
return 1;
} else {
return (a.safeStartDate.isAfter(b.safeStartDate) && -1) || 0;
}
};
this.work && this.work.sort(byDateDesc);
this.education && this.education.sort(byDateDesc);
this.volunteer && this.volunteer.sort(byDateDesc);
this.awards && this.awards.sort(function(a, b) {
if (a.safeDate.isBefore(b.safeDate)) {
return 1;
} else {
return (a.safeDate.isAfter(b.safeDate) && -1) || 0;
}
});
return this.publications && this.publications.sort(function(a, b) {
if (a.safeReleaseDate.isBefore(b.safeReleaseDate)) {
return 1;
} else {
return (a.safeReleaseDate.isAfter(b.safeReleaseDate) && -1) || 0;
}
});
}
dupe() {
var rnew;
rnew = new JRSResume();
rnew.parse(this.stringify(), {});
return rnew;
}
/**
Create a copy of this resume in which all fields have been interpreted as
Markdown.
*/
harden() {
var HD, HDIN, ret, transformer;
ret = this.dupe();
HD = function(txt) {
return '@@@@~' + txt + '~@@@@';
};
HDIN = function(txt) {
//return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
return HD(txt);
};
transformer = require('../utils/string-transformer');
return transformer(ret, ['skills', 'url', 'website', 'startDate', 'endDate', 'releaseDate', 'date', 'phone', 'email', 'address', 'postalCode', 'city', 'country', 'region', 'safeStartDate', 'safeEndDate'], function(key, val) {
return HD(val);
});
}
};
/**
Return internal metadata. Create if it doesn't exist.
JSON Resume v0.0.0 doesn't allow additional properties at the root level,
so tuck this into the .basic sub-object.
*/
JRSResume.prototype.i = function() {
var ref;
return this.imp = (ref = this.imp) != null ? ref : {};
};
/** Reset the sheet to an empty state. */
clear = function(clearMeta) {
clearMeta = ((clearMeta === void 0) && true) || clearMeta;
if (clearMeta) {
delete this.imp;
}
delete this.basics.computed;
delete this.basics.computed; // Don't use Object.keys() here
delete this.work;
delete this.volunteer;
delete this.education;
@ -173,152 +280,22 @@ Definition of the JRSResume class.
return delete this.basics.profiles;
};
/** Add work experience to the sheet. */
JRSResume.prototype.add = function(moniker) {
var defSheet, newObject;
defSheet = JRSResume["default"]();
newObject = $.extend(true, {}, defSheet[moniker][0]);
this[moniker] = this[moniker] || [];
this[moniker].push(newObject);
return newObject;
};
/** Determine if the sheet includes a specific social profile (eg, GitHub). */
JRSResume.prototype.hasProfile = function(socialNetwork) {
socialNetwork = socialNetwork.trim().toLowerCase();
return this.basics.profiles && _.some(this.basics.profiles, function(p) {
return p.network.trim().toLowerCase() === socialNetwork;
});
};
/** Determine if the sheet includes a specific skill. */
JRSResume.prototype.hasSkill = function(skill) {
skill = skill.trim().toLowerCase();
return this.skills && _.some(this.skills, function(sk) {
return sk.keywords && _.some(sk.keywords, function(kw) {
return kw.trim().toLowerCase() === skill;
});
});
};
/** Validate the sheet against the JSON Resume schema. */
JRSResume.prototype.isValid = function() {
var ret, schema, schemaObj, temp, validate;
schema = FS.readFileSync(PATH.join(__dirname, 'resume.json'), 'utf8');
schemaObj = JSON.parse(schema);
validator = require('is-my-json-valid');
validate = validator(schemaObj, {
formats: {
date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/
}
});
temp = this.imp;
delete this.imp;
ret = validate(this);
this.imp = temp;
if (!ret) {
this.imp = this.imp || {};
this.imp.validationErrors = validate.errors;
}
return ret;
};
JRSResume.prototype.duration = function(unit) {
var inspector;
inspector = require('../inspectors/duration-inspector');
return inspector.run(this, '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().
*/
JRSResume.prototype.sort = function() {
var byDateDesc;
byDateDesc = function(a, b) {
if (a.safeStartDate.isBefore(b.safeStartDate)) {
return 1;
} else {
return (a.safeStartDate.isAfter(b.safeStartDate) && -1) || 0;
}
};
this.work && this.work.sort(byDateDesc);
this.education && this.education.sort(byDateDesc);
this.volunteer && this.volunteer.sort(byDateDesc);
this.awards && this.awards.sort(function(a, b) {
if (a.safeDate.isBefore(b.safeDate)) {
return 1;
} else {
return (a.safeDate.isAfter(b.safeDate) && -1) || 0;
}
});
return this.publications && this.publications.sort(function(a, b) {
if (a.safeReleaseDate.isBefore(b.safeReleaseDate)) {
return 1;
} else {
return (a.safeReleaseDate.isAfter(b.safeReleaseDate) && -1) || 0;
}
});
};
JRSResume.prototype.dupe = function() {
var rnew;
rnew = new JRSResume();
rnew.parse(this.stringify(), {});
return rnew;
};
/**
Create a copy of this resume in which all fields have been interpreted as
Markdown.
*/
JRSResume.prototype.harden = function() {
var HD, HDIN, ret, transformer;
ret = this.dupe();
HD = function(txt) {
return '@@@@~' + txt + '~@@@@';
};
HDIN = function(txt) {
return HD(txt);
};
transformer = require('../utils/string-transformer');
return transformer(ret, ['skills', 'url', 'website', 'startDate', 'endDate', 'releaseDate', 'date', 'phone', 'email', 'address', 'postalCode', 'city', 'country', 'region', 'safeStartDate', 'safeEndDate'], function(key, val) {
return HD(val);
});
};
return JRSResume;
})();
}).call(this);
/** Get the default (empty) sheet. */
JRSResume["default"] = function() {
JRSResume.default = function() {
return new JRSResume().parseJSON(require('fresh-resume-starter').jrs);
};
/**
Convert this object to a JSON string, sanitizing meta-properties along the
way. Don't override .toString().
*/
*/
JRSResume.stringify = function(obj) {
var replacer;
replacer = function(key, value) {
replacer = function(key, value) { // Exclude these keys from stringification
var temp;
temp = _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index', 'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result', 'isModified', 'htmlPreview', 'display_progress_bar'], function(val) {
return key.trim() === val;
@ -332,15 +309,6 @@ Definition of the JRSResume class.
return 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
the Moment-ified date as a separate property with a prefix of .safe. For ex:
job.startDate is the date as entered by the user. job.safeStartDate is the
parsed Moment.js date that we actually use in processing.
*/
_parseDates = function() {
var _fmt;
_fmt = require('./fluent-date').fmt;
@ -364,11 +332,9 @@ Definition of the JRSResume class.
});
};
/**
Export the JRSResume function/ctor.
*/
*/
module.exports = JRSResume;
}).call(this);

View File

@ -1,11 +1,9 @@
/**
Definition of the JRSTheme class.
@module core/jrs-theme
@license MIT. See LICENSE.MD for details.
*/
(function() {
/**
Definition of the JRSTheme class.
@module core/jrs-theme
@license MIT. See LICENSE.MD for details.
*/
var JRSTheme, PATH, _, errors, parsePath, pathExists;
_ = require('underscore');
@ -18,32 +16,30 @@ Definition of the JRSTheme class.
errors = require('./status-codes');
/**
The JRSTheme class is a representation of a JSON Resume theme asset.
@class JRSTheme
*/
JRSTheme = (function() {
function JRSTheme() {}
*/
JRSTheme = class JRSTheme {
/**
Open and parse the specified JRS theme.
@method open
*/
JRSTheme.prototype.open = function(thFolder) {
*/
open(thFolder) {
var pathInfo, pkgJsonPath, thApi, thPkg;
this.folder = thFolder;
pathInfo = parsePath(thFolder);
// Open and parse the theme's package.json file
pkgJsonPath = PATH.join(thFolder, 'package.json');
if (pathExists(pkgJsonPath)) {
thApi = require(thFolder);
thPkg = require(pkgJsonPath);
thApi = require(thFolder); // Requiring the folder yields whatever the package.json's "main" is set to
thPkg = require(pkgJsonPath); // Get the package.json as JSON
this.name = thPkg.name;
this.render = (thApi && thApi.render) || void 0;
this.engine = 'jrs';
// Create theme formats (HTML and PDF). Just add the bare minimum mix of
// properties necessary to allow JSON Resume themes to share a rendering
// path with FRESH themes.
this.formats = {
html: {
outFormat: 'html',
@ -76,31 +72,25 @@ Definition of the JRSTheme class.
};
}
return this;
};
}
/**
Determine if the theme supports the output format.
@method hasFormat
*/
JRSTheme.prototype.hasFormat = function(fmt) {
*/
hasFormat(fmt) {
return _.has(this.formats, fmt);
};
}
/**
Return the requested output format.
@method getFormat
*/
JRSTheme.prototype.getFormat = function(fmt) {
*/
getFormat(fmt) {
return this.formats[fmt];
};
}
return JRSTheme;
})();
};
module.exports = JRSTheme;

View File

@ -1,11 +1,13 @@
/**
Definition of the ResumeFactory class.
@license MIT. See LICENSE.md for details.
@module core/resume-factory
*/
(function() {
/**
Definition of the ResumeFactory class.
@license MIT. See LICENSE.md for details.
@module core/resume-factory
*/
/**
A simple factory class for FRESH and JSON Resumes.
@class ResumeFactory
*/
var FS, HME, HMS, ResumeConverter, ResumeFactory, SyntaxErrorEx, _, _parse, chalk, resumeDetect;
FS = require('fs');
@ -26,20 +28,13 @@ Definition of the ResumeFactory class.
require('string.prototype.startswith');
/**
A simple factory class for FRESH and JSON Resumes.
@class ResumeFactory
*/
ResumeFactory = module.exports = {
/**
Load one or more resumes from disk.
@param {Object} opts An options object with settings for the factory as well
as passthrough settings for FRESHResume or JRSResume. Structure:
{
format: 'FRESH', // Format to open as. ('FRESH', 'JRS', null)
objectify: true, // FRESH/JRSResume or raw JSON?
@ -47,31 +42,38 @@ Definition of the ResumeFactory class.
sort: false
}
}
*/
*/
load: function(sources, opts, emitter) {
return sources.map(function(src) {
return this.loadOne(src, opts, emitter);
}, this);
},
/** Load a single resume from disk. */
/** Load a single resume from disk. */
loadOne: function(src, opts, emitter) {
var ResumeClass, info, json, orgFormat, reqLib, rez, toFormat;
toFormat = opts.format;
toFormat = opts.format; // Can be null
// Get the destination format. Can be 'fresh', 'jrs', or null/undefined.
toFormat && (toFormat = toFormat.toLowerCase().trim());
// Load and parse the resume JSON
info = _parse(src, opts, emitter);
if (info.fluenterror) {
return info;
}
// Determine the resume format: FRESH or JRS
json = info.json;
orgFormat = resumeDetect(json);
if (orgFormat === 'unk') {
info.fluenterror = HMS.unknownSchema;
return info;
}
// Convert between formats if necessary
if (toFormat && (orgFormat !== toFormat)) {
json = ResumeConverter['to' + toFormat.toUpperCase()](json);
}
// Objectify the resume, that is, convert it from JSON to a FRESHResume
// or JRSResume object.
rez = null;
if (opts.objectify) {
reqLib = '../core/' + (toFormat || orgFormat) + '-resume';
@ -88,9 +90,10 @@ Definition of the ResumeFactory class.
};
_parse = function(fileName, opts, eve) {
var orgFormat, rawData, ret;
var err, orgFormat, rawData, ret;
rawData = null;
try {
// Read the file
eve && eve.stat(HME.beforeRead, {
file: fileName
});
@ -112,10 +115,12 @@ Definition of the ResumeFactory class.
fmt: orgFormat
});
return ret;
} catch (_error) {
} catch (error) {
err = error;
return {
// Can be ENOENT, EACCES, SyntaxError, etc.
fluenterror: rawData ? HMS.parseError : HMS.readError,
inner: _error,
inner: err,
raw: rawData,
file: fileName
};

View File

@ -1,11 +1,9 @@
/**
Status codes for HackMyResume.
@module core/status-codes
@license MIT. See LICENSE.MD for details.
*/
(function() {
/**
Status codes for HackMyResume.
@module core/status-codes
@license MIT. See LICENSE.MD for details.
*/
module.exports = {
success: 0,
themeNotFound: 1,