lib/objcthin.rb in objcthin-0.3.0 vs lib/objcthin.rb in objcthin-0.4.0

- old
+ new

@@ -7,15 +7,15 @@ module Objcthin class Command < Thor desc 'findsel','find unused method sel' method_option :prefix, :default => '', :type => :string, :desc => 'the class prefix you want find' def findsel(path) - Imp::UnusedClass.instance.find_unused_sel(path, options[:prefix]) + Imp::UnusedSel.instance.find_unused_sel(path, options[:prefix]) end desc 'findclass', 'find unused class list' - method_option :prefix => :string, :default => '', :desc => 'the class prefix you want find' + method_option :prefix, :default => '', :type => :string, :desc => 'the class prefix you want find' def findclass(path) Imp::UnusedClass.instance.find_unused_class(path, options[:prefix]) end desc'version','print version' @@ -24,11 +24,11 @@ end end end module Imp - class UnusedClass + class UnusedSel include Singleton def find_unused_sel(path, prefix) check_file_type(path) @@ -176,10 +176,16 @@ module Imp class UnusedClass include Singleton + def find_unused_class(path, prefix) + check_file_type(path) + result = split_segment_and_find(path, prefix) + puts result.values + end + def check_file_type(path) pathname = Pathname.new(path) unless pathname.exist? raise "#{path} not exit!" end @@ -219,13 +225,14 @@ end patten = /Contents of \(.*\) section/ name_patten_string = '.*' - if prefix.length > 0 + unless prefix.empty? name_patten_string = "#{prefix}.*" end + vmaddress_to_class_name_patten = /^(\d*\w*)\s(0x\d*\w*)\s_OBJC_CLASS_\$_(#{name_patten_string})/ class_list = [] class_refs = [] used_vmaddress_to_class_name_hash = {} @@ -277,15 +284,7 @@ end end result end - - def find_unused_class(path, prefix) - check_file_type(path) - result = split_segment_and_find(path, prefix) - puts result.values - end - end - -end \ No newline at end of file + end