Class: Xcodeproj::ImportChecker
- Inherits:
-
Object
- Object
- Xcodeproj::ImportChecker
- Defined in:
- lib/podfileDep/check/import.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#check_import ⇒ Object
检查import规范.
-
#initialize(project) ⇒ ImportChecker
constructor
A new instance of ImportChecker.
Constructor Details
#initialize(project) ⇒ ImportChecker
Returns a new instance of ImportChecker.
10 11 12 |
# File 'lib/podfileDep/check/import.rb', line 10 def initialize(project) @project = project end |
Instance Attribute Details
#project ⇒ XCodeProject
7 8 9 |
# File 'lib/podfileDep/check/import.rb', line 7 def project @project end |
Instance Method Details
#check_import ⇒ Object
检查import规范
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/podfileDep/check/import.rb', line 15 def check_import puts "import检查中..." start = (Time.now.to_f * 1000).to_i module_count = 0 file_count = 0 project.module_items.each do |module_name, module_item| unless module_item.is_development_module next end module_count += 1 = [] did_check_imports = {} module_item.init_import_info module_item.import_items.each do |import_item| file_count += 1 did_check_import = did_check_imports[import_item.import_file_name] if did_check_import next end need_module_item = project.module_items[import_item.module_name] real_path = need_module_item.header_files[import_item.import_file_name] did_check_imports[import_item.import_file_name] = !!(real_path) unless real_path # 去查找所属模块 expect_module_name = find_module_with_header_file(import_item.import_file_name) if expect_module_name << "#{import_item.file_path.basename} 第#{import_item.line_index}行 #{import_item.import_name} => #import <#{expect_module_name}/#{import_item.import_file_name}>" end end end if .size >0 puts "组件#{module_item.module_name}存在以下情况, 请检查:".yellow puts puts "\n" end end duration = ((Time.now.to_f * 1000).to_i - start)*0.001 puts "import检查完毕! 共检查#{module_count}个组件(#{file_count}个import) 耗时:#{duration.round(2)}秒" end |