Commit 02a59df5 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge pull request #306 from CocoaPods/develop

v0.6.0rc2
parents db4a4d2c d1a9af21
......@@ -2,5 +2,8 @@ language: ruby
rvm:
- 1.8.7
- 1.9.3
# Rubinius in 1.8 mode on Travis does not work. It complains about st_data_t etc in Xcodeproj.
#- rbx-18mode
- rbx-19mode
install: NOEXEC=skip rake travis:setup
script: bundle exec rake spec
......@@ -9,7 +9,7 @@ gem "faraday", ">= 0.8.1"
gem "octokit"
group :development do
gem "xcodeproj", :git => "git://github.com/CocoaPods/Xcodeproj.git"
gem "xcodeproj", :git => "git://github.com/CocoaPods/Xcodeproj.git", :branch => "develop"
gem "bacon"
gem "kicker"
......
GIT
remote: git://github.com/CocoaPods/Xcodeproj.git
revision: 7a8e4564740aea026e4605d678981b2c4cd9690e
revision: c651b216acd6db18128f5b2df77ed04d183e7a3f
branch: develop
specs:
xcodeproj (0.1.0)
xcodeproj (0.2.0.rc2)
GEM
remote: http://rubygems.org/
......@@ -30,7 +31,7 @@ GEM
mocha (>= 0.9.8)
multi_json (1.3.6)
multipart-post (1.1.5)
octokit (1.3.0)
octokit (1.4.0)
addressable (~> 2.2)
faraday (~> 0.8)
faraday_middleware (~> 0.8)
......@@ -44,7 +45,7 @@ GEM
rake (0.9.2.2)
rb-fsevent (0.9.1)
slop (2.4.4)
vcr (2.1.1)
vcr (2.2.0)
webmock (1.8.7)
addressable (>= 2.2.7)
crack (>= 0.1.7)
......
......@@ -64,21 +64,36 @@ module Pod
root.rmtree if exists?
end
# It deletes all the files identified by clean_files, then it removes
# all the empty folders or symlinks.
### Cleaning
# Public: Deletes any path that is not used by the pod.
def clean
clean_files.each { |path| FileUtils.rm_rf(path) }
clean_paths.each { |path| FileUtils.rm_rf(path) }
end
# Get all the directories. Then sort them from the longest
# to the shortest, so a directory will be empty if its
# subdirs where empty. We need to delete the symlinks because
# it might prevent a bundle from being deleted
dirs = Dir.glob(root + "**/*", File::FNM_DOTMATCH)
dirs = dirs.reject { |d| d.end_with?('.', '..') || !File.directory?(d) }.sort_by(&:length).reverse
dirs.each { |d| FileUtils.rm_rf(d) if File.symlink?(d) || (Dir.entries(d) == %w[ . .. ]) }
# Public: Finds the absolute paths, including hidden ones, of the files
# that are not used by the pod and can be safely deleted.
#
# Returns an Array of Strings containing the absolute paths.
def clean_paths
cached_used_paths = used_paths.map{ |path| path.to_s }
files = Dir.glob(root + "**/*", File::FNM_DOTMATCH)
files.reject! do |candidate|
candidate.end_with?('.', '..') ||
cached_used_paths.any? { |path| path.include?(candidate) || candidate.include?(path) }
end
files
end
# File attributes
# Public: Finds all the absolute paths used by pod.
#
# Returns an Array of Pathnames containing the absolute paths.
def used_paths
files = source_files(false) + resources(false) + preserve_paths + [ readme_file, license_file, prefix_header_file ]
files.compact
end
### File attributes
def prefix_header_file
root + top_specification.prefix_header_file if top_specification.prefix_header_file
......@@ -96,15 +111,6 @@ module Pod
chained_expanded_paths(:resources, :relative_to_sandbox => relative)
end
def clean_files
all_files = Dir.glob(root + "**/*", File::FNM_DOTMATCH).map { |f| root + f }.reject { |p| p.directory? }
all_files - used_files
end
def used_files
source_files(false) + resources(false) + preserve_paths + [ readme_file, license_file, prefix_header_file ]
end
# TODO: implement case insensitive search
def preserve_paths
chained_expanded_paths(:preserve_paths) + expanded_paths(%w[ *.podspec notice* NOTICE* CREDITS* ])
......
......@@ -107,7 +107,19 @@ module Pod
@specification, @platform = specification, platform
end
%w{ source_files= resource= resources= xcconfig= framework= frameworks= library= libraries= compiler_flags= deployment_target= dependency }.each do |method|
%w{ source_files=
resource=
resources=
preserve_paths=
preserve_path=
xcconfig=
framework=
frameworks=
library=
libraries=
compiler_flags=
deployment_target=
dependency }.each do |method|
define_method(method) do |args|
@specification._on_platform(@platform) do
@specification.send(method, args)
......@@ -198,9 +210,10 @@ module Pod
pltf_chained_attr_accessor :frameworks, lambda {|value, current| (current << value).flatten }
pltf_chained_attr_accessor :libraries, lambda {|value, current| (current << value).flatten }
alias_method :resource=, :resources=
alias_method :framework=, :frameworks=
alias_method :library=, :libraries=
alias_method :resource=, :resources=
alias_method :preserve_path=, :preserve_paths=
alias_method :framework=, :frameworks=
alias_method :library=, :libraries=
platform_attr_writer :xcconfig, lambda {|value, current| current.tap { |c| c.merge!(value) } }
......
......@@ -38,10 +38,11 @@ describe Pod::LocalPod do
end
it 'returns an expanded list the files to clean' do
clean_files = @pod.clean_files.map { |p| p.to_s }
clean_files.should.include "#{@sandbox.root}/BananaLib/.git/config"
clean_files_without_hidden = clean_files.reject { |p| p.to_s.include?('/.') }
clean_files_without_hidden.should == ["#{@sandbox.root}/BananaLib/sub-dir/sub-dir-2/somefile.txt"]
clean_paths = @pod.clean_paths.map { |p| p.to_s.gsub(/.*Pods\/BananaLib/,'') }
clean_paths.should.include "/.git/config"
# There are some hidden files on Travis
clean_files_without_hidden = clean_paths.reject { |p| p.to_s.include?('/.') }
clean_files_without_hidden.should == %W[ /sub-dir /sub-dir/sub-dir-2 /sub-dir/sub-dir-2/somefile.txt ]
end
it 'returns an expanded list of resources, relative to the sandbox root' 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