I am now responsible for a Rails application that was built in a very quick-and-dirty fashion. It has many view files (html templates) that are not used. It also has many css files that are not used.
What is the best way to determine which files are no longer needed so they can be deleted?
I'm looking for a generic solution and not a Rails-specific solution, but a Ruby/Rails-only solution will definitely be welcomed.
Just to get things started, one idea I had (which I'm not particularly fond of) for determining which views were used is as follows:
- Write a script that will insert a line of code into the top of every view file. The line of code will append the name of the view to some sort of log.
- Recursively wget the entire site
- Go through the log and remove duplicates - then we have a list of views that are used
- Delete views that are not listed in the log
If you are on a unix-like system:
Make sure the partition with the pages are mounted with access time (atime) enabled. On linux, mounts with relatime or noatime will not help you.)
Pick the current time.
Run the webserver for a few days.
Identify files whose atime is older than the previously picked time. They are not being used.