mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 00:10:15 +00:00
Introduce "Sheet" class.
Start formalizing some of the key domain nouns, starting with the concept of the "sheet" or "character sheet".
This commit is contained in:
parent
63c9cb4f33
commit
c9ec8a81a0
@ -12,7 +12,8 @@ module.exports = function () {
|
||||
, XML = require( 'xml-escape' )
|
||||
, path = require( 'path' )
|
||||
, extend = require( './extend' )
|
||||
, _ = require('underscore');
|
||||
, _ = require('underscore')
|
||||
, Sheet = require('./sheet');
|
||||
|
||||
String.prototype.endsWith = function(suffix) {
|
||||
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
||||
@ -48,20 +49,19 @@ module.exports = function () {
|
||||
// Assemble input resumes
|
||||
var sheets = src.map( function( res ) {
|
||||
console.log( 'Reading JSON resume: ' + res );
|
||||
var raw = FS.readFileSync( res, 'utf8' );
|
||||
return JSON.parse( raw );
|
||||
return (new Sheet()).open( res );
|
||||
});
|
||||
|
||||
// Merge input resumes
|
||||
rez = sheets.reduce( function( acc, elem ) {
|
||||
return extend(true, acc, elem);
|
||||
return extend(true, acc.rep, elem.rep);
|
||||
});
|
||||
|
||||
// Run the transformation!
|
||||
var finished = targets.map( gen );
|
||||
|
||||
return {
|
||||
sheet: rez,
|
||||
sheet: rez.rep,
|
||||
targets: targets,
|
||||
processed: finished
|
||||
};
|
||||
@ -85,11 +85,11 @@ module.exports = function () {
|
||||
var mk = FS.readFileSync( themeFile, 'utf8' );
|
||||
|
||||
// Compile and invoke the template
|
||||
mk = single( rez, mk, fName, cssData );
|
||||
mk = single( rez.rep, mk, fName, cssData );
|
||||
|
||||
// Post-process and save the file
|
||||
fName === 'html' && (mk = html( mk, themeFile, fOut ));
|
||||
fName === 'pdf' && pdf( mk, fOut );
|
||||
//fName === 'pdf' && pdf( mk, fOut );
|
||||
fName !== 'pdf' && FS.writeFileSync( fOut, mk, 'utf8' );
|
||||
|
||||
return mk;
|
||||
|
21
src/sheet.js
Normal file
21
src/sheet.js
Normal file
@ -0,0 +1,21 @@
|
||||
(function() {
|
||||
|
||||
var FS = require('fs');
|
||||
|
||||
function Sheet() {
|
||||
|
||||
this.id = null;
|
||||
this.title = "";
|
||||
this.sheets = [];
|
||||
this.rep = { };
|
||||
|
||||
}
|
||||
|
||||
Sheet.prototype.open = function( file ) {
|
||||
this.rep = JSON.parse( FS.readFileSync( file, 'utf8' ) );
|
||||
return this;
|
||||
};
|
||||
|
||||
module.exports = Sheet;
|
||||
|
||||
}());
|
Loading…
Reference in New Issue
Block a user