class Djutils::Inspector

Constants

FILES_MISMATCHED
INSPECT_SUCCESS
PROJECT_NOT_FOUND
TARGET_NOT_FOUND

Public Class Methods

inspect_targets(proj_path) click to toggle source
# File lib/djutils/inspector.rb, line 12
def self.inspect_targets(proj_path)

  if !proj_path
    proj_path = File.join(Dir.pwd, '东家.xcodeproj')
  end

  if !File.exist?(proj_path)
    puts "Error: #{proj_path} not found."
    return PROJECT_NOT_FOUND
  end

  proj = Xcodeproj::Project.open(proj_path)

  target_dongjia = nil
  target_dongjia_ent = nil

  proj.targets.each do |target|
    if target.name == '东家'
        target_dongjia = target
    elsif target.name == '东家企业版'
        target_dongjia_ent = target
    end
  end

  if target_dongjia == nil or target_dongjia_ent == nil
    puts "Target校验错误"
    return TARGET_NOT_FOUND
  end

  mismatched_files = []

  for file_ref in target_dongjia.source_build_phase.files_references
    if !target_dongjia_ent.source_build_phase.include?(file_ref)
        mismatched_files << file_ref.display_name
    end
  end

  if mismatched_files.size > 0
    puts "\n\n#{mismatched_files}\n\n"
    return FILES_MISMATCHED
  end

  INSPECT_SUCCESS

end