Skip to content

Commit

Permalink
Rename DirList to PathList
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Oct 24, 2012
1 parent 72dd54b commit 750dfe2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 26 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,16 @@
## 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)

Expand Down
10 changes: 5 additions & 5 deletions lib/cocoapods/local_pod.rb
Expand Up @@ -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.
#
Expand Down Expand Up @@ -95,8 +95,8 @@ def root
@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
Expand Down Expand Up @@ -161,7 +161,7 @@ def local?
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
Expand Down Expand Up @@ -577,7 +577,7 @@ def expanded_paths(patterns, dir_pattern = nil, exclude_patterns = nil)

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)
Expand Down
@@ -1,23 +1,23 @@
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
Expand Down Expand Up @@ -150,6 +150,6 @@ def dir_glob_equivalent_patterns(pattern)
patterns
end
end
end # DirList
end # PathList
end # LocalPod
end # Pod
@@ -1,13 +1,13 @@
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
Expand All @@ -20,63 +20,63 @@
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
dirs.sort.should == %w| Classes Resources sub-dir sub-dir/sub-dir-2 |
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

0 comments on commit 750dfe2

Please sign in to comment.