Commit 148371c1 authored by Fabio Pelosin's avatar Fabio Pelosin

[LocalPod] Always use Pathname::glob.

This patch also removes the custom Pathname.glob based on Dir::glob.

Related #572 and #602.
parent 4d61123b
...@@ -57,12 +57,6 @@ module Pod ...@@ -57,12 +57,6 @@ module Pod
end end
end end
class Pathname
def glob(pattern = '')
Dir.glob((self + pattern).to_s).map { |f| Pathname.new(f) }
end
end
if ENV['COCOA_PODS_ENV'] == 'development' if ENV['COCOA_PODS_ENV'] == 'development'
require 'letters' require 'letters'
require 'awesome_print' require 'awesome_print'
......
...@@ -90,7 +90,7 @@ module Pod ...@@ -90,7 +90,7 @@ module Pod
dirs.each do |dir| dirs.each do |dir|
check_versions(dir) check_versions(dir)
UI.puts "\nLinting spec repo `#{dir.realpath.basename}'\n".yellow UI.puts "\nLinting spec repo `#{dir.realpath.basename}'\n".yellow
podspecs = dir.glob('**/*.podspec') podspecs = Pathname.glob( dir + '**/*.podspec')
invalid_count = 0 invalid_count = 0
podspecs.each do |podspec| podspecs.each do |podspec|
......
...@@ -138,7 +138,7 @@ module Pod ...@@ -138,7 +138,7 @@ module Pod
end end
files << output_path files << output_path
else if (pathname = Pathname.new(path)).directory? else if (pathname = Pathname.new(path)).directory?
files += pathname.glob('**/*.podspec') files += Pathname.glob(pathname + '**/*.podspec')
raise Informative, "No specs found in the current directory." if files.empty? raise Informative, "No specs found in the current directory." if files.empty?
else else
files << (pathname = Pathname.new(path)) files << (pathname = Pathname.new(path))
......
...@@ -163,14 +163,15 @@ module Pod ...@@ -163,14 +163,15 @@ module Pod
# #
# @return [Array<Strings>] The paths that can be deleted. # @return [Array<Strings>] The paths that can be deleted.
# #
# @note The Paths are downcased to prevent issues. See #568. # @note Implementation detail: Don't use Dir#glob as there is an
# unexplained issue (#568, #572 and #602).
# #
def clean_paths def clean_paths
used = used_files cached_used = used_files
files = Dir.glob(root + "**/*", File::FNM_DOTMATCH | File::FNM_CASEFOLD) files = Pathname.glob(root + "**/*", File::FNM_DOTMATCH | File::FNM_CASEFOLD).map(&:to_s)
files.reject! do |candidate| files.reject! do |candidate|
candidate.end_with?('.', '..') || used.any? do |path| candidate.end_with?('.', '..') || cached_used.any? do |path|
path.include?(candidate) || candidate.include?(path) path.include?(candidate) || candidate.include?(path)
end end
end end
......
...@@ -35,7 +35,8 @@ module Pod ...@@ -35,7 +35,8 @@ module Pod
if @path if @path
@path @path
else else
xcodeprojs = config.project_root.glob('*.xcodeproj') puts config.project_root + '*.xcodeproj'
xcodeprojs = Pathname.glob(config.project_root + '*.xcodeproj')
if xcodeprojs.size == 1 if xcodeprojs.size == 1
@path = xcodeprojs.first @path = xcodeprojs.first
end end
......
...@@ -105,7 +105,7 @@ describe "Pod::Podfile" do ...@@ -105,7 +105,7 @@ describe "Pod::Podfile" do
end end
path = config.project_root + 'MyProject.xcodeproj' path = config.project_root + 'MyProject.xcodeproj'
config.project_root.expects(:glob).with('*.xcodeproj').returns([path]) Pathname.expects(:glob).with(config.project_root + '*.xcodeproj').returns([path])
podfile.target_definitions[:default].user_project.path.should == path podfile.target_definitions[:default].user_project.path.should == path
podfile.target_definitions[:another_target].user_project.path.should == path podfile.target_definitions[:another_target].user_project.path.should == path
...@@ -113,7 +113,7 @@ describe "Pod::Podfile" do ...@@ -113,7 +113,7 @@ describe "Pod::Podfile" do
it "assumes the basename of the workspace is the same as the default target's project basename" do it "assumes the basename of the workspace is the same as the default target's project basename" do
path = config.project_root + 'MyProject.xcodeproj' path = config.project_root + 'MyProject.xcodeproj'
config.project_root.expects(:glob).with('*.xcodeproj').returns([path]) Pathname.expects(:glob).with(config.project_root + '*.xcodeproj').returns([path])
Pod::Podfile.new {}.workspace.should == config.project_root + 'MyProject.xcworkspace' Pod::Podfile.new {}.workspace.should == config.project_root + 'MyProject.xcworkspace'
Pod::Podfile.new do Pod::Podfile.new do
...@@ -225,13 +225,13 @@ describe "Pod::Podfile" do ...@@ -225,13 +225,13 @@ describe "Pod::Podfile" do
it "returns a Xcode project found in the working dir when no explicit project is specified" do it "returns a Xcode project found in the working dir when no explicit project is specified" do
xcodeproj1 = config.project_root + '1.xcodeproj' xcodeproj1 = config.project_root + '1.xcodeproj'
config.project_root.expects(:glob).with('*.xcodeproj').returns([xcodeproj1]) Pathname.expects(:glob).with(config.project_root + '*.xcodeproj').returns([xcodeproj1])
Pod::Podfile::UserProject.new.path.should == xcodeproj1 Pod::Podfile::UserProject.new.path.should == xcodeproj1
end end
it "returns `nil' if more than one Xcode project was found in the working when no explicit project is specified" do it "returns `nil' if more than one Xcode project was found in the working when no explicit project is specified" do
xcodeproj1, xcodeproj2 = config.project_root + '1.xcodeproj', config.project_root + '2.xcodeproj' xcodeproj1, xcodeproj2 = config.project_root + '1.xcodeproj', config.project_root + '2.xcodeproj'
config.project_root.expects(:glob).with('*.xcodeproj').returns([xcodeproj1, xcodeproj2]) Pathname.expects(:glob).with(config.project_root + '*.xcodeproj').returns([xcodeproj1, xcodeproj2])
Pod::Podfile::UserProject.new.path.should == nil Pod::Podfile::UserProject.new.path.should == nil
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