Created
June 2, 2015 11:06
-
-
Save osxpeppermint/edbd3bd61ca7f6519176 to your computer and use it in GitHub Desktop.
OpenFL library scraper
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
import sys.FileSystem; | |
import sys.io.File; | |
class Scraper { | |
static public function scrapeFile(name,filename):Void { | |
var r = ~/public\s(?:inline\s)?function\s([A-Za-z]+)/gm; | |
var fileContents = sys.io.File.getContent(filename); | |
var fileLines = fileContents.split("\n"); | |
neko.Lib.println("<" + name + ">"); | |
for (fileLine in fileLines) | |
{ | |
if (r.match(fileLine)) | |
neko.Lib.println(r.matched(1)); | |
} | |
neko.Lib.println("\n"); | |
} | |
static public function main():Void { | |
// Set globals | |
var directory = "/Users/drkameleon/Desktop/HaxeScraper/"; // Where the Scraper.hx is | |
directory += "openfl"; // Where the OpenFL .hx lib files are | |
neko.Lib.println("HaxeScraper loaded."); | |
var files = sys.FileSystem.readDirectory(directory); | |
for (f in files) | |
{ | |
var file = directory + "/" + f; | |
if (sys.FileSystem.isDirectory(file)) | |
{ | |
// It's a folder | |
var subfiles = sys.FileSystem.readDirectory(file); | |
for (subf in subfiles) | |
{ | |
var subfile = file + "/" + subf; | |
if (!sys.FileSystem.isDirectory(subfile)) | |
scrapeFile(f+"/"+subf, subfile); | |
} | |
} | |
else | |
{ | |
scrapeFile(f,file); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment