module Pod

Public Class Methods

inject_local_path(name, requirements) click to toggle source

注入本地路径

# File lib/helper/pod.rb, line 15
def self.inject_local_path(name, requirements)
  local_path = nil
  local_root = ENV['POD_LOCAL_ROOT']
  if !local_root
    UI.warn '环境变量中未发现 POD_LOCAL_ROOT 定义'
  elsif local_root.length
    local_path = File.join(local_root, repo_name(name))
  end
  if local_path
    cfg = requirements.pop
    if cfg.is_a?(Hash)
      cfg.reject! { |key, value|
        [:git, :branch, :tag, :commit, :podspec].include?(key)
      }
    else
      cfg = {:path => local_path}
    end
    cfg.merge!({:path => local_path})
    requirements.push(cfg)
  end
end
inject_remote_git(name, requirements) click to toggle source

注入远程仓库地址

# File lib/helper/pod.rb, line 38
def self.inject_remote_git(name, requirements)
  name = name.split('/').first
  options = requirements.pop
  options[:git] = "git@code.kaipao.cc:ios-team/components/#{name}.git"
  requirements.push(options)
end
repo_name(name) click to toggle source
# File lib/helper/pod.rb, line 5
def self.repo_name(name)
  pos = name.index('/')
  ret = pos == nil ? name : name[0, pos]
  if ret == 'ProtocolBuffers'
    ret = 'protobuf-objc'
  end
  ret
end