Class: Stool::TaskInfo

Inherits:
BaseObj show all
Includes:
Git_util
Defined in:
lib/stool/Core/TaskInfo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Git_util

#git_checkout, #git_commit_all, #git_st, #git_stash, #git_stash_pop, #git_up

Methods inherited from BaseObj

#doCacheByYAML, fromFile, fromYAML

Constructor Details

#initializeTaskInfo

Returns a new instance of TaskInfo.



24
25
26
27
28
29
30
# File 'lib/stool/Core/TaskInfo.rb', line 24

def initialize
  @localLibs = []
  @otherCode = []
  @repos = []
  @allUseCode = false
  super
end

Instance Attribute Details

#allUseCodeObject

Returns the value of attribute allUseCode.



19
20
21
# File 'lib/stool/Core/TaskInfo.rb', line 19

def allUseCode
  @allUseCode
end

#localLibsObject

pod时,指定的本地lib name



16
17
18
# File 'lib/stool/Core/TaskInfo.rb', line 16

def localLibs
  @localLibs
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/stool/Core/TaskInfo.rb', line 11

def name
  @name
end

#otherCodeObject

其他源码指定



18
19
20
# File 'lib/stool/Core/TaskInfo.rb', line 18

def otherCode
  @otherCode
end

#pathObject

Returns the value of attribute path.



12
13
14
# File 'lib/stool/Core/TaskInfo.rb', line 12

def path
  @path
end

#reposObject

指定的repo



22
23
24
# File 'lib/stool/Core/TaskInfo.rb', line 22

def repos
  @repos
end

#tagObject

Returns the value of attribute tag.



13
14
15
# File 'lib/stool/Core/TaskInfo.rb', line 13

def tag
  @tag
end

Instance Method Details

#addLocalLib(libs) ⇒ Object



48
49
50
51
52
# File 'lib/stool/Core/TaskInfo.rb', line 48

def addLocalLib(libs)
  libs.each do |lib|
    @localLibs.push(lib)
  end
end

#addOtherLibUseCode(libs) ⇒ Object



54
55
56
57
58
# File 'lib/stool/Core/TaskInfo.rb', line 54

def addOtherLibUseCode(libs)
  libs.each do |lib|
    @otherCode.push(lib)
  end
end

#allLibsUseCodeObject



60
61
62
# File 'lib/stool/Core/TaskInfo.rb', line 60

def allLibsUseCode
  @allUseCode = true
end

#edit_podfile_use_loaclLibsObject

更新podfile,添加使用本地库



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/stool/Core/TaskInfo.rb', line 83

def edit_podfile_use_loaclLibs
  podfilePath = File.join(@path,'Podfile')

  if File.exist?(podfilePath)
    arr = @localLibs
    newStr = ''
    lastMatch = ''
    File.open(podfilePath, "r+") do |f|
      f.each_line do |line|
        lineNew = line
        hasFound = []
        arr.each do |libName|
          regx = "pod '#{libName}'"
          if line[/#{regx}/]
            config = Config.loadConfig
            libInfo = nil
            config.pools.each do |pool|
              result = pool.searchLib(libName)
              if result
                libInfo = result
              end
            end
            if libInfo
              lineNew = regx + ", :path => '#{libInfo.path}'" + "\n"
              lastMatch = lineNew
              hasFound.push(libName)
            end
          end
        end
        arr = arr - hasFound
        newStr = newStr + lineNew
      end
    end

    File.open(podfilePath, "w") do |file|
      # puts newStr
      file.write(newStr)
    end

    if arr.count > 0
      newStr = ''
      File.open(podfilePath, "r+") do |f|
        f.each_line do |line|
          lineNew = line
          regx = "#{lastMatch}"
          if line[/#{regx}/]
            arr.map do |libName|
              config = Config.loadConfig
              libInfo = nil
              config.pools.each do |pool|
                result = pool.searchLib(libName)
                if result
                  libInfo = result
                end
              end
              if libInfo
                lineNew = lineNew + "\n" + "pod '#{libName}'" + ", :path => '#{libInfo.path}'" + "\n"
              end
            end
          end
          newStr = newStr + lineNew
        end
      end

      File.open(podfilePath, "w") do |file|
        file.write(newStr)
      end
    end
  end
end

#info_tosObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/stool/Core/TaskInfo.rb', line 32

def info_tos
  puts('--' + 'name:'+ self.name)
  puts('--' + 'tag:'+ self.tag)
  puts('--' + 'path:'+ self.path)
  puts('--' + 'localLibs:')
  self.localLibs.sort.map do |lib|
    puts('  ' + lib.to_s)
  end
  puts('--' + 'otherCode:')
  self.otherCode.sort.map do |lib|
    puts('  ' + lib.to_s)
  end
  puts('--' + 'allUseCode:'+ self.allUseCode.to_s)
  puts('')
end

#open_taskObject



66
67
68
# File 'lib/stool/Core/TaskInfo.rb', line 66

def open_task
  `open *.xcworkspace`
end

#resetPofileObject



70
71
72
# File 'lib/stool/Core/TaskInfo.rb', line 70

def resetPofile
  git_checkout(File.join(@path,'Podfile'))
end

#task_git_upObject

更新主工程



75
76
77
78
79
80
# File 'lib/stool/Core/TaskInfo.rb', line 75

def task_git_up
  if @path
    Dir.chdir(path)
    git_up
  end
end