Skip to content

Instantly share code, notes, and snippets.

@timabell
Forked from gma/Gemfile.local
Last active December 21, 2015 00:19
Show Gist options
  • Save timabell/6219158 to your computer and use it in GitHub Desktop.
Save timabell/6219158 to your computer and use it in GitHub Desktop.
# Script for switching your own gems in and out of a project
# without interfering with git's status. Caveat emptor.
# Instructions:
# Source this file from your .bashrc, this will make bundle-local available
# Put a Gemfile.local in your project with the gems you want to use
# run `bundle-local on && bundle` from your project directory
# run `bundle-local off` if you are going to need to check in changes to your bundle
bundle-local ()
{
local command="$1";
if [ "$command" = "on" ]; then
if ! grep --color=auto -qs Gemfile.local Gemfile; then
echo "Appending local gems to gemfile..."
echo "eval File.read('Gemfile.local')" >> Gemfile;
echo "Telling git to ignore gemfile changes..."
git update-index --assume-unchanged Gemfile Gemfile.lock;
echo "Updating bundles..."
bundle;
fi;
else
if [ "$command" = "off" ]; then
echo "Appending local gems to gemfile..."
sed -i '/Gemfile.local/d' Gemfile;
echo "Telling git not to ignore gemfile changes..."
git update-index --no-assume-unchanged Gemfile Gemfile.lock;
echo "Updating bundles..."
bundle;
else
echo "Usage: bundle-local <on|off>" 1>&2;
return 1;
fi;
fi
}
group :development do
gem 'debugger'
gem 'spring'
end
group :test do
gem 'minitest', '4.3.0'
gem 'tconsole', '1.2.8'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment