Commit 0e074f75 authored by Marc Boquet's avatar Marc Boquet

[PathList] Another try at the re-implementation of read_file_system

parent 768b2c57
...@@ -50,20 +50,12 @@ module Pod ...@@ -50,20 +50,12 @@ module Pod
unless root.exist? unless root.exist?
raise Informative, "Attempt to read non existent folder `#{root}`." raise Informative, "Attempt to read non existent folder `#{root}`."
end end
files = []
dirs = []
escaped_root = escape_path_for_glob(root) escaped_root = escape_path_for_glob(root)
paths = Pathname.glob(escaped_root + '**/*', File::FNM_DOTMATCH) do |path| absolute_paths = Pathname.glob(escaped_root + '**/*', File::FNM_DOTMATCH)
next if path.basename.to_s.match /\.\.?$/ dirs_and_files = absolute_paths.reject { |path| path.basename.to_s =~ /^\.\.?$/ }
relative_path = path.relative_path_from(root) dirs, files = dirs_and_files.partition(&:directory?)
if path.directory? @dirs = dirs.map { |dir| dir.relative_path_from(root).to_s }.sort_by(&:upcase)
dirs << relative_path.to_s @files = files.map { |file| file.relative_path_from(root).to_s }.sort_by(&:upcase)
else
files << relative_path.to_s
end
end
@files = files.sort_by(&:upcase)
@dirs = dirs.sort_by(&:upcase)
@glob_cache = {} @glob_cache = {}
end end
......
...@@ -168,14 +168,14 @@ module Pod ...@@ -168,14 +168,14 @@ module Pod
describe 'Reading file system' do describe 'Reading file system' do
it 'orders paths case insensitively' do it 'orders paths case insensitively' do
root = fixture('banana-lib') root = fixture('banana-unordered')
# Let Pathname.glob result be ordered case-sensitively # Let Pathname.glob result be ordered case-sensitively
Pathname.stubs(:glob).multiple_yields(Pathname.new("#{root}/Classes/NSFetchRequest+Banana.h"), Pathname.stubs(:glob).returns([Pathname.new("#{root}/Classes/NSFetchRequest+Banana.h"),
Pathname.new("#{root}/Classes/NSFetchedResultsController+Banana.h")) Pathname.new("#{root}/Classes/NSFetchedResultsController+Banana.h")])
File.stubs(:directory?).returns(false) File.stubs(:directory?).returns(false)
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(root)
path_list.files.should == %w(Classes/NSFetchedResultsController+Banana.h Classes/NSFetchRequest+Banana.h) path_list.files.should == %w(Classes/NSFetchedResultsController+Banana.h Classes/NSFetchRequest+Banana.h)
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