Skip to content

Instantly share code, notes, and snippets.

@hirochachacha
Created January 19, 2012 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirochachacha/1640354 to your computer and use it in GitHub Desktop.
Save hirochachacha/1640354 to your computer and use it in GitHub Desktop.
rocco on the fly
#!/bin/bash --
set -e
TEMP_DIR="/tmp/rocco-$$"
GEM_DIR=$(ruby -e "print Gem::Specification.find_by_name(\"$1\").full_gem_path")
trap "rm -rf $TEMP_DIR" EXIT
mkdir $TEMP_DIR
cd $GEM_DIR/lib && find . -name '*.rb' -type f | xargs rocco -o $TEMP_DIR
cd $TEMP_DIR
if [ -r "$1.html" ]
then
INDEX="$1.html"
else
INDEX=""
fi
sleep 1 && python -c "import webbrowser; webbrowser.open(\"http://localhost:8000/$INDEX\")" &
python -m SimpleHTTPServer 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment