class BigKeeper::PodfileDetector

Attributes

main_path[RW]
module_list[RW]

Public Class Methods

get_pod_model(sentence) click to toggle source
# File lib/big_keeper/util/podfile_detector.rb, line 65
def self.get_pod_model(sentence)
  if sentence.include?('pod ')
    pod_model = Podfile_Modle.new(sentence)
    return pod_model
  end
end
new(main_path,module_list) click to toggle source
# File lib/big_keeper/util/podfile_detector.rb, line 13
def initialize(main_path,module_list)
  @module_list = module_list
  @main_path = main_path
end

Public Instance Methods

chose_version(cur_version,temp_version) click to toggle source
# File lib/big_keeper/util/podfile_detector.rb, line 91
def chose_version(cur_version,temp_version)
  # p "cur:#{cur_version},temp:#{temp_version}"
  cur_list = cur_version.split('.')
  temp_list = temp_version.split('.')
  temp_list << 0.to_s if temp_list.size == 2
  if cur_list[0] >= temp_list[0]
    if cur_list[1] >= temp_list[1]
      if cur_list[2] > temp_list[2]
        return cur_version
      end
      return temp_version
    end
    return temp_version
  end
  return temp_version
end
deal_lock_file(main_path,deal_list) click to toggle source
# File lib/big_keeper/util/podfile_detector.rb, line 39
def deal_lock_file(main_path,deal_list)
    $result = {}
    podfile_lock_lines = File.readlines("#{main_path}/Podfile.lock")
    Logger.highlight("Analyzing Podfile.lock...") unless podfile_lock_lines.size.zero?
    podfile_lock_lines.select do |sentence|
    if sentence.include?('DEPENDENCIES')  #指定范围解析 Dependencies 之前
      break
    end

    temp_sentence = sentence.strip
    pod_name = get_lock_podname(temp_sentence)
    if deal_list.include?(pod_name)
      current_version = $result[pod_name]
      temp_version = get_lock_version(temp_sentence)
      if temp_version != nil
        if current_version != nil
          $result[pod_name] = chose_version(current_version,temp_version)
        else
          $result[pod_name] = temp_version
        end
      end
    end
  end
  return $result
end
deal_podfile_line(sentence) click to toggle source
# File lib/big_keeper/util/podfile_detector.rb, line 28
def deal_podfile_line(sentence)
  if sentence.include?('pod ')
    pod_model = Podfile_Modle.new(sentence)
    if !pod_model.name.empty? && pod_model.configurations != '[\'Debug\']' && pod_model.path == nil && pod_model.tag == nil
          $unlock_pod_list << pod_model.name unless @module_list.include?(pod_model.name)
    end
    pod_model
  end
end
get_lock_podname(sentence) click to toggle source
# File lib/big_keeper/util/podfile_detector.rb, line 80
def get_lock_podname(sentence) #获得pod名称
  match_result = /(\d+.){1,2}\d+/.match(sentence.delete('- :~>='))
  pod_name = match_result.pre_match unless match_result == nil
  return pod_name.delete('()') unless pod_name == nil
end
get_lock_version(sentence) click to toggle source
# File lib/big_keeper/util/podfile_detector.rb, line 86
def get_lock_version(sentence)#获得pod版本号
  match_result = /(\d+.){1,2}\d+/.match(sentence)
  return match_result[0] unless match_result == nil
end
get_pod_name(sentence) click to toggle source
# File lib/big_keeper/util/podfile_detector.rb, line 72
def get_pod_name(sentence)
  pod_model = deal_podfile_line(sentence)
  pod_name = pod_model.name if pod_model != nil && pod_model.configurations.nil
  @unlock_pod_list << pod_name unless @module_list.include pod_name
end
get_unlock_pod_list() click to toggle source
# File lib/big_keeper/util/podfile_detector.rb, line 18
def get_unlock_pod_list
  podfile_lines = File.readlines("#{@main_path}/Podfile")
  Logger.highlight("Analyzing Podfile...") unless podfile_lines.size.zero?
    podfile_lines.collect do |sentence|
    deal_podfile_line(sentence) unless sentence =~(/(\d+.){1,2}\d+/)
    end
    $unlock_pod_list
    # p $unlock_pod_list
end