class Object

Public Instance Methods

cleanCocoapodsCache(gitPathList) click to toggle source
# File lib/cocoapods-cafswitcher/Main.rb, line 219
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_rf([desc[:spec_file]])
        end
        # Pod::UI.message("Removing cache #{desc[:slug]}") do
        #   FileUtils.rm_rf([desc[:slug]])
        # end
      end
    end
  end

end
cleanDebugENV(name) click to toggle source
# File lib/cocoapods-cafswitcher/Main.rb, line 285
def cleanDebugENV(name)
  ENV.delete("#{name}_DEBUG")
  ENV.delete("#{name}_RELEASE")
end
cleanENV(name) click to toggle source
# File lib/cocoapods-cafswitcher/Main.rb, line 278
def cleanENV(name)
  envName = name.gsub(/[\/]/, '_')
  ENV.delete("#{envName}_SOURCE")
  ENV.delete("#{envName}_FRAMEWORK")
  ENV.delete('IS_SOURCE')
end
cleanPodsDir(changedSubPods) click to toggle source
# File lib/cocoapods-cafswitcher/Main.rb, line 246
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) click to toggle source
# File lib/cocoapods-cafswitcher/Main.rb, line 269
def setEnv(name, suffix)
  envName = name.gsub(/[\/]/, '_')
  ENV["#{envName}#{suffix}"] = '1'
  podName = name.split('/')[0]
  ENV["#{podName}#{suffix}"] = '1'
end