Skip to content

Commit

Permalink
event executer implemented and pass existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomohito Nakayama committed Mar 18, 2016
1 parent 497f58b commit d65e8fd
Showing 1 changed file with 57 additions and 5 deletions.
62 changes: 57 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,53 @@ function rootPlan( executeFunction , fixedFile ){
this.fixedFiles = fixedFile;
}

function eventPlan( executer ){

let thisPlan = this;
this.receivingFileProxy = new ReceivingFileProxy();

rootPlan.call(
this,
function(
eventListnerConfigurator,
filePathCalculator ) {

eventListnerConfigurator(
function( receivedObject ) {

let files = fixFiles ( filePathCalculator( receivedObject ) , executer );

files.foreach( file => thisPlan.runtime.addJsonFile( file ) );

for( let file of files ){

saveAfterApply(
receivedObject,
file.path(),
function( executeNextPlan ){
// no need to close filePath
executeNextPlan();
},
calcJb( file.path() ),
file.path(),
thisPlan.nextPlan,
executer
);

}
},
function() { thisPlan.runtime.removeJsonFile( this.receivingFileProxy ); }
)

},
this.receivingFileProxy
)
}

util.inherits( notexecPlan, executePlan );
util.inherits( collectPlan, executePlan );
util.inherits( rootPlan, executePlan );
util.inherits( eventPlan, executePlan );

function runtimeInformation(){

Expand Down Expand Up @@ -313,13 +358,13 @@ function rootsExecuter( executers ){

};

function eventExecuter( eventListnerCongigurator, fileNameCalculator ){
function eventExecuter( eventListnerConfigurator, fileNameCalculator ){
rootExecuter.call( this, null );
let thisExecuter = this;

this.rootExec =
function( executePlan ){
executePlan._executeFunction();
executePlan._executeFunction( eventListnerConfigurator, fileNameCalculator );
};

}
Expand Down Expand Up @@ -570,6 +615,11 @@ function JsonFile( filePath ){
}
}

function ReceivingFileProxy(){
}

util.inherits( ReceivingFileProxy, JsonFile );

function ioExecuter( userProcess, parent) {
childExecuter.call( this, userProcess, parent );

Expand Down Expand Up @@ -1189,14 +1239,16 @@ function applyCalledbackProcess( process, json, file, closeFile, jb, filePath, n

files.forEach(
( file ) => {
save(
saveAfterApply(
data,
file ,
function(){
function( executeNextPlan ){
// no need to close filePath
nextPlan._executeFunction( file );
executeNextPlan();
},
jb,
file,
nextPlan,
normalized._plannedExecuter);
}
);
Expand Down

0 comments on commit d65e8fd

Please sign in to comment.