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
[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
# returns absolute paths.
#
class LocalPod
autoload :DirList, 'cocoapods/local_pod/dir_list'
autoload :PathList, 'cocoapods/local_pod/path_list'
# @return [Specification] The specification that describes the pod.
#
......@@ -95,8 +95,8 @@ module Pod
@sandbox.root + top_specification.name
end
def dir_list
@dir_list ||= DirList.new(root)
def path_list
@path_list ||= PathList.new(root)
end
# @return [String] A string representation of the pod which indicates if
......@@ -161,7 +161,7 @@ module Pod
def clean!
clean_paths.each { |path| FileUtils.rm_rf(path) }
@cleaned = true
dir_list.read_file_system
path_list.read_file_system
end
# Finds the absolute paths, including hidden ones, of the files
......@@ -577,7 +577,7 @@ module Pod
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|
file_list.prepend_patterns(root)
......
module Pod
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
# paths and matches the globs patterns against them, resulting in just
# 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
# {DirList#read_file_system}
# {PathList#read_file_system}
#
class DirList
class PathList
# @return [Pathname] The root of the list whose files and directories
# are used to perform the matching operations.
#
attr_accessor :root
# @param [Pathname] root The root of the DirList.
# @param [Pathname] root The root of the PathList.
#
def initialize(root)
@root = root
......@@ -150,6 +150,6 @@ module Pod
patterns
end
end
end # DirList
end # PathList
end # LocalPod
end # Pod
require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::LocalPod::DirList do
describe Pod::LocalPod::PathList do
before do
@dir_list = Pod::LocalPod::DirList.new(fixture('banana-lib'))
@path_list = Pod::LocalPod::PathList.new(fixture('banana-lib'))
end
it "creates the list of all the files" do
files = @dir_list.files
files = @path_list.files
files.reject! do |f|
f.include?('libPusher') || f.include?('.git') || f.include?('DS_Store')
end
......@@ -20,7 +20,7 @@ describe Pod::LocalPod::DirList do
end
it "creates theh list of the directories" do
dirs = @dir_list.dirs
dirs = @path_list.dirs
dirs.reject! do |f|
f.include?('libPusher') || f.include?('.git')
end
......@@ -28,55 +28,55 @@ describe Pod::LocalPod::DirList do
end
it "detects a directory" do
@dir_list.directory?('classes').should == true
@path_list.directory?('classes').should == true
end
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
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 |
end
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 |
end
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 |
end
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
end
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
end
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 |
end
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*.* |
end
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 |
end
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 |
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