Skip to content

Instantly share code, notes, and snippets.

@vertis
Created January 25, 2013 04:16
Show Gist options
  • Select an option

  • Save vertis/4631686 to your computer and use it in GitHub Desktop.

Select an option

Save vertis/4631686 to your computer and use it in GitHub Desktop.
Generate gem dependencies. You need to have graphviz installed
#!/usr/bin/env bash
if [ $# -eq 0 ] ; then
printf "%s\n" "no args given, exiting"
exit 1
fi
export TMP_GEM_PATH=/tmp/$1
mkdir -p
GEM_HOME=$TMP_GEM_PATH GEM_PATH=$TMP_GEM_PATH gem install $1
GEM_HOME=$TMP_GEM_PATH GEM_PATH=$TMP_GEM_PATH gem list \
| cut -d\ -f1 \
| xargs gem dep \
| grep -v development\) \
| awk '\
BEGIN { print "digraph gems {" } \
/^Gem / { cur=$2; sub(/-[0-9\.]+$/, "", cur); print " \"" cur "\";" } \
! /^Gem / && $0 != "" { print " \"" cur "\" -> \"" $1 "\";" } \
END { print "}" }' \
| dot -Tpng -o gems.png
rm -rf $TMP_GEM_PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment