Created
January 23, 2012 22:17
-
-
Save levinotik/1665820 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bin/env ruby | |
#Author - Levi Notik | |
# Pass the root project path in which to see | |
# which Activities you've forgotten to add to your manifest | |
@activities = Array.new | |
@project_files = Array.new | |
def find_subactivities(super_class) | |
@project_files.each do |file| | |
file = File.read(file) | |
if file =~ /public class (\S+) extends #{super_class}/ | |
@activities.push($1) | |
find_subactivities($1) | |
end | |
end | |
end | |
ARGV.each do |path| | |
files = Dir.glob(File.join(path, '**', "*.java"), File::FNM_CASEFOLD).each do |f| | |
class_file = File.read(f) | |
if (class_file =~ /public class (\S+) extends Activity/) | |
@activities.push($1) | |
end | |
end | |
project_files = files | |
found_activity = String.new | |
@activities.each do |activity| | |
files.each do |f| | |
file = File.read(f) | |
if file =~ /public class (\S+) extends #{activity}/ | |
found_activity = $1 | |
@activities.push(found_activity) | |
find_subactivities(found_activity) | |
end | |
end | |
end | |
project_root = File.join(path, "AndroidManifest.xml") | |
manifest = File.read(project_root) | |
not_declared_in_manifest = Array.new | |
@activities.each do |activity| | |
unless manifest =~ /\b#{activity}\b/ | |
not_declared_in_manifest.push(activity) | |
end | |
end | |
unless not_declared_in_manifest.empty? | |
puts "The following Activities may need to be added to the Manifest" | |
puts not_declared_in_manifest | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment