Last active
November 18, 2016 14:49
-
-
Save gagomes/a04b3098181220176e40cef98314b0d0 to your computer and use it in GitHub Desktop.
a util to display the contents of a ruby gemfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -u | |
GEM=$1 | |
if ! echo $GEM | egrep -qi '\.gem$'; then | |
echo $1 does not end in .gem | |
exit 1 | |
fi | |
trap '' INT | |
TMPDIR=~/tmp/gemcat | |
mkdir -p $TMPDIR | |
CONTENTS=$(mktemp -d) | |
echo $CONTENTS | |
echo ------------------------------------------ | |
echo | |
tar xf $GEM -C $CONTENTS | |
pushd $CONTENTS | |
for file in *; do | |
echo $file | |
echo ------------------------------------------- | |
echo | |
case "$file" in | |
*.tgz|*.tar.gz) | |
tar tfvz $file | |
;; | |
*.gz) | |
zcat < $file | |
;; | |
*) | |
echo "unhandled" $file ;e | |
esac | |
echo | |
done | |
popd | |
rm -rf $CONTENTS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment