Class: Xcake::TargetFileReferenceGenerator
- Defined in:
- lib/xcake/generator/target_file_reference_generator.rb
Overview
This generator processes the files to add to the project from the ‘include_files` and `exclude_files`
Instance Attribute Summary
Attributes inherited from Generator
Class Method Summary collapse
Instance Method Summary collapse
-
#get_cleaned_paths(reg_exp) ⇒ Object
This method will return an array of files based on the passed regular Exp NOTE:- directories will not be included in the array.
-
#initialize(context) ⇒ TargetFileReferenceGenerator
constructor
A new instance of TargetFileReferenceGenerator.
- #visit_target(target) ⇒ Object
Methods inherited from Generator
Methods included from Visitor
Methods included from Plugin
Methods included from Dependency
Constructor Details
#initialize(context) ⇒ TargetFileReferenceGenerator
Returns a new instance of TargetFileReferenceGenerator.
8 9 10 |
# File 'lib/xcake/generator/target_file_reference_generator.rb', line 8 def initialize(context) @context = context end |
Class Method Details
.dependencies ⇒ Object
12 13 14 |
# File 'lib/xcake/generator/target_file_reference_generator.rb', line 12 def self.dependencies [TargetGenerator] end |
Instance Method Details
#get_cleaned_paths(reg_exp) ⇒ Object
This method will return an array of files based on the passed regular Exp NOTE:- directories will not be included in the array
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/xcake/generator/target_file_reference_generator.rb', line 18 def get_cleaned_paths(reg_exp) paths_without_directories = Dir.glob(reg_exp).reject do |f| file_ext = File.extname(f) disallowed_extensions = [ '.xcdatamodeld', '.xcassets', '.framework', '.bundle' ] File.directory?(f) && !disallowed_extensions.include?(file_ext) end paths = paths_without_directories.map do |f| Pathname.new(f).cleanpath.to_s end paths end |
#visit_target(target) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/xcake/generator/target_file_reference_generator.rb', line 36 def visit_target(target) paths_to_include = get_cleaned_paths(target.include_files) paths_to_exclude = get_cleaned_paths(target.exclude_files) paths = paths_to_include - paths_to_exclude paths.each do |p| include_file_for_path_and_target(p, target) if PathClassifier.should_include_path?(p) end end |