Commit 21e60f91 authored by Fabio Pelosin's avatar Fabio Pelosin

[PathList] Fix for Ruby 2.0.0-preview2.

parent 71983133
...@@ -42,17 +42,15 @@ module Pod ...@@ -42,17 +42,15 @@ module Pod
# @return [void] Reads the file system and populates the files and paths # @return [void] Reads the file system and populates the files and paths
# lists. # lists.
# #
# @todo Ruby 2.0 developer preview 1 does not returns directories
# ending with '/.' and '/..'.
#
def read_file_system def read_file_system
root_length = root.to_s.length+1 root_length = root.to_s.length+1
paths = Dir.glob(root + "**/*", File::FNM_DOTMATCH) paths = Dir.glob(root + "**/*", File::FNM_DOTMATCH)
dirs = paths.select { |path| File.directory?(path) }
dirs = dirs.map { |p| p[root_length..-1] }
paths = paths.map { |p| p[root_length..-1] } paths = paths.map { |p| p[root_length..-1] }
paths = paths.reject { |p| p == '.' || p == '..' } paths = paths.reject { |p| p == '.' || p == '..' }
dirs_entries = paths.select { |path| path.end_with?('/.', '/..') } @files = paths - dirs
@files = paths - dirs_entries @dirs = dirs.map { |d| d.gsub(/\/\.\.?$/,'') }.uniq
@dirs = dirs_entries.map { |d| d.gsub(/\/\.\.?$/,'') }.uniq
end end
# @return [Array<Pathname>] Similar to {glob} but returns the absolute # @return [Array<Pathname>] Similar to {glob} but returns the absolute
......
...@@ -11,12 +11,17 @@ describe Pod::LocalPod::PathList do ...@@ -11,12 +11,17 @@ describe Pod::LocalPod::PathList do
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
files.sort.should == %w| expected = %w[
BananaLib.podspec BananaLib.podspec
Classes Classes/Banana.h Classes/Banana.m Classes/BananaLib.pch Classes/Banana.h
Classes/Banana.m
Classes/BananaLib.pch
README README
Resources Resources/logo-sidebar.png Resources/logo-sidebar.png
sub-dir sub-dir/sub-dir-2 sub-dir/sub-dir-2/somefile.txt | sub-dir/sub-dir-2/somefile.txt
]
files.sort.should == expected
end end
it "creates theh list of the directories" do it "creates theh list of the directories" do
......
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