Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Validate your bundler cache for OSX. For use in your Ruby (or Rails) project that is managed with Bundler.
#!/usr/bin/env bash
if [[ $1 != [yY] ]] ; then
echo 'Ensure this is executed in your bundled project.'
echo 'i.e. where the Gemfile is located'
ehco 'you should run 'bundle clean' first to ensure you don't check unused gems
echo "Type 'Y/y' to proceed"
read proceed
if [[ $proceed != [yY] ]] ; then
exit
fi
fi
if ! which md5 > /dev/null; then
echo Install md5
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
fi
# set your GEM_HOME to your bundler --local
# Example /Users/hankbeaver/mycom/myapp/local/ruby/1.9.1
home=$(bundle exec gem env GEM_HOME)
cache=$home/cache
echo This will take a while...
for gem in $cache/*.gem; do
echo inspecting $gem
gemfile=$(basename $gem)
local=$(md5 $gem | awk '{print $4}')
remote=$(curl -s -D - -X HEAD -H 'Connection:close' http://production.cf.rubygems.org/gems/$gemfile | grep 'ETag' | cut -d '"' -f 2)
if [[ ! $local = $remote ]]; then
echo $gemfile mismatch. local: $local, remote: $remote
fi
done
echo All done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment