Commit 750dfe2a authored by Fabio Pelosin's avatar Fabio Pelosin

Rename DirList to PathList

parent 72dd54bb
## Branch 0.17
###### TODO
- Add `s.exclude_source_files` and related attributes to the specification class.
###### Enhancements
- Added PathList class.
- Added Podfile to the Pods project.
[#476](https://github.com/CocoaPods/CocoaPods/issues/476)
## Master ## Master
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.16.0.rc2...master)[Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.4.0.rc1...master) [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.16.0.rc2...master)[Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.4.0.rc1...master)
......
...@@ -21,7 +21,7 @@ module Pod ...@@ -21,7 +21,7 @@ module Pod
# returns absolute paths. # returns absolute paths.
# #
class LocalPod class LocalPod
autoload :DirList, 'cocoapods/local_pod/dir_list' autoload :PathList, 'cocoapods/local_pod/path_list'
# @return [Specification] The specification that describes the pod. # @return [Specification] The specification that describes the pod.
# #
...@@ -95,8 +95,8 @@ module Pod ...@@ -95,8 +95,8 @@ module Pod
@sandbox.root + top_specification.name @sandbox.root + top_specification.name
end end
def dir_list def path_list
@dir_list ||= DirList.new(root) @path_list ||= PathList.new(root)
end end
# @return [String] A string representation of the pod which indicates if # @return [String] A string representation of the pod which indicates if
...@@ -161,7 +161,7 @@ module Pod ...@@ -161,7 +161,7 @@ module Pod
def clean! def clean!
clean_paths.each { |path| FileUtils.rm_rf(path) } clean_paths.each { |path| FileUtils.rm_rf(path) }
@cleaned = true @cleaned = true
dir_list.read_file_system path_list.read_file_system
end end
# Finds the absolute paths, including hidden ones, of the files # Finds the absolute paths, including hidden ones, of the files
...@@ -577,7 +577,7 @@ module Pod ...@@ -577,7 +577,7 @@ module Pod
result = [] result = []
result << dir_list.glob(glob_patterns, dir_pattern, exclude_patterns) result << path_list.glob(glob_patterns, dir_pattern, exclude_patterns)
result << file_lists.map do |file_list| result << file_lists.map do |file_list|
file_list.prepend_patterns(root) file_list.prepend_patterns(root)
......
module Pod module Pod
class LocalPod class LocalPod
# The {DirList} class is designed to perform multiple glob matches against # The {PathList} class is designed to perform multiple glob matches against
# a given directory. Basically, it generates a list of all the children # a given directory. Basically, it generates a list of all the children
# paths and matches the globs patterns against them, resulting in just # paths and matches the globs patterns against them, resulting in just
# one access to the file system. # one access to the file system.
# #
# @note A {DirList} once it has generated the list of the paths this is # @note A {PathList} once it has generated the list of the paths this is
# updated only if explicitly requested by calling # updated only if explicitly requested by calling
# {DirList#read_file_system} # {PathList#read_file_system}
# #
class DirList class PathList
# @return [Pathname] The root of the list whose files and directories # @return [Pathname] The root of the list whose files and directories
# are used to perform the matching operations. # are used to perform the matching operations.
# #
attr_accessor :root attr_accessor :root
# @param [Pathname] root The root of the DirList. # @param [Pathname] root The root of the PathList.
# #
def initialize(root) def initialize(root)
@root = root @root = root
...@@ -150,6 +150,6 @@ module Pod ...@@ -150,6 +150,6 @@ module Pod
patterns patterns
end end
end end
end # DirList end # PathList
end # LocalPod end # LocalPod
end # Pod end # Pod
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::LocalPod::DirList do describe Pod::LocalPod::PathList do
before do before do
@dir_list = Pod::LocalPod::DirList.new(fixture('banana-lib')) @path_list = Pod::LocalPod::PathList.new(fixture('banana-lib'))
end end
it "creates the list of all the files" do it "creates the list of all the files" do
files = @dir_list.files files = @path_list.files
files.reject! do |f| files.reject! do |f|
f.include?('libPusher') || f.include?('.git') || f.include?('DS_Store') f.include?('libPusher') || f.include?('.git') || f.include?('DS_Store')
end end
...@@ -20,7 +20,7 @@ describe Pod::LocalPod::DirList do ...@@ -20,7 +20,7 @@ describe Pod::LocalPod::DirList do
end end
it "creates theh list of the directories" do it "creates theh list of the directories" do
dirs = @dir_list.dirs dirs = @path_list.dirs
dirs.reject! do |f| dirs.reject! do |f|
f.include?('libPusher') || f.include?('.git') f.include?('libPusher') || f.include?('.git')
end end
...@@ -28,55 +28,55 @@ describe Pod::LocalPod::DirList do ...@@ -28,55 +28,55 @@ describe Pod::LocalPod::DirList do
end end
it "detects a directory" do it "detects a directory" do
@dir_list.directory?('classes').should == true @path_list.directory?('classes').should == true
end end
it "doesn't reports as a directory a file" do it "doesn't reports as a directory a file" do
@dir_list.directory?('Classes/Banana.m').should == false @path_list.directory?('Classes/Banana.m').should == false
end end
it "can glob the root for a given pattern" do it "can glob the root for a given pattern" do
paths = @dir_list.relative_glob('Classes/*.{h,m}').map(&:to_s) paths = @path_list.relative_glob('Classes/*.{h,m}').map(&:to_s)
paths.should == %w| Classes/Banana.h Classes/Banana.m | paths.should == %w| Classes/Banana.h Classes/Banana.m |
end end
it "supports the `**` glob pattern" do it "supports the `**` glob pattern" do
paths = @dir_list.relative_glob('Classes/**/*.{h,m}').map(&:to_s) paths = @path_list.relative_glob('Classes/**/*.{h,m}').map(&:to_s)
paths.should == %w| Classes/Banana.h Classes/Banana.m | paths.should == %w| Classes/Banana.h Classes/Banana.m |
end end
it "supports an optional pattern for globbing directories" do it "supports an optional pattern for globbing directories" do
paths = @dir_list.relative_glob('Classes', '*.{h,m}').map(&:to_s) paths = @path_list.relative_glob('Classes', '*.{h,m}').map(&:to_s)
paths.should == %w| Classes/Banana.h Classes/Banana.m | paths.should == %w| Classes/Banana.h Classes/Banana.m |
end end
it "can return the absolute paths from glob" do it "can return the absolute paths from glob" do
paths = @dir_list.glob('Classes/*.{h,m}') paths = @path_list.glob('Classes/*.{h,m}')
paths.all? { |p| p.absolute? }.should == true paths.all? { |p| p.absolute? }.should == true
end end
it "can return the relative paths from glob" do it "can return the relative paths from glob" do
paths = @dir_list.relative_glob('Classes/*.{h,m}') paths = @path_list.relative_glob('Classes/*.{h,m}')
paths.any? { |p| p.absolute? }.should == false paths.any? { |p| p.absolute? }.should == false
end end
it "expands a pattern into all the combinations of Dir#glob literals" do it "expands a pattern into all the combinations of Dir#glob literals" do
patterns = @dir_list.dir_glob_equivalent_patterns('{file1,file2}.{h,m}') patterns = @path_list.dir_glob_equivalent_patterns('{file1,file2}.{h,m}')
patterns.sort.should == %w| file1.h file1.m file2.h file2.m | patterns.sort.should == %w| file1.h file1.m file2.h file2.m |
end end
it "returns the original patter if there are no Dir#glob expansions" do it "returns the original patter if there are no Dir#glob expansions" do
patterns = @dir_list.dir_glob_equivalent_patterns('file*.*') patterns = @path_list.dir_glob_equivalent_patterns('file*.*')
patterns.sort.should == %w| file*.* | patterns.sort.should == %w| file*.* |
end end
it "expands `**`" do it "expands `**`" do
patterns = @dir_list.dir_glob_equivalent_patterns('Classes/**/file.m') patterns = @path_list.dir_glob_equivalent_patterns('Classes/**/file.m')
patterns.sort.should == %w| Classes/**/file.m Classes/file.m | patterns.sort.should == %w| Classes/**/file.m Classes/file.m |
end end
it "supports a combination of `**` and literals" do it "supports a combination of `**` and literals" do
patterns = @dir_list.dir_glob_equivalent_patterns('Classes/**/file.{h,m}') patterns = @path_list.dir_glob_equivalent_patterns('Classes/**/file.{h,m}')
patterns.sort.should == %w| Classes/**/file.h Classes/**/file.m Classes/file.h Classes/file.m | patterns.sort.should == %w| Classes/**/file.h Classes/**/file.m Classes/file.h Classes/file.m |
end end
end end
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