Skip to content

Instantly share code, notes, and snippets.

@Nirma
Last active Aug 29, 2015
Embed
What would you like to do?
Ruby script to clean up unused / old classes
#!/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