Class: DoraBox::PodFileHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/doraBox/util/pod_file_helper.rb

Class Method Summary collapse

Class Method Details

.get_module_dependece(module_name) ⇒ Object



67
68
69
70
# File 'lib/doraBox/util/pod_file_helper.rb', line 67

def self.get_module_dependece(module_name)
  version = ""

end

.handle_pod_file(modules_name, branch_name) ⇒ Object



11
12
13
14
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
# File 'lib/doraBox/util/pod_file_helper.rb', line 11

def self.handle_pod_file(modules_name,branch_name)
  version_filter_regex = /'([\d]+)(\.([1-9]\d|\d)*-*\w*)*'/
  version_filter_number_regex = /([\d]+)(\.([1-9]\d|\d)*-*\w*)*/
  podfile_str = ""
  checked_names = []
  module_branch_or_version_dict = {}

  File.open($pod_file, 'r+') do |file|
    file.each_line do |line|
      modules_name.each do |name|
        puts line if line.include?(name)
        checked_names.append(name)
        if version_filter_regex =~ line && /#{name}/ =~ line && /[^#]/ =~ line
          regex_str = line.gsub(version_filter_regex,":path => '../#{name}'")
          podfile_str += regex_str
          match_result = version_filter_number_regex.match(line)
          module_branch_or_version_dict[name] = match_result[0]
        else
          podfile_str += line
        end
      end
    end
  end

  # puts module_branch_or_version_dict

  # 根据公版模块的版本,去创建 ka 定制的分支
  modules_name.each do |module_name|
    module_pod_version = module_branch_or_version_dict[module_name]
    GitOperator.create_module_branch(module_pod_version,module_name,branch_name)
  end


  # 修改 podfile
  File.open($pod_file,'w') do |file|
    file.write podfile_str
  end

  FileOperator.cache_modified_modules(modules_name,branch_name)

  # 执行 pod install
  Logger.log_with_type("正在执行 pod install", HIGHLIGHT_LOG)
  pod_install

end

.pod_installObject



57
58
59
60
61
62
63
64
65
# File 'lib/doraBox/util/pod_file_helper.rb', line 57

def self.pod_install
  if Dir.chdir(File.dirname($pod_file))
    IO.popen("pod install") do |io|
      io.each do |line|
        puts Logger.log_with_type(line,HIGHLIGHT_LOG)
      end
    end
  end
end