Top Level Namespace

Defined Under Namespace

Modules: CocoapodsCafswitcher, Pod

Instance Method Summary collapse

Instance Method Details

#cleanCocoapodsCache(gitPathList) ⇒ Object



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/cocoapods-cafswitcher/Main.rb', line 214

def cleanCocoapodsCache(gitPathList)
  cachePath = Pod::Config.instance.cache_root + 'Pods'
  @cache = Pod::Downloader::Cache.new(cachePath)
  gitPathList.each do |gitPathSubPod|
    gitPathPod = gitPathSubPod.split('/')[0]
    cache_descriptors = @cache.cache_descriptors_per_pod[gitPathPod]
    # 清空缓存,因为缓存里有podspec.json
    if cache_descriptors
      # TODO 检查changedSubPod
      cache_descriptors.each do |desc|
        specs_dir = cachePath + 'Specs'
        release_specs_dir = specs_dir + 'Release'
        if desc[:spec_file].to_s.include?(release_specs_dir.to_s)
          next
        end
        Pod::UI.message("Removing spec #{desc[:spec_file]} (v#{desc[:version]})") do
          FileUtils.rm desc[:spec_file]
        end
        # Pod::UI.message("Removing cache #{desc[:slug]}") do
        #   FileUtils.rm_rf(desc[:slug])
        # end
      end
    end
  end

end

#cleanDebugENV(name) ⇒ Object



280
281
282
283
# File 'lib/cocoapods-cafswitcher/Main.rb', line 280

def cleanDebugENV(name)
  ENV.delete("#{name}_DEBUG")
  ENV.delete("#{name}_RELEASE")
end

#cleanENV(name) ⇒ Object



273
274
275
276
277
278
# File 'lib/cocoapods-cafswitcher/Main.rb', line 273

def cleanENV(name)
  envName = name.gsub(/[\/]/, '_')
  ENV.delete("#{envName}_SOURCE")
  ENV.delete("#{envName}_FRAMEWORK")
  ENV.delete('IS_SOURCE')
end

#cleanPodsDir(changedSubPods) ⇒ Object



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/cocoapods-cafswitcher/Main.rb', line 241

def cleanPodsDir(changedSubPods)
  config = Pod::Config.instance
  # 根据不同删除cache
  podRoot = config.project_pods_root
  changedSubPods.each do |changedSubPod|
    changedPod = changedSubPod.split('/')[0]
    # 清除本地的localFile 的JSON
    localspecPath = podRoot + "/Local Podspecs/" + "#{changedPod}.podspec.json"
    if File.exist? localspecPath.to_s
      Pod::UI.message "Removing local Podspecs.json #{localspecPath}"
      FileUtils.rm_r(localspecPath)
    end
    # next unless changedSubPod =~ /^(?i)LJ/ || changedSubPod =~ /^(?i)Lianjia/ || changedSubPod.include?('/')
    # 清除目录 pods 文件夹下的缓存
    changedPodPath = podRoot + changedPod
    if File.exist? changedPodPath.to_s
      Pod::UI.message "Removing Folder #{changedPodPath}"
      FileUtils.rm_r(changedPodPath)
    end
  end
end

#setEnv(name, suffix) ⇒ Object



264
265
266
267
268
269
# File 'lib/cocoapods-cafswitcher/Main.rb', line 264

def setEnv(name, suffix)
  envName = name.gsub(/[\/]/, '_')
  ENV["#{envName}#{suffix}"] = '1'
  podName = name.split('/')[0]
  ENV["#{podName}#{suffix}"] = '1'
end