mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 09:56:22 +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' )
|
, XML = require( 'xml-escape' )
|
||||||
, path = require( 'path' )
|
, path = require( 'path' )
|
||||||
, extend = require( './extend' )
|
, extend = require( './extend' )
|
||||||
, _ = require('underscore');
|
, _ = require('underscore')
|
||||||
|
, Sheet = require('./sheet');
|
||||||
|
|
||||||
String.prototype.endsWith = function(suffix) {
|
String.prototype.endsWith = function(suffix) {
|
||||||
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
||||||
@ -48,20 +49,19 @@ module.exports = function () {
|
|||||||
// Assemble input resumes
|
// Assemble input resumes
|
||||||
var sheets = src.map( function( res ) {
|
var sheets = src.map( function( res ) {
|
||||||
console.log( 'Reading JSON resume: ' + res );
|
console.log( 'Reading JSON resume: ' + res );
|
||||||
var raw = FS.readFileSync( res, 'utf8' );
|
return (new Sheet()).open( res );
|
||||||
return JSON.parse( raw );
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Merge input resumes
|
// Merge input resumes
|
||||||
rez = sheets.reduce( function( acc, elem ) {
|
rez = sheets.reduce( function( acc, elem ) {
|
||||||
return extend(true, acc, elem);
|
return extend(true, acc.rep, elem.rep);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Run the transformation!
|
// Run the transformation!
|
||||||
var finished = targets.map( gen );
|
var finished = targets.map( gen );
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sheet: rez,
|
sheet: rez.rep,
|
||||||
targets: targets,
|
targets: targets,
|
||||||
processed: finished
|
processed: finished
|
||||||
};
|
};
|
||||||
@ -85,11 +85,11 @@ module.exports = function () {
|
|||||||
var mk = FS.readFileSync( themeFile, 'utf8' );
|
var mk = FS.readFileSync( themeFile, 'utf8' );
|
||||||
|
|
||||||
// Compile and invoke the template
|
// Compile and invoke the template
|
||||||
mk = single( rez, mk, fName, cssData );
|
mk = single( rez.rep, mk, fName, cssData );
|
||||||
|
|
||||||
// Post-process and save the file
|
// Post-process and save the file
|
||||||
fName === 'html' && (mk = html( mk, themeFile, fOut ));
|
fName === 'html' && (mk = html( mk, themeFile, fOut ));
|
||||||
fName === 'pdf' && pdf( mk, fOut );
|
//fName === 'pdf' && pdf( mk, fOut );
|
||||||
fName !== 'pdf' && FS.writeFileSync( fOut, mk, 'utf8' );
|
fName !== 'pdf' && FS.writeFileSync( fOut, mk, 'utf8' );
|
||||||
|
|
||||||
return mk;
|
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