1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-05 09:56:22 +00:00

Introduce JRSTheme class.

Start splitting out logic into dedicated abstractions for both FRESH and
JSON Resume themes given the different structure and use cases of each.
This commit is contained in:
hacksalot 2015-12-30 12:08:46 -05:00
parent 37e75acd86
commit b21fd93d66
2 changed files with 73 additions and 1 deletions

70
src/core/jrs-theme.js Normal file
View File

@ -0,0 +1,70 @@
/**
Definition of the JRSTheme class.
@module jrs-theme.js
@license MIT. See LICENSE.MD for details.
*/
(function() {
var _ = require('underscore')
, PATH = require('path')
, parsePath = require('parse-filepath')
, pathExists = require('path-exists').sync;
/**
The JRSTheme class is a representation of a JSON Resume theme asset.
@class JRSTheme
*/
function JRSTheme() {
}
/**
Open and parse the specified theme.
*/
JRSTheme.prototype.open = function( themeFolder ) {
this.folder = themeFolder;
// Open the [theme-name].json file; should have the same name as folder
var pathInfo = parsePath( themeFolder );
// Open and parse the theme's package.json file.
var packageJsonPath = PATH.join(themeFolder, 'package.json');
if( pathExists( packageJsonPath ) ) {
var themePack = require( themeFolder );
var themePkgJson = require( packageJsonPath );
this.name = themePkgJson.name;
this.render = (themePack && themePack.render) || undefined;
this.formats = {
html: { title: 'html', outFormat: 'html', ext: 'html' }
};
}
else {
throw { fluenterror: 10 };
}
return this;
};
/**
Determine if the theme supports the specified output format.
*/
JRSTheme.prototype.hasFormat = function( fmt ) {
return _.has( this.formats, fmt );
};
/**
Determine if the theme supports the specified output format.
*/
JRSTheme.prototype.getFormat = function( fmt ) {
return this.formats[ fmt ];
};
module.exports = JRSTheme;
}());

View File

@ -1,6 +1,7 @@
/**
Status codes for HackMyResume.
@module status-codes.js
@license MIT. See LICENSE.MD for details.
*/
(function(){
@ -15,7 +16,8 @@ Status codes for HackMyResume.
resumeNotFoundAlt: 6,
inputOutputParity: 7,
createNameMissing: 8,
wkhtmltopdf: 9
wkhtmltopdf: 9,
missingPackageJSON: 10
};
}());