Created
May 10, 2014 00:36
-
-
Save dylancwood/4d04a754a287ec7373e7 to your computer and use it in GitHub Desktop.
AppData Cleanup!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
TODO: | |
write a new file that contains calls to each function found in each of the splitFileDirPath | |
function getSubjectTags() { | |
return className->getSubjectTags($args); | |
} | |
Address methods that reference other methods as '$this->doSomething()' | |
+ $this->select() Could be addressed by each class extending BaseAppData | |
+ Grep for methods defined in File 'A' that are referenced in File 'B' using $this-> | |
+ Alternatively, change all calls to '$this' to be $AppData. | |
*/ | |
var fs = require('fs'); | |
var splitFilesDirPath = './micis/AppDataClasses/'; | |
var appDataPath = './micis/AppData.inc'; | |
//format {'filename':[func1, func2]...} | |
var functionNames = {} | |
fs.readdir(splitFilesDirPath, function readFiles(err, files) { | |
if (err) throw err; | |
files.forEach(function readFile(filename) { | |
var fileFullPath = splitFilesDirPath + filename; | |
functionNames[filename] = []; | |
fs.readFile(fileFullPath, 'utf-8', function parseFunctionNames(err, contents) { | |
var rx = /function *[^\s(]* *\([^)]*\)\s*\{/g; | |
var funcNameRx = /function *([^\s(]*) *\([^)]*\)\s*\{/; | |
console.log(filename); | |
if (contents == undefined) return; | |
functionNames[filename] = contents.match(rx).map(function extractFunctionName(str) { | |
var groups = str.match(funcNameRx); | |
console.log('>>>' + groups[1]); | |
return groups[1]; | |
}); | |
}); | |
}); | |
}); | |
/* | |
in app.inc: | |
require('AppData.inc'); | |
in AppData.inc: | |
require ('AppDataSomething.inc') | |
//other sub-classes required | |
class AppData { | |
__constructor() { | |
$this->AppDataSomething = new AppDataSomething($this); | |
} | |
someThing() { | |
return $this->AppDataSomething->someThing($args); | |
} | |
... | |
} | |
in AppDataSomething.inc: | |
class AppDataSomething { | |
__constructor ($parent) { | |
$this->parent = $parent; | |
} | |
someThing() { | |
//$this->select() | |
$this->parent->select(); | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment