Commit e05cc709 authored by Fabio Pelosin's avatar Fabio Pelosin

[DirList] Support for excluded patterns

parent 9b24e307
...@@ -502,7 +502,7 @@ module Pod ...@@ -502,7 +502,7 @@ module Pod
specs = specs.sort_by { |s| s.name.length } specs = specs.sort_by { |s| s.name.length }
specs.each do |spec| specs.each do |spec|
paths = expanded_paths(spec.send(accessor), dir_pattern) paths = expanded_paths(spec.send(accessor), dir_pattern, spec.excluded_patterns)
unless paths.empty? unless paths.empty?
paths_by_spec[spec] = paths - processed_paths paths_by_spec[spec] = paths - processed_paths
processed_paths += paths processed_paths += paths
...@@ -527,7 +527,7 @@ module Pod ...@@ -527,7 +527,7 @@ module Pod
# #
# @return [Array<Pathname>] A list of the paths. # @return [Array<Pathname>] A list of the paths.
# #
def expanded_paths(patterns, dir_pattern = nil) def expanded_paths(patterns, dir_pattern = nil, exclude_patterns = nil)
unless exists? unless exists?
raise Informative, "[Local Pod] Attempt to resolve paths for nonexistent pod.\n" \ raise Informative, "[Local Pod] Attempt to resolve paths for nonexistent pod.\n" \
"\tSpecifications: #{@specifications.inspect}\n" \ "\tSpecifications: #{@specifications.inspect}\n" \
...@@ -547,7 +547,7 @@ module Pod ...@@ -547,7 +547,7 @@ module Pod
file_list.prepend_patterns(root) file_list.prepend_patterns(root)
file_list.glob file_list.glob
end end
result << dir_list.glob(glob_patterns, dir_pattern) result << dir_list.glob(glob_patterns, dir_pattern, exclude_patterns)
result.flatten.compact.uniq result.flatten.compact.uniq
end end
......
...@@ -57,8 +57,8 @@ module Pod ...@@ -57,8 +57,8 @@ module Pod
# @return [Array<Pathname>] Similar to {glob} but returns the absolute # @return [Array<Pathname>] Similar to {glob} but returns the absolute
# paths. # paths.
# #
def glob(patterns, dir_pattern = nil) def glob(patterns, dir_pattern = nil, exclude_patterns = nil)
relative_glob(patterns, dir_pattern).map {|p| root + p } relative_glob(patterns, dir_pattern, exclude_patterns).map {|p| root + p }
end end
# @return [Array<Pathname>] The list of the relative paths that are # @return [Array<Pathname>] The list of the relative paths that are
...@@ -71,17 +71,27 @@ module Pod ...@@ -71,17 +71,27 @@ module Pod
# pattern, if this one is the path of a # pattern, if this one is the path of a
# directory. # directory.
# #
def relative_glob(patterns, dir_pattern = nil) def relative_glob(patterns, dir_pattern = nil, exclude_patterns = nil)
return [] if patterns.empty?
patterns = [ patterns ] if patterns.is_a? String patterns = [ patterns ] if patterns.is_a? String
list = patterns.map do |pattern| list = patterns.map do |pattern|
pattern += '/' + dir_pattern if directory?(pattern) && dir_pattern if pattern.is_a?(String)
expanded_patterns = dir_glob_equivalent_patterns(pattern) pattern += '/' + dir_pattern if directory?(pattern) && dir_pattern
files.select do |path| expanded_patterns = dir_glob_equivalent_patterns(pattern)
expanded_patterns.any? do |p| files.select do |path|
File.fnmatch(p, path, File::FNM_CASEFOLD | File::FNM_PATHNAME) expanded_patterns.any? do |p|
File.fnmatch(p, path, File::FNM_CASEFOLD | File::FNM_PATHNAME)
end
end end
else
pattern.to_s.cyan
files.select { |path| path.match(pattern) }
end end
end.flatten end.flatten
if exclude_patterns
excluded = relative_glob(exclude_patterns)
list = exclude_patterns ? list - excluded : list
end
list.map { |path| Pathname.new(path) } list.map { |path| Pathname.new(path) }
end end
......
...@@ -40,6 +40,7 @@ module Pod ...@@ -40,6 +40,7 @@ module Pod
# multi-platform attributes # multi-platform attributes
%w[ source_files %w[ source_files
excluded_patterns
public_header_files public_header_files
resources resources
preserve_paths preserve_paths
...@@ -136,6 +137,7 @@ module Pod ...@@ -136,6 +137,7 @@ module Pod
end end
%w{ source_files= %w{ source_files=
excluded_patterns=
public_header_files= public_header_files=
resource= resource=
resources= resources=
...@@ -259,6 +261,7 @@ module Pod ...@@ -259,6 +261,7 @@ module Pod
top_attr_accessor :prefix_header_contents top_attr_accessor :prefix_header_contents
pltf_chained_attr_accessor :source_files, lambda {|value, current| pattern_list(value) } pltf_chained_attr_accessor :source_files, lambda {|value, current| pattern_list(value) }
pltf_chained_attr_accessor :excluded_patterns, lambda {|value, current| pattern_list(value) }
pltf_chained_attr_accessor :public_header_files, lambda {|value, current| pattern_list(value) } pltf_chained_attr_accessor :public_header_files, lambda {|value, current| pattern_list(value) }
pltf_chained_attr_accessor :resources, lambda {|value, current| pattern_list(value) } pltf_chained_attr_accessor :resources, lambda {|value, current| pattern_list(value) }
pltf_chained_attr_accessor :preserve_paths, lambda {|value, current| pattern_list(value) } # Paths that should not be cleaned pltf_chained_attr_accessor :preserve_paths, lambda {|value, current| pattern_list(value) } # Paths that should not be cleaned
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment