Class: Xcodeproj::ModuleItem

Inherits:
Object
  • Object
show all
Defined in:
lib/podfileDep/check/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(module_name) ⇒ ModuleItem

Returns a new instance of ModuleItem.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/podfileDep/check/item.rb', line 51

def initialize(module_name)
  @module_name = module_name
  @module_path = nil
  @podspec_path = nil
  @header_files = {}
  @source_files = {}
  @import_items = []
  @absolute_import_items = []
  @is_development_module = false
  @frameworks = []
end

Instance Attribute Details

#absolute_import_itemsObject

ImportItem


46
47
48
# File 'lib/podfileDep/check/item.rb', line 46

def absolute_import_items
  @absolute_import_items
end

#frameworksObject

String


49
50
51
# File 'lib/podfileDep/check/item.rb', line 49

def frameworks
  @frameworks
end

#header_filesObject

组件目录的所有被引用的文件数组



34
35
36
# File 'lib/podfileDep/check/item.rb', line 34

def header_files
  @header_files
end

#import_itemsObject

ImportItem


43
44
45
# File 'lib/podfileDep/check/item.rb', line 43

def import_items
  @import_items
end

#is_development_moduleObject

是否是开发模块



40
41
42
# File 'lib/podfileDep/check/item.rb', line 40

def is_development_module
  @is_development_module
end

#module_nameObject

组名名



25
26
27
# File 'lib/podfileDep/check/item.rb', line 25

def module_name
  @module_name
end

#module_pathObject

组件路径



28
29
30
# File 'lib/podfileDep/check/item.rb', line 28

def module_path
  @module_path
end

#podspec_pathObject

podspec路径



31
32
33
# File 'lib/podfileDep/check/item.rb', line 31

def podspec_path
  @podspec_path
end

#source_filesObject

组件目录的所有被引用的文件数组



37
38
39
# File 'lib/podfileDep/check/item.rb', line 37

def source_files
  @source_files
end

Instance Method Details

#init_absolute_import_infoObject

生成 import <XX/YY.h>的信息生成 include <XX/YY.h>的信息



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/podfileDep/check/item.rb', line 65

def init_absolute_import_info
  source_files.each_value do |source_file_path|
    if File.directory?(source_file_path)
      next
    end

    line_array = IO.readlines(source_file_path)
    line_array.each_with_index { |line, line_index|
      line = line.gsub(" ", "")

      # 处理特殊情况
      if line.start_with?("#import\"NBSAppAgent.h\"")
        line = "#import<tingyunApp/NBSAppAgent.h>"
      end

      if not line.start_with?("#import<") and not line.start_with?("#include<")
        next
      end

      if line.start_with?("@implementation")
        break
      end

      # 前一行的内容 这里不是检测,则不需要
      pre_line = ""

      import_item = other_module_import(line, source_file_path, line_index, @module_name, pre_line)
      if import_item
        absolute_import_items << import_item
      end
    }
  end

  absolute_import_items
end

#init_import_infoObject

生成 import “XXX.h”的信息



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/podfileDep/check/item.rb', line 102

def init_import_info
  source_files.each_value do |source_file_path|
    if File.directory?(source_file_path)
      next
    end

    line_array = IO.readlines(source_file_path)
    line_array.each_with_index { |line, line_index|
      line = line.gsub(" ", "")

      unless line.start_with?("#import")
        next
      end

      if line.start_with?("@implementation")
        break
      end

      # 前一行的内容
      pre_index = line_index-1 < 0 ? 0 : line_index-1
      pre_line = line_array[pre_index]

      if line.start_with?("#import\"") #本组件
        import_item = own_module_import(line, source_file_path, line_index, @module_name, pre_line)
        if import_item
          import_items << import_item
        end
      elsif line.start_with?("#import<") #其他组件

      end

    }
  end

  import_items
end