Skip to content

Instantly share code, notes, and snippets.

@Adzz
Created August 8, 2016 17:01
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 Adzz/c41c338623e562a4c69c86d2ce9aa47c to your computer and use it in GitHub Desktop.
Save Adzz/c41c338623e562a4c69c86d2ce9aa47c to your computer and use it in GitHub Desktop.
This is lifted from Gary Bernhardt here: https://www.youtube.com/watch?v=sCZJblyT_XM It shows the number of times a class is referenced within an app
grep -rh '^[[:space:]]*\(class\|module\)\b' api/app api/lib --include='*.rb' | sed 's/^[[:space:]]*//' | cut -d ' ' -f 2 | while read class; do echo "`grep -rl "\b$class\b" api/app api/lib --include="*.rb" | wc -l` $class"; done | sort -n
@Adzz
Copy link
Author

Adzz commented Aug 8, 2016

Currently searches within api/app and api/lib but those paths can be edited to whichever we need.

@Adzz
Copy link
Author

Adzz commented Aug 8, 2016

```grep -rh '^[[:space:]](class|module)\b' app lib --include='.rb' | sed 's/^[[:space:]]*//' | cut -d ' ' -f 2 | while read class; do echo "grep -rl "\b$class\b" app lib --include="*.rb" | wc -l $class"; done | sort -n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment