Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[DirList] Support for excluded patterns

  • Loading branch information...
commit e05cc709e85807762559ab81528152b2db2af2bd 1 parent 9b24e30
@fabiopelosin fabiopelosin authored
View
6 lib/cocoapods/local_pod.rb
@@ -502,7 +502,7 @@ def paths_by_spec(accessor, dir_pattern = nil, specs = nil)
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 @@ def paths_by_spec(accessor, dir_pattern = nil, specs = nil)
#
# @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 @@ def expanded_paths(patterns, dir_pattern = nil)
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
View
26 lib/cocoapods/local_pod/dir_list.rb
@@ -57,8 +57,8 @@ def read_file_system
# @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 @@ def glob(patterns, dir_pattern = nil)
# 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
View
3  lib/cocoapods/specification.rb
@@ -40,6 +40,7 @@ def initialize(parent = nil, name = nil)
# multi-platform attributes
%w[ source_files
+ excluded_patterns
public_header_files
resources
preserve_paths
@@ -136,6 +137,7 @@ def initialize(specification, platform)
end
%w{ source_files=
+ excluded_patterns=
public_header_files=
resource=
resources=
@@ -259,6 +261,7 @@ def available_platforms
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
Please sign in to comment.
Something went wrong with that request. Please try again.