class Xcake::PathClassifier

This class handles classifing the files and how Xcake should handle them.

Constants

EXTENSION_MAPPINGS

Public Class Methods

classification_for_path(path) click to toggle source
# File lib/xcake/path_classifier.rb, line 29
def self.classification_for_path(path)
  classification = EXTENSION_MAPPINGS.detect do |_key, ext_group|
    ext_group.any? { |ext| File.extname(path) == ext }
  end

  return :PBXResourcesBuildPhase if classification.nil?

  classification.first
end
should_create_build_phase_for_classification?(classification) click to toggle source
# File lib/xcake/path_classifier.rb, line 39
def self.should_create_build_phase_for_classification?(classification)
  classification != :PBXHeadersBuildPhase
end
should_include_path?(path) click to toggle source

@note This should be overidden by subclasses.

@param [String] the path

@return [Boolean] true if classifier thinks the path should be included into the project

# File lib/xcake/path_classifier.rb, line 22
def self.should_include_path?(path)
  return false if locale_container?(path)
  return false if inside_classified_container?(path)

  true
end

Private Class Methods

classified?(path) click to toggle source
# File lib/xcake/path_classifier.rb, line 65
def classified?(path)
  EXTENSION_MAPPINGS.values.flatten.any? { |ext| File.extname(path) == ext }
end
inside_classified_container?(path) click to toggle source
# File lib/xcake/path_classifier.rb, line 51
def inside_classified_container?(path)
  components = path.split('/')

  classified_component_index = components.index do |c|
    classified?(c)
  end

  if !classified_component_index.nil?
    classified_component_index < (components.length - 1)
  else
    false
  end
end
locale_container?(path) click to toggle source
# File lib/xcake/path_classifier.rb, line 46
def locale_container?(path)
  components = path.split('/')
  File.extname(components.last) == '.lproj'
end