Commit a751ba23 authored by Luke Redpath's avatar Luke Redpath

Some minor clean-up and refactoring.

parent 7ddf9227
......@@ -77,13 +77,10 @@ module Pod
end
def install!
@sandbox.prepare_for_install
puts "Installing dependencies of: #{@podfile.defined_in_file}" if config.verbose?
pods = install_dependencies!
root = config.project_pods_root
headers_symlink_root = config.headers_symlink_root
# Clean old header symlinks
FileUtils.rm_r(headers_symlink_root, :secure => true) if File.exists?(headers_symlink_root)
puts "Generating support files" unless config.silent?
target_installers.each do |target_installer|
......@@ -94,14 +91,21 @@ module Pod
puts "* Running post install hooks" if config.verbose?
# Post install hooks run _before_ saving of project, so that they can alter it before saving.
run_post_install_hooks
puts "* Writing Xcode project file to `#{@sandbox.project_path}'" if config.verbose?
project.save_as(@sandbox.project_path)
end
def run_post_install_hooks
# we loop over target installers instead of pods, because we yield the target installer
# to the spec post install hook.
target_installers.each do |target_installer|
target_installer.build_specifications.each { |spec| spec.post_install(target_installer) }
end
@podfile.post_install!(self)
projpath = File.join(root, 'Pods.xcodeproj')
puts "* Writing Xcode project file to `#{projpath}'" if config.verbose?
project.save_as(projpath)
end
def generate_lock_file!(pods)
......
......@@ -13,12 +13,16 @@ module Pod
root.rmtree
end
def headers_path
def headers_root
root + "Headers"
end
def project_path
root + "Pods.xcodeproj"
end
def add_header_file(namespace_path, relative_header_path)
namespaced_header_path = headers_path + namespace_path
namespaced_header_path = headers_root + namespace_path
namespaced_header_path.mkpath unless File.exist?(namespaced_header_path)
source = (root + relative_header_path).relative_path_from(namespaced_header_path)
Dir.chdir(namespaced_header_path) { FileUtils.ln_sf(source, relative_header_path.basename)}
......@@ -33,5 +37,9 @@ module Pod
def header_search_paths
@header_search_paths.uniq.map { |path| "$(PODS_ROOT)/#{path}" }
end
def prepare_for_install
headers_root.rmtree if headers_root.exist?
end
end
end
......@@ -61,7 +61,7 @@ describe Pod::LocalPod do
it "can link it's headers into the sandbox" do
@pod.link_headers
expected_header_path = @sandbox.headers_path + "BananaLib/Banana.h"
expected_header_path = @sandbox.headers_root + "BananaLib/Banana.h"
expected_header_path.should.be.symlink
File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read
end
......
......@@ -23,8 +23,8 @@ describe Pod::Sandbox do
FileUtils.mkdir(TMP_POD_ROOT) # put it back again
end
it "returns it's headers path" do
@sandbox.headers_path.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers"))
it "returns it's headers root" do
@sandbox.headers_root.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers"))
end
it "can add namespaced headers to it's header path using symlinks and return the relative path" do
......@@ -68,4 +68,9 @@ describe Pod::Sandbox do
@sandbox.header_search_paths.should == ["$(PODS_ROOT)/Headers/ExampleLib"]
end
it 'clears out its headers root when preparing for install' do
@sandbox.prepare_for_install
@sandbox.headers_root.should.not.exist
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