Vendor Gems Quickly
Here’s a bash function to vendor gems in your Rails app.
Usage:
vg <gem name> [gem version]
This will install the gem in your ./vendor/gems directory, without installing documentation or dependencies. The version can be specific (i.e. 2.4.3) or minimal (i.e. “>= 2.4”).
Add the following to your ~/.profile:
function vg {
if [ -z "$1" ]; then
echo "Usage: vg [gem version]"
fi
opts="--install-dir=vendor/gems --no-rdoc --no-ri --ignore-dependencies"
if [ -n "$2" ]; then
opts="--version $2 $opts"
fi
gem install $1 $opts
}