mirror of
https://github.com/zhigang1992/CocoaPods.git
synced 2026-01-12 17:12:54 +08:00
[LocalPod] Always use Pathname::glob.
This patch also removes the custom Pathname.glob based on Dir::glob. Related #572 and #602.
This commit is contained in:
@@ -57,12 +57,6 @@ module Pod
|
||||
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'
|
||||
require 'letters'
|
||||
require 'awesome_print'
|
||||
|
||||
@@ -90,7 +90,7 @@ module Pod
|
||||
dirs.each do |dir|
|
||||
check_versions(dir)
|
||||
UI.puts "\nLinting spec repo `#{dir.realpath.basename}'\n".yellow
|
||||
podspecs = dir.glob('**/*.podspec')
|
||||
podspecs = Pathname.glob( dir + '**/*.podspec')
|
||||
invalid_count = 0
|
||||
|
||||
podspecs.each do |podspec|
|
||||
|
||||
@@ -138,7 +138,7 @@ module Pod
|
||||
end
|
||||
files << output_path
|
||||
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?
|
||||
else
|
||||
files << (pathname = Pathname.new(path))
|
||||
|
||||
@@ -163,14 +163,15 @@ module Pod
|
||||
#
|
||||
# @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
|
||||
used = used_files
|
||||
files = Dir.glob(root + "**/*", File::FNM_DOTMATCH | File::FNM_CASEFOLD)
|
||||
cached_used = used_files
|
||||
files = Pathname.glob(root + "**/*", File::FNM_DOTMATCH | File::FNM_CASEFOLD).map(&:to_s)
|
||||
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,8 @@ module Pod
|
||||
if @path
|
||||
@path
|
||||
else
|
||||
xcodeprojs = config.project_root.glob('*.xcodeproj')
|
||||
puts config.project_root + '*.xcodeproj'
|
||||
xcodeprojs = Pathname.glob(config.project_root + '*.xcodeproj')
|
||||
if xcodeprojs.size == 1
|
||||
@path = xcodeprojs.first
|
||||
end
|
||||
|
||||
@@ -105,7 +105,7 @@ describe "Pod::Podfile" do
|
||||
end
|
||||
|
||||
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[:another_target].user_project.path.should == path
|
||||
@@ -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
|
||||
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 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
|
||||
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
|
||||
end
|
||||
|
||||
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'
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user