Commit e05cc709 authored by Fabio Pelosin's avatar Fabio Pelosin

[DirList] Support for excluded patterns

parent 9b24e307
......@@ -502,7 +502,7 @@ module Pod
specs = specs.sort_by { |s| s.name.length }
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?
paths_by_spec[spec] = paths - processed_paths
processed_paths += paths
......@@ -527,7 +527,7 @@ module Pod
#
# @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?
raise Informative, "[Local Pod] Attempt to resolve paths for nonexistent pod.\n" \
"\tSpecifications: #{@specifications.inspect}\n" \
......@@ -547,7 +547,7 @@ module Pod
file_list.prepend_patterns(root)
file_list.glob
end
result << dir_list.glob(glob_patterns, dir_pattern)
result << dir_list.glob(glob_patterns, dir_pattern, exclude_patterns)
result.flatten.compact.uniq
end
......
......@@ -57,8 +57,8 @@ module Pod
# @return [Array<Pathname>] Similar to {glob} but returns the absolute
# paths.
#
def glob(patterns, dir_pattern = nil)
relative_glob(patterns, dir_pattern).map {|p| root + p }
def glob(patterns, dir_pattern = nil, exclude_patterns = nil)
relative_glob(patterns, dir_pattern, exclude_patterns).map {|p| root + p }
end
# @return [Array<Pathname>] The list of the relative paths that are
......@@ -71,17 +71,27 @@ module Pod
# pattern, if this one is the path of a
# 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
list = patterns.map do |pattern|
pattern += '/' + dir_pattern if directory?(pattern) && dir_pattern
expanded_patterns = dir_glob_equivalent_patterns(pattern)
files.select do |path|
expanded_patterns.any? do |p|
File.fnmatch(p, path, File::FNM_CASEFOLD | File::FNM_PATHNAME)
if pattern.is_a?(String)
pattern += '/' + dir_pattern if directory?(pattern) && dir_pattern
expanded_patterns = dir_glob_equivalent_patterns(pattern)
files.select do |path|
expanded_patterns.any? do |p|
File.fnmatch(p, path, File::FNM_CASEFOLD | File::FNM_PATHNAME)
end
end
else
pattern.to_s.cyan
files.select { |path| path.match(pattern) }
end
end.flatten
if exclude_patterns
excluded = relative_glob(exclude_patterns)
list = exclude_patterns ? list - excluded : list
end
list.map { |path| Pathname.new(path) }
end
......
......@@ -40,6 +40,7 @@ module Pod
# multi-platform attributes
%w[ source_files
excluded_patterns
public_header_files
resources
preserve_paths
......@@ -136,6 +137,7 @@ module Pod
end
%w{ source_files=
excluded_patterns=
public_header_files=
resource=
resources=
......@@ -259,6 +261,7 @@ module Pod
top_attr_accessor :prefix_header_contents
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 :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
......
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