Last active
August 29, 2015 14:18
-
-
Save Nirma/f28e4d6b8e4b34ff42f4 to your computer and use it in GitHub Desktop.
Ruby script to clean up unused / old classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
#Get Contents | |
file = File.open(ARGV[0], "r") | |
data = file.read | |
file.close | |
search_results = [] | |
data.each_line{ |line| | |
output = `pt -l #{line}` | |
record = {:count => 0, :files => [], :name => line} | |
output.each_line{ |output_line| | |
next if output_line.match /pbxproj|Bridging-Header.h|.txt/ | |
record[:files] << output_line | |
record[:count] += 1 | |
} | |
search_results << record | |
} | |
search_results.sort_by!{ |hash| hash[:count]} | |
results = File.open(ARGV[1], "w") | |
output_str = "" | |
search_results.each{|data| | |
output_str += "\n\n## #{data[:name]}" | |
output_str += "\n#### File Count: #{data[:count]}" | |
output_str += "\n#### Appears in Files: \n" | |
data[:files].each{ |file_name| | |
output_str += "* " + file_name | |
} | |
output_str += "\n\n\n" | |
} | |
results.write output_str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment