'See citadel.py::ImportHandler.find_importables_in_dir() for
details.
Importables for Ruby look like this:
{"shell":   ("shell.rb",   None, True),
"weakref": ("weakref.rb", None, False),
"rdoc":    (None,         None, True)}
Notes:
- Drop "plat" dir (e.g., "i686-linux" on linux). Using the
existance of "$dir/rbconfig.rb" to indicate this is a plat
dir. Optimization: Only look in dirs with a hyphen.
TODO: log the fs-stat\'ing a la codeintel.db logging.
TODO: consider *.so files when have a story for binary modules
on the fly'

def find_importables_in_dir(self, dir):

    from os.path import join, isdir, splitext, exists
    if (dir == '<Unsaved>'):
        return {}
    try:
        names = os.listdir(dir)
    except OSError as ex:
        return {}
    (dirs, nondirs) = (set(), set())
    for name in names:
        if isdir(join(dir, name)):
            if (('-' in name) and exists(join(dir, name, 'rbconfig.rb'))):
                continue
            dirs.add(name)
        else:
            nondirs.add(name)
    importables = {}
    for name in nondirs:
        (base, ext) = splitext(name)
        if (ext != '.rb'):
            continue
        if (base in dirs):
            importables[base] = (name, None, True)
            dirs.remove(base)
        else:
            importables[base] = (name, None, False)
    for name in dirs:
        importables[name] = (None, None, True)
    return importables
