Dot directories are not racks because formulae names do not start with
"." so avoid attempting to descend into dot directories, which may not
always be possible (e.g. .Trashes).
This is the (partially) documented public API for Homebrew.
The main class you should look at is the {Formula} class (and classes linked from there). That's the class that's used to create Homebrew formulae (i.e. package descriptions). Assume anything else you stumble upon is private.