class Bullseye::Checker

Constants

ROOT_PATH

Public Class Methods

new(options = {}) click to toggle source
# File lib/bullseye/checker.rb, line 10
def initialize(options = {})
  @target_name = options.fetch(:target)

  @project_path = options.fetch(:project)
  @project_path = @project_path.gsub /\/$/, ''

  @excluded_directories = options.fetch(:exclude, [])
  @excluded_directories.collect! {|item| item.strip}

  @included_directories = options.fetch(:include, [])
  @included_directories.collect! {|item| item.strip}

  if !@project_path.match(/\.xcodeproj{1}/)
    @project_path += '.xcodeproj'
  end

  @project = Xcodeproj::Project.open @project_path
end

Public Instance Methods

begin() click to toggle source
# File lib/bullseye/checker.rb, line 29
def begin
  names = source_names + resource_names
  names = names.map {|n| n.sub(/.*\/+/, "") }
  files = project_files
  files.delete_if { |file| names.include?(file) }

  files
end
project_files() click to toggle source
# File lib/bullseye/checker.rb, line 38
def project_files
  file_names = []

  if /\/\w/ =~ @project_path
    path_name = @project_path.gsub /(\w*\.\w*)$/, ''
  else
    path_name = ROOT_PATH
  end

  Find.find(path_name) do |path|
    @excluded_directories.each do |dir|
      if path.to_s.include? dir
        Find.prune
      end
    end

    unless @included_directories.any? {|dir| path == ROOT_PATH || path.include?(dir)}
      Find.prune
    end

    file_names << strip_path_from_name(path) if path =~ /.*\.(xib|storyboard|m|swift)$/
  end

  file_names
end
resource_names() click to toggle source
# File lib/bullseye/checker.rb, line 68
def resource_names
  names = target.resources_build_phase.files_references
  names.keep_if { |file| file.kind_of?(PBXFileReference) && !file.path.nil? && file.path =~ /[a-zA-Z0-9\-\_\~\/]*\.*(m|xib|storyboard|swift)$/ }
  names.map { |n| strip_path_from_name("#{n.path}") }
end
source_names() click to toggle source
# File lib/bullseye/checker.rb, line 74
def source_names
  references = target.source_build_phase.files_references
  references.keep_if do |r|
    r.kind_of?(PBXFileReference) && !r.path.nil?
  end

  references.map { |r| strip_path_from_name("#{r.path}") }
end
target() click to toggle source
# File lib/bullseye/checker.rb, line 64
def target
  @target ||= @project.targets.select { |target| target.name == @target_name }.first
end

Private Instance Methods

strip_path_from_name(name) click to toggle source
# File lib/bullseye/checker.rb, line 85
def strip_path_from_name(name)
  name.gsub(/.*\/+/, "")
end