Skip to content

Instantly share code, notes, and snippets.

@osxpeppermint
Created June 2, 2015 11:06
Show Gist options
  • Save osxpeppermint/edbd3bd61ca7f6519176 to your computer and use it in GitHub Desktop.
Save osxpeppermint/edbd3bd61ca7f6519176 to your computer and use it in GitHub Desktop.
OpenFL library scraper
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