Skip to content

Instantly share code, notes, and snippets.

@joecannatti
Created July 26, 2011 18:33
Show Gist options
  • Save joecannatti/1107477 to your computer and use it in GitHub Desktop.
Save joecannatti/1107477 to your computer and use it in GitHub Desktop.
pretty rake routes
function prr {
bundle exec rake routes | fgrep :action | \
\
awk '{
method="";
for(i=1;i<=NF;i++){
if ($i ~ /^\//){
example_url=$i;
}
else if($i ~ /[GET|PUT|POST|DELETE]/){
method=$i;
}
else if($i ~ /:action/){
first_index=index($i,"\"")+1;
action=substr($i,first_index,length($i)-first_index-1);
}
else if($i ~ /:controller/){
first_index=index($i,"\"")+1;
controller=substr($i,first_index,length($i)-first_index-1);
}
}
if ($1 != example_url && $1 != method){
name=$1;
}
print ""
print " " method;
print " " name;
print " " example_url;
print " ACTION: " action;
print " CONTROLLER: " controller;
}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment