9e819435 |
# This plugin is based on https://github.com/gma/bundler-exec
# modify the BUNDLED_COMMANDS if needed
|
05883f38 |
bundled_commands=(cucumber heroku rackup rails rake rspec ruby shotgun spec spork) |
9e819435 |
## Functions
|
3aee5c19 |
_bundler-installed() |
9e819435 |
{
which bundle > /dev/null 2>&1
}
|
3aee5c19 |
_within-bundled-project() |
9e819435 |
{ |
3aee5c19 |
local check_dir=$PWD
while [ "$(dirname $check_dir)" != "/" ]; do
[ -f "$check_dir/Gemfile" ] && return
dir="$(dirname $check_dir)" |
9e819435 |
done
false
}
|
3aee5c19 |
_run-with-bundler() |
9e819435 |
{
local command="$1"
shift |
3aee5c19 |
if _bundler-installed && _within-bundled-project; then |
9e819435 |
bundle exec $command "$@"
else
$command "$@"
fi
}
## Main program |
05883f38 |
for cmd in $bundled_commands; do |
3aee5c19 |
alias $cmd="_run-with-bundler $cmd" |
9e819435 |
done |