Class: Xcake::PathClassifier
Overview
This class handles classifing the files and how Xcake should handle them.
Constant Summary collapse
- EXTENSION_MAPPINGS =
{ PBXFrameworksBuildPhase: %w(.a .dylib .so .framework).freeze, PBXHeadersBuildPhase: %w(.h .hpp).freeze, PBXSourcesBuildPhase: %w(.c .m .mm .cpp .swift .xcdatamodeld).freeze, PBXResourcesBuildPhase: %w(.xcassets).freeze }.freeze
Class Method Summary collapse
- .classification_for_path(path) ⇒ Object
- .is_classified?(path) ⇒ Boolean
- .is_inside_classified_container?(path) ⇒ Boolean
- .is_locale_container?(path) ⇒ Boolean
- .should_create_build_phase_for_classification?(classification) ⇒ Boolean
-
.should_include_path?(path) ⇒ Boolean
by subclasses.
Class Method Details
.classification_for_path(path) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/xcake/path_classifier.rb', line 28 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 |
.is_classified?(path) ⇒ Boolean
62 63 64 |
# File 'lib/xcake/path_classifier.rb', line 62 def self.is_classified?(path) EXTENSION_MAPPINGS.values.flatten.any? { |ext| File.extname(path) == ext } end |
.is_inside_classified_container?(path) ⇒ Boolean
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/xcake/path_classifier.rb', line 48 def self.is_inside_classified_container?(path) components = path.split('/') classified_component_index = components.index do |c| is_classified?(c) end if !classified_component_index.nil? classified_component_index < (components.length - 1) else false end end |
.is_locale_container?(path) ⇒ Boolean
43 44 45 46 |
# File 'lib/xcake/path_classifier.rb', line 43 def self.is_locale_container?(path) components = path.split('/') File.extname(components.last) == '.lproj' end |
.should_create_build_phase_for_classification?(classification) ⇒ Boolean
37 38 39 |
# File 'lib/xcake/path_classifier.rb', line 37 def self.should_create_build_phase_for_classification?(classification) classification != :PBXHeadersBuildPhase end |
.should_include_path?(path) ⇒ Boolean
Note:
This should be overidden
by subclasses.
into the project
22 23 24 25 26 |
# File 'lib/xcake/path_classifier.rb', line 22 def self.should_include_path?(path) return false if is_locale_container?(path) return false if is_inside_classified_container?(path) true end |