ianheggie/rbenv-binstubs — pull request #6 by madumlao (2013-06-18 07:19:57+00:00)
Title: Create binstubs for all projects ever rehashed with rbenv-binstubs

This patch is a possible solution for issue 5.

It adds a hook to rbenv-rehash to keep track of any bundles in ${RBENV_ROOT}/bundles. The hook does the following:

1) Everytime rehash is run, if the current directory has a Gemfile, it is added to the list of bundles.
2) All installed bundles are checked to see if they have Gemfiles and they are removed if they are no longer present. The check is a simple [ -f "$bundle"/Gemfile ] test, so it shouldn't be long.
3) check_for_binstubs is run on all remaining directories, and a shim is registered for all files in the bin path.

Tests:
1) rbenv which on outside of a project path will correctly fail to find the script if it wasn't installed in your ruby version.
2) rbenv which in project 1 finds binstubs for project 1 and rbenv which for project 2 finds binstubs for project 2.

Todo:
1) refactor check_for_binstubs to be in a common include?

I really, really hate typing bundle exec.