From 0aa9bc29372853eabebf5dd5ef5a47c4e3e32b75 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Thu, 19 Nov 2015 10:39:14 -0500 Subject: [PATCH] Rename Sheet/FreshSheet to JRSResume/FRESHResume. --- src/core/{fresh-sheet.js => fresh-resume.js} | 45 ++++++++++---------- src/core/{sheet.js => jrs-resume.js} | 44 +++++++++---------- src/fluentcmd.js | 4 +- src/fluentlib.js | 4 +- tests/test-fresh-sheet.js | 6 +-- tests/test-jrs-sheet.js | 6 +-- 6 files changed, 55 insertions(+), 54 deletions(-) rename src/core/{fresh-sheet.js => fresh-resume.js} (86%) rename src/core/{sheet.js => jrs-resume.js} (87%) diff --git a/src/core/fresh-sheet.js b/src/core/fresh-resume.js similarity index 86% rename from src/core/fresh-sheet.js rename to src/core/fresh-resume.js index ac80135..137b1e4 100644 --- a/src/core/fresh-sheet.js +++ b/src/core/fresh-resume.js @@ -1,5 +1,5 @@ /** -FRESH character/resume sheet representation. +Definition of the FRESHResume class. @license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk */ @@ -15,18 +15,18 @@ FRESH character/resume sheet representation. /** A FRESH-style resume in JSON or YAML. - @class Sheet + @class FreshResume */ - function FreshSheet() { + function FreshResume() { } /** - Open and parse the specified JSON resume sheet. Merge the JSON object model + Open and parse the specified FRESH resume sheet. 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. */ - FreshSheet.prototype.open = function( file, title ) { + FreshResume.prototype.open = function( file, title ) { this.meta = { fileName: file }; this.meta.raw = FS.readFileSync( file, 'utf8' ); return this.parse( this.meta.raw, title ); @@ -35,7 +35,7 @@ FRESH character/resume sheet representation. /** Save the sheet to disk (for environments that have disk access). */ - FreshSheet.prototype.save = function( filename ) { + FreshResume.prototype.save = function( filename ) { this.meta.fileName = filename || this.meta.fileName; FS.writeFileSync( this.meta.fileName, this.stringify(), 'utf8' ); return this; @@ -45,11 +45,10 @@ FRESH character/resume sheet representation. Convert this object to a JSON string, sanitizing meta-properties along the way. Don't override .toString(). */ - FreshSheet.prototype.stringify = function() { + FreshResume.prototype.stringify = function() { function replacer( key,value ) { // Exclude these keys from stringification return _.some(['meta', 'warnings', 'computed', 'filt', 'ctrl', 'index', - 'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result', - 'isModified', 'htmlPreview', 'display_progress_bar'], + 'safe', 'result', 'isModified', 'htmlPreview', 'display_progress_bar'], function( val ) { return key.trim() === val; } ) ? undefined : value; } @@ -61,7 +60,7 @@ FRESH character/resume sheet representation. onto this Sheet instance with extend() and convert sheet dates to a safe & consistent format. Then sort each section by startDate descending. */ - FreshSheet.prototype.parse = function( stringData, opts ) { + FreshResume.prototype.parse = function( stringData, opts ) { // Parse the incoming JSON representation var rep = JSON.parse( stringData ); @@ -91,7 +90,7 @@ FRESH character/resume sheet representation. /** Return a unique list of all keywords across all skills. */ - FreshSheet.prototype.keywords = function() { + FreshResume.prototype.keywords = function() { var flatSkills = []; this.skills && this.skills.length && (flatSkills = this.skills.map(function(sk) { return sk.name; })); @@ -101,7 +100,7 @@ FRESH character/resume sheet representation. /** Update the sheet's raw data. TODO: remove/refactor */ - FreshSheet.prototype.updateData = function( str ) { + FreshResume.prototype.updateData = function( str ) { this.clear( false ); this.parse( str ) return this; @@ -110,7 +109,7 @@ FRESH character/resume sheet representation. /** Reset the sheet to an empty state. */ - FreshSheet.prototype.clear = function( clearMeta ) { + FreshResume.prototype.clear = function( clearMeta ) { clearMeta = ((clearMeta === undefined) && true) || clearMeta; clearMeta && (delete this.meta); delete this.computed; // Don't use Object.keys() here @@ -127,15 +126,15 @@ FRESH character/resume sheet representation. /** Get the default (empty) sheet. */ - FreshSheet.default = function() { - return new FreshSheet().open( PATH.join( __dirname, 'empty.json'), 'Empty' ); + FreshResume.default = function() { + return new FreshResume().open( PATH.join( __dirname, 'empty.json'), 'Empty' ); } /** Add work experience to the sheet. */ - FreshSheet.prototype.add = function( moniker ) { - var defSheet = FreshSheet.default(); + FreshResume.prototype.add = function( moniker ) { + var defSheet = FreshResume.default(); var newObject = $.extend( true, {}, defSheet[ moniker ][0] ); this[ moniker ] = this[ moniker ] || []; this[ moniker ].push( newObject ); @@ -145,7 +144,7 @@ FRESH character/resume sheet representation. /** Determine if the sheet includes a specific social profile (eg, GitHub). */ - FreshSheet.prototype.hasProfile = function( socialNetwork ) { + FreshResume.prototype.hasProfile = function( socialNetwork ) { socialNetwork = socialNetwork.trim().toLowerCase(); return this.social && _.some( this.social, function(p) { return p.network.trim().toLowerCase() === socialNetwork; @@ -155,7 +154,7 @@ FRESH character/resume sheet representation. /** Determine if the sheet includes a specific skill. */ - FreshSheet.prototype.hasSkill = function( skill ) { + FreshResume.prototype.hasSkill = function( skill ) { skill = skill.trim().toLowerCase(); return this.skills && _.some( this.skills, function(sk) { return sk.keywords && _.some( sk.keywords, function(kw) { @@ -167,7 +166,7 @@ FRESH character/resume sheet representation. /** Validate the sheet against the FRESH Resume schema. */ - FreshSheet.prototype.isValid = function( info ) { + FreshResume.prototype.isValid = function( info ) { var schemaObj = require('FRESCA'); //var schemaObj = JSON.parse( schema ); var validator = require('is-my-json-valid') @@ -188,7 +187,7 @@ FRESH character/resume sheet representation. *latest end date of all jobs in the work history*. This last condition is for sheets that have overlapping jobs. */ - FreshSheet.prototype.duration = function() { + FreshResume.prototype.duration = function() { if( this.employment.history && this.employment.history.length ) { var careerStart = this.employment.history[ this.employment.history.length - 1].safe.start; if ((typeof careerStart === 'string' || careerStart instanceof String) && @@ -206,7 +205,7 @@ FRESH character/resume sheet representation. Sort dated things on the sheet by start date descending. Assumes that dates on the sheet have been processed with _parseDates(). */ - FreshSheet.prototype.sort = function( ) { + FreshResume.prototype.sort = function( ) { this.employment.history && this.employment.history.sort( byDateDesc ); this.education.history && this.education.history.sort( byDateDesc ); @@ -270,6 +269,6 @@ FRESH character/resume sheet representation. /** Export the Sheet function/ctor. */ - module.exports = FreshSheet; + module.exports = FreshResume; }()); diff --git a/src/core/sheet.js b/src/core/jrs-resume.js similarity index 87% rename from src/core/sheet.js rename to src/core/jrs-resume.js index 6cd1b7f..55e8e29 100644 --- a/src/core/sheet.js +++ b/src/core/jrs-resume.js @@ -1,5 +1,5 @@ /** -Abstract character/resume sheet representation. +Definition of the JRSResume class. @license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk */ @@ -13,14 +13,14 @@ Abstract character/resume sheet representation. , moment = require('moment'); /** - The Sheet class represent a specific JSON character sheet. When Sheet.open + The JRSResume class represent a specific JSON character sheet. When Sheet.open is called, we merge the loaded JSON sheet properties onto the Sheet instance via extend(), so a full-grown sheet object will have all of the methods here, plus a complement of JSON properties from the backing JSON file. That allows us to treat Sheet objects interchangeably with the loaded JSON model. - @class Sheet + @class JRSResume */ - function Sheet() { + function JRSResume() { } @@ -29,7 +29,7 @@ Abstract character/resume sheet representation. onto this Sheet instance with extend() and convert sheet dates to a safe & consistent format. Then sort each section by startDate descending. */ - Sheet.prototype.open = function( file, title ) { + JRSResume.prototype.open = function( file, title ) { this.meta = { fileName: file }; this.meta.raw = FS.readFileSync( file, 'utf8' ); return this.parse( this.meta.raw, title ); @@ -38,7 +38,7 @@ Abstract character/resume sheet representation. /** Save the sheet to disk (for environments that have disk access). */ - Sheet.prototype.save = function( filename ) { + JRSResume.prototype.save = function( filename ) { this.meta.fileName = filename || this.meta.fileName; FS.writeFileSync( this.meta.fileName, this.stringify(), 'utf8' ); return this; @@ -48,7 +48,7 @@ Abstract character/resume sheet representation. Convert this object to a JSON string, sanitizing meta-properties along the way. Don't override .toString(). */ - Sheet.prototype.stringify = function() { + JRSResume.prototype.stringify = function() { function replacer( key,value ) { // Exclude these keys from stringification return _.some(['meta', 'warnings', 'computed', 'filt', 'ctrl', 'index', 'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result', @@ -64,7 +64,7 @@ Abstract character/resume sheet representation. onto this Sheet instance with extend() and convert sheet dates to a safe & consistent format. Then sort each section by startDate descending. */ - Sheet.prototype.parse = function( stringData, opts ) { + JRSResume.prototype.parse = function( stringData, opts ) { opts = opts || { }; var rep = JSON.parse( stringData ); extend( true, this, rep ); @@ -86,7 +86,7 @@ Abstract character/resume sheet representation. /** Return a unique list of all keywords across all skills. */ - Sheet.prototype.keywords = function() { + JRSResume.prototype.keywords = function() { var flatSkills = []; if( this.skills && this.skills.length ) { this.skills.forEach( function( s ) { @@ -99,7 +99,7 @@ Abstract character/resume sheet representation. /** Update the sheet's raw data. TODO: remove/refactor */ - Sheet.prototype.updateData = function( str ) { + JRSResume.prototype.updateData = function( str ) { this.clear( false ); this.parse( str ) return this; @@ -108,7 +108,7 @@ Abstract character/resume sheet representation. /** Reset the sheet to an empty state. */ - Sheet.prototype.clear = function( clearMeta ) { + JRSResume.prototype.clear = function( clearMeta ) { clearMeta = ((clearMeta === undefined) && true) || clearMeta; clearMeta && (delete this.meta); delete this.computed; // Don't use Object.keys() here @@ -125,15 +125,15 @@ Abstract character/resume sheet representation. /** Get the default (empty) sheet. */ - Sheet.default = function() { - return new Sheet().open( PATH.join( __dirname, 'empty.json'), 'Empty' ); + JRSResume.default = function() { + return new JRSResume().open( PATH.join( __dirname, 'empty.json'), 'Empty' ); } /** Add work experience to the sheet. */ - Sheet.prototype.add = function( moniker ) { - var defSheet = Sheet.default(); + JRSResume.prototype.add = function( moniker ) { + var defSheet = JRSResume.default(); var newObject = $.extend( true, {}, defSheet[ moniker ][0] ); this[ moniker ] = this[ moniker ] || []; this[ moniker ].push( newObject ); @@ -143,7 +143,7 @@ Abstract character/resume sheet representation. /** Determine if the sheet includes a specific social profile (eg, GitHub). */ - Sheet.prototype.hasProfile = function( socialNetwork ) { + 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; @@ -153,7 +153,7 @@ Abstract character/resume sheet representation. /** Determine if the sheet includes a specific skill. */ - Sheet.prototype.hasSkill = function( 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) { @@ -165,7 +165,7 @@ Abstract character/resume sheet representation. /** Validate the sheet against the JSON Resume schema. */ - Sheet.prototype.isValid = function( ) { // TODO: ↓ fix this path ↓ + JRSResume.prototype.isValid = function( ) { // TODO: ↓ fix this path ↓ var schema = FS.readFileSync( PATH.join( __dirname, 'resume.json' ), 'utf8' ); var schemaObj = JSON.parse( schema ); var validator = require('is-my-json-valid') @@ -181,7 +181,7 @@ Abstract character/resume sheet representation. *latest end date of all jobs in the work history*. This last condition is for sheets that have overlapping jobs. */ - Sheet.prototype.duration = function() { + JRSResume.prototype.duration = function() { if( this.work && this.work.length ) { var careerStart = this.work[ this.work.length - 1].safeStartDate; if ((typeof careerStart === 'string' || careerStart instanceof String) && @@ -199,7 +199,7 @@ Abstract character/resume sheet representation. Sort dated things on the sheet by start date descending. Assumes that dates on the sheet have been processed with _parseDates(). */ - Sheet.prototype.sort = function( ) { + JRSResume.prototype.sort = function( ) { this.work && this.work.sort( byDateDesc ); this.education && this.education.sort( byDateDesc ); @@ -253,8 +253,8 @@ Abstract character/resume sheet representation. } /** - Export the Sheet function/ctor. + Export the JRSResume function/ctor. */ - module.exports = Sheet; + module.exports = JRSResume; }()); diff --git a/src/fluentcmd.js b/src/fluentcmd.js index 29f7455..ebbfded 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -37,7 +37,7 @@ module.exports = function () { if(!src || !src.length) { throw { fluenterror: 3 }; } var sheets = src.map( function( res ) { _log( 'Reading JSON resume: ' + res ); - return (new FLUENT.Sheet()).open( res ); + return (new FLUENT.FRESHResume()).open( res ); }); // Merge input resumes... @@ -139,7 +139,7 @@ module.exports = function () { if( !src || !src.length ) { throw { fluenterror: 3 }; } var isValid = true; var sheets = src.map( function( res ) { - var sheet = (new FLUENT.Sheet()).open( res ); + var sheet = (new FLUENT.FRESHResume()).open( res ); var valid = sheet.isValid(); _log( 'Validating JSON resume: ' + res + (valid ? ' (VALID)' : ' (INVALID)')); diff --git a/src/fluentlib.js b/src/fluentlib.js index 226b693..26e23b7 100644 --- a/src/fluentlib.js +++ b/src/fluentlib.js @@ -4,7 +4,9 @@ External API surface for FluentCV:CLI. */ module.exports = { - Sheet: require('./core/fresh-sheet'), + Sheet: require('./core/fresh-resume'), + FRESHResume: require('./core/fresh-resume'), + JRSResume: require('./core/jrs-resume'), Theme: require('./core/theme'), FluentDate: require('./core/fluent-date'), HtmlGenerator: require('./gen/html-generator'), diff --git a/tests/test-fresh-sheet.js b/tests/test-fresh-sheet.js index 4df7db7..3492f33 100644 --- a/tests/test-fresh-sheet.js +++ b/tests/test-fresh-sheet.js @@ -4,7 +4,7 @@ var chai = require('chai') , should = chai.should() , path = require('path') , _ = require('underscore') - , FreshSheet = require('../src/core/fresh-sheet') + , FRESHResume = require('../src/core/fresh-resume') , validator = require('is-my-json-valid'); chai.config.includeStack = false; @@ -15,7 +15,7 @@ describe('fullstack.json (FRESH)', function () { it('should open without throwing an exception', function () { function tryOpen() { - _sheet = new FreshSheet().open( 'tests/exemplars/fresh-exemplar.json' ); + _sheet = new FRESHResume().open( 'tests/exemplars/fresh-exemplar.json' ); } tryOpen.should.not.Throw(); }); @@ -45,7 +45,7 @@ describe('fullstack.json (FRESH)', function () { }); it('should not be modified after saving', function() { - var savedSheet = new FreshSheet().open( 'tests/sandbox/fullstack.json' ); + var savedSheet = new FRESHResume().open( 'tests/sandbox/fullstack.json' ); _sheet.stringify().should.equal( savedSheet.stringify() ) }); diff --git a/tests/test-jrs-sheet.js b/tests/test-jrs-sheet.js index aa40c95..5fccb35 100644 --- a/tests/test-jrs-sheet.js +++ b/tests/test-jrs-sheet.js @@ -4,7 +4,7 @@ var chai = require('chai') , should = chai.should() , path = require('path') , _ = require('underscore') - , Sheet = require('../src/core/sheet') + , JRSResume = require('../src/core/jrs-resume') , validator = require('is-my-json-valid'); chai.config.includeStack = false; @@ -15,7 +15,7 @@ describe('fullstack.json (JRS)', function () { it('should open without throwing an exception', function () { function tryOpen() { - _sheet = new Sheet().open( 'node_modules/resample/fullstack/in/resume.json' ); + _sheet = new JRSResume().open( 'node_modules/resample/fullstack/in/resume.json' ); } tryOpen.should.not.Throw(); }); @@ -44,7 +44,7 @@ describe('fullstack.json (JRS)', function () { }); it('should not be modified after saving', function() { - var savedSheet = new Sheet().open( 'tests/sandbox/fullstack.json' ); + var savedSheet = new JRSResume().open( 'tests/sandbox/fullstack.json' ); _sheet.stringify().should.equal( savedSheet.stringify() ) });