Skip to content

Instantly share code, notes, and snippets.

@gagomes
Last active November 18, 2016 14:49
Show Gist options
  • Save gagomes/a04b3098181220176e40cef98314b0d0 to your computer and use it in GitHub Desktop.
Save gagomes/a04b3098181220176e40cef98314b0d0 to your computer and use it in GitHub Desktop.
a util to display the contents of a ruby gemfile
#!/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