Reimplement cap completion with ruby