Commit 2fecb2d9 authored by Fabio Pelosin's avatar Fabio Pelosin

Move code around.

parent 3d1b65a4
...@@ -348,7 +348,7 @@ module Pod ...@@ -348,7 +348,7 @@ module Pod
# #
def pod_spec_path def pod_spec_path
path = Pathname.new(@params[:local]).expand_path path = Pathname.new(@params[:local]).expand_path
path += "#{name}.podspec"# unless path.to_s.include?("#{name}.podspec") path += "#{name}.podspec" unless path.to_s.match(/#{name}\.podspec$/)
unless path.exist? unless path.exist?
raise Informative, "No podspec found for `#{name}` in `#{@params[:local]}`" raise Informative, "No podspec found for `#{name}` in `#{@params[:local]}`"
end end
......
...@@ -93,8 +93,6 @@ module Pod ...@@ -93,8 +93,6 @@ module Pod
# Creates the link to the headers of the Pod in the sandbox. # Creates the link to the headers of the Pod in the sandbox.
# #
# TODO: clean up
#
# @return [void] # @return [void]
# #
def link_headers def link_headers
......
...@@ -13,6 +13,8 @@ module Pod ...@@ -13,6 +13,8 @@ module Pod
# #
class UserProjectIntegrator class UserProjectIntegrator
autoload :TargetIntegrator, 'cocoapods/installer/user_project_integrator/target_integrator'
# @return [Podfile] the podfile that should be integrated with the user # @return [Podfile] the podfile that should be integrated with the user
# projects. # projects.
# #
...@@ -62,7 +64,7 @@ module Pod ...@@ -62,7 +64,7 @@ module Pod
warn_about_empty_podfile warn_about_empty_podfile
end end
#--------------------------------------# #-----------------------------------------------------------------------#
# @!group Integration steps # @!group Integration steps
...@@ -71,8 +73,8 @@ module Pod ...@@ -71,8 +73,8 @@ module Pod
# Creates and saved the workspace containing the Pods project and the # Creates and saved the workspace containing the Pods project and the
# user projects, if needed. # user projects, if needed.
# #
# @note If the workspace alreayd containts the projects it is not saved # @note If the workspace already contains the projects it is not saved
# to avoid Xcode from diplatying the revert dialog: `Do you want to # to avoid Xcode from displaying the revert dialog: `Do you want to
# keep the Xcode version or revert to the version on disk?` # keep the Xcode version or revert to the version on disk?`
# #
# @return [void] # @return [void]
...@@ -129,7 +131,7 @@ module Pod ...@@ -129,7 +131,7 @@ module Pod
end end
end end
#--------------------------------------# #-----------------------------------------------------------------------#
# @!group Helpers. # @!group Helpers.
...@@ -164,183 +166,6 @@ module Pod ...@@ -164,183 +166,6 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
# This class is responsible for integrating the library generated by a
# {TargetDefinition} with its destination project.
#
class TargetIntegrator
# @return [Library] the library that should be integrated.
#
attr_reader :library
# @param [Library] library @see #target_definition
#
def initialize(library)
@library = library
end
# Integrates the user project targets. Only the targets that do **not**
# already have the Pods library in their frameworks build phase are
# processed.
#
# @return [void]
#
def integrate!
return if targets.empty?
UI.section(integration_message) do
add_xcconfig_base_configuration
add_pods_library
add_copy_resources_script_phase
save_user_project
end
end
# @return [Array<PBXNativeTarget>] the list of targets that the Pods
# lib that need to be integrated.
#
# @note A target is considered integrated if it already references
#
def targets
unless @targets
target_uuids = library.user_target_uuids
targets = target_uuids.map { |uuid| user_project.targets.find { |target| target.uuid == uuid } }
non_integrated = targets.reject do |target|
target.frameworks_build_phase.files.any? do |build_file|
file_ref = build_file.file_ref
!file_ref.proxy? && file_ref.display_name == library.product_name
end
end
@targets = non_integrated
end
@targets
end
# Read the project from the disk to ensure that it is up to date as
# other TargetIntegrator might have modified it.
#
def user_project
@user_project ||= Xcodeproj::Project.new(library.user_project_path)
end
# @return [String] a string representation suitable for debugging.
#
def inspect
"#<#{self.class} for target `#{target_definition.label}'>"
end
#--------------------------------------#
# @!group Integration steps
private
# Adds the `xcconfig` configurations files generated for the current
# {TargetDefinition} to the build configurations of the targets that
# should be integrated.
#
# @note It also checks if any build setting of the build
# configurations overrides the `xcconfig` file and warns the
# user.
#
# @todo If the xcconfig is already set don't override it and inform
# the user.
#
# @return [void]
#
def add_xcconfig_base_configuration
xcconfig = user_project.new_file(library.xcconfig_relative_path)
targets.each do |target|
check_overridden_build_settings(library.xcconfig, target)
target.build_configurations.each do |config|
config.base_configuration_reference = xcconfig
end
end
end
# Adds a file reference to the library of the {TargetDefinition} and
# adds it to the frameworks build phase of the targets.
#
# @return [void]
#
def add_pods_library
frameworks = user_project.frameworks_group
pods_library = frameworks.new_static_library(library.label)
targets.each do |target|
target.frameworks_build_phase.add_file_reference(pods_library)
end
end
# Adds a shell script build phase responsible to copy the resources
# generated by the TargetDefinition to the bundle of the product of the
# targets.
#
# @return [void]
#
def add_copy_resources_script_phase
targets.each do |target|
phase = target.new_shell_script_build_phase('Copy Pods Resources')
path = library.copy_resources_script_relative_path
phase.shell_script = %{"#{path}"\n}
end
end
# Saves the changes to the user project to the disk.
#
# @return [void]
#
def save_user_project
user_project.save_as(library.user_project_path)
end
#--------------------------------------#
# @!group Private helpers.
private
# Informs the user about any build setting of the target which might
# override the given xcconfig file.
#
# @return [void]
#
def check_overridden_build_settings(xcconfig, target)
return unless xcconfig
configs_by_overridden_key = {}
target.build_configurations.each do |config|
xcconfig.attributes.keys.each do |key|
target_value = config.build_settings[key]
if target_value && !target_value.include?('$(inherited)')
configs_by_overridden_key[key] ||= []
configs_by_overridden_key[key] << config.name
end
end
configs_by_overridden_key.each do |key, config_names|
name = "#{target.name} [#{config_names.join(' - ')}]"
actions = [
"Use the `$(inherited)` flag, or",
"Remove the build settings from the target."
]
UI.warn("The target `#{name}` overrides the `#{key}` build " \
"setting defined in `#{library.xcconfig_relative_path}'.",
actions)
end
end
end
# @return [String] the message that should be displayed for the target
# integration.
#
def integration_message
"Integrating `#{library.product_name}` into " \
"#{'target'.pluralize(targets.size)} " \
"`#{targets.map(&:name).to_sentence}` " \
"of project #{UI.path library.user_project_path}."
end
end
end end
end end
end end
module Pod
class Installer
class UserProjectIntegrator
# This class is responsible for integrating the library generated by a
# {TargetDefinition} with its destination project.
#
class TargetIntegrator
# @return [Library] the library that should be integrated.
#
attr_reader :library
# @param [Library] library @see #target_definition
#
def initialize(library)
@library = library
end
# Integrates the user project targets. Only the targets that do **not**
# already have the Pods library in their frameworks build phase are
# processed.
#
# @return [void]
#
def integrate!
return if targets.empty?
UI.section(integration_message) do
add_xcconfig_base_configuration
add_pods_library
add_copy_resources_script_phase
save_user_project
end
end
# @return [Array<PBXNativeTarget>] the list of targets that the Pods
# lib that need to be integrated.
#
# @note A target is considered integrated if it already references
#
def targets
unless @targets
target_uuids = library.user_target_uuids
targets = target_uuids.map { |uuid| user_project.targets.find { |target| target.uuid == uuid } }
non_integrated = targets.reject do |target|
target.frameworks_build_phase.files.any? do |build_file|
file_ref = build_file.file_ref
!file_ref.proxy? && file_ref.display_name == library.product_name
end
end
@targets = non_integrated
end
@targets
end
# Read the project from the disk to ensure that it is up to date as
# other TargetIntegrators might have modified it.
#
def user_project
@user_project ||= Xcodeproj::Project.new(library.user_project_path)
end
# @return [String] a string representation suitable for debugging.
#
def inspect
"#<#{self.class} for target `#{target_definition.label}'>"
end
#---------------------------------------------------------------------#
# @!group Integration steps
private
# Adds the `xcconfig` configurations files generated for the current
# {TargetDefinition} to the build configurations of the targets that
# should be integrated.
#
# @note It also checks if any build setting of the build
# configurations overrides the `xcconfig` file and warns the
# user.
#
# @todo If the xcconfig is already set don't override it and inform
# the user.
#
# @return [void]
#
def add_xcconfig_base_configuration
xcconfig = user_project.new_file(library.xcconfig_relative_path)
targets.each do |target|
check_overridden_build_settings(library.xcconfig, target)
target.build_configurations.each do |config|
config.base_configuration_reference = xcconfig
end
end
end
# Adds a file reference to the library of the {TargetDefinition} and
# adds it to the frameworks build phase of the targets.
#
# @return [void]
#
def add_pods_library
frameworks = user_project.frameworks_group
pods_library = frameworks.new_static_library(library.label)
targets.each do |target|
target.frameworks_build_phase.add_file_reference(pods_library)
end
end
# Adds a shell script build phase responsible to copy the resources
# generated by the TargetDefinition to the bundle of the product of the
# targets.
#
# @return [void]
#
def add_copy_resources_script_phase
targets.each do |target|
phase = target.new_shell_script_build_phase('Copy Pods Resources')
path = library.copy_resources_script_relative_path
phase.shell_script = %{"#{path}"\n}
end
end
# Saves the changes to the user project to the disk.
#
# @return [void]
#
def save_user_project
user_project.save_as(library.user_project_path)
end
#---------------------------------------------------------------------#
# @!group Private helpers.
private
# Informs the user about any build setting of the target which might
# override the given xcconfig file.
#
# @return [void]
#
def check_overridden_build_settings(xcconfig, target)
return unless xcconfig
configs_by_overridden_key = {}
target.build_configurations.each do |config|
xcconfig.attributes.keys.each do |key|
target_value = config.build_settings[key]
if target_value && !target_value.include?('$(inherited)')
configs_by_overridden_key[key] ||= []
configs_by_overridden_key[key] << config.name
end
end
configs_by_overridden_key.each do |key, config_names|
name = "#{target.name} [#{config_names.join(' - ')}]"
actions = [
"Use the `$(inherited)` flag, or",
"Remove the build settings from the target."
]
UI.warn("The target `#{name}` overrides the `#{key}` build " \
"setting defined in `#{library.xcconfig_relative_path}'.",
actions)
end
end
end
# @return [String] the message that should be displayed for the target
# integration.
#
def integration_message
"Integrating `#{library.product_name}` into " \
"#{'target'.pluralize(targets.size)} " \
"`#{targets.map(&:name).to_sentence}` " \
"of project #{UI.path library.user_project_path}."
end
#---------------------------------------------------------------------#
end
end
end
end
...@@ -29,7 +29,7 @@ module Pod ...@@ -29,7 +29,7 @@ module Pod
# | +-- Acknowledgements.plist # | +-- Acknowledgements.plist
# | +-- Pods.xcconfig # | +-- Pods.xcconfig
# | +-- Pods-prefix.pch # | +-- Pods-prefix.pch
# | +-- PodsDummy_Pods.m # | +-- Pods-dummy_Pods.m
# | # |
# +-- Manifest.lock # +-- Manifest.lock
# | # |
...@@ -37,8 +37,9 @@ module Pod ...@@ -37,8 +37,9 @@ module Pod
# #
class Sandbox class Sandbox
autoload :PathList, 'cocoapods/sandbox/path_list'
autoload :FileAccessor, 'cocoapods/sandbox/file_accessor' autoload :FileAccessor, 'cocoapods/sandbox/file_accessor'
autoload :HeadersStore, 'cocoapods/sandbox/headers_store'
autoload :PathList, 'cocoapods/sandbox/path_list'
# @return [Pathname] the root of the sandbox. # @return [Pathname] the root of the sandbox.
# #
...@@ -117,7 +118,7 @@ module Pod ...@@ -117,7 +118,7 @@ module Pod
"#<#{self.class}> with root #{root}" "#<#{self.class}> with root #{root}"
end end
#--------------------------------------# #-------------------------------------------------------------------------#
# @!group Paths # @!group Paths
...@@ -203,94 +204,7 @@ module Pod ...@@ -203,94 +204,7 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
# Provides support for managing a header directory. It also keeps track of
# the header search paths.
#
class HeadersStore
# @return [Pathname] the absolute path of this header directory.
#
def root
@sandbox.root + @relative_path
end
# @return [Sandbox] the sandbox where this header directory is stored.
#
attr_reader :sandbox
# @param [Sandbox] @see sandbox
#
# @param [String] relative_path
# the relative path to the sandbox root and hence to the Pods
# project.
#
def initialize(sandbox, relative_path)
@sandbox = sandbox
@relative_path = relative_path
@search_paths = [relative_path]
end
# @return [Array<String>] All the search paths of the header directory in
# xcconfig format. The paths are specified relative to the pods
# root with the `${PODS_ROOT}` variable.
#
def search_paths
@search_paths.uniq.map { |path| "${PODS_ROOT}/#{path}" }
end
# Removes the directory as it is regenerated from scratch during each
# installation.
#
# @return [void]
#
def implode!
root.rmtree if root.exist?
end
#--------------------------------------#
public
# @!group Adding headers
# Adds a header to the directory.
#
# @param [Pathname] namespace_path
# the path where the header file should be stored relative to the
# headers directory.
#
# @param [Pathname] relative_header_path
# the path of the header file relative to the sandbox.
#
# @note This method adds the files are added to the search paths.
#
# @return [Pathname]
#
def add_files(namespace, relative_header_paths)
add_search_path(namespace)
namespaced_path = root + namespace
namespaced_path.mkpath unless File.exist?(namespaced_path)
relative_header_paths.map do |relative_header_path|
source = (@sandbox.root + relative_header_path).relative_path_from(namespaced_path)
Dir.chdir(namespaced_path) do
FileUtils.ln_sf(source, relative_header_path.basename)
end
namespaced_path + relative_header_path.basename
end
end
# Adds an header search path to the sandbox.
#
# @param [Pathname] path
# the path tho add.
#
# @return [void]
#
def add_search_path(path)
@search_paths << Pathname.new(@relative_path) + path
end
end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
module Pod
class Sandbox
# Provides support for managing a header directory. It also keeps track of
# the header search paths.
#
class HeadersStore
# @return [Pathname] the absolute path of this header directory.
#
def root
@sandbox.root + @relative_path
end
# @return [Sandbox] the sandbox where this header directory is stored.
#
attr_reader :sandbox
# @param [Sandbox] @see sandbox
#
# @param [String] relative_path
# the relative path to the sandbox root and hence to the Pods
# project.
#
def initialize(sandbox, relative_path)
@sandbox = sandbox
@relative_path = relative_path
@search_paths = [relative_path]
end
# @return [Array<String>] All the search paths of the header directory in
# xcconfig format. The paths are specified relative to the pods
# root with the `${PODS_ROOT}` variable.
#
def search_paths
@search_paths.uniq.map { |path| "${PODS_ROOT}/#{path}" }
end
# Removes the directory as it is regenerated from scratch during each
# installation.
#
# @return [void]
#
def implode!
root.rmtree if root.exist?
end
#-----------------------------------------------------------------------#
public
# @!group Adding headers
# Adds a header to the directory.
#
# @param [Pathname] namespace_path
# the path where the header file should be stored relative to the
# headers directory.
#
# @param [Pathname] relative_header_path
# the path of the header file relative to the sandbox.
#
# @note This method adds the files are added to the search paths.
#
# @return [Pathname]
#
def add_files(namespace, relative_header_paths)
add_search_path(namespace)
namespaced_path = root + namespace
namespaced_path.mkpath unless File.exist?(namespaced_path)
relative_header_paths.map do |relative_header_path|
source = (@sandbox.root + relative_header_path).relative_path_from(namespaced_path)
Dir.chdir(namespaced_path) do
FileUtils.ln_sf(source, relative_header_path.basename)
end
namespaced_path + relative_header_path.basename
end
end
# Adds an header search path to the sandbox.
#
# @param [Pathname] path
# the path tho add.
#
# @return [void]
#
def add_search_path(path)
@search_paths << Pathname.new(@relative_path) + path
end
#-----------------------------------------------------------------------#
end
end
end
...@@ -275,7 +275,7 @@ end ...@@ -275,7 +275,7 @@ end
# subfolders. # subfolders.
# #
def check(arguments, folder) def check(arguments, folder)
focused_check(arguments, folder) # focused_check(arguments, folder)
end end
# Shortcut to focus on a test: Comment the implmentation of #check and # Shortcut to focus on a test: Comment the implmentation of #check and
...@@ -324,7 +324,7 @@ describe "Integration take 2" do ...@@ -324,7 +324,7 @@ describe "Integration take 2" do
end end
describe "Installs a Pod with a local source" do describe "Installs a Pod with a local source" do
check "install --no-update --no-doc", "install_local_source" focused_check "install --no-update --no-doc", "install_local_source"
end end
describe "Installs a Pod with an external source" do describe "Installs a Pod with an external source" do
......
require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
describe TargetIntegrator = Installer::UserProjectIntegrator::TargetIntegrator do
describe "In general" do
before do
sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
@sample_project = Xcodeproj::Project.new sample_project_path
@target = @sample_project.targets.first
target_definition = Podfile::TargetDefinition.new(:default, nil, nil)
@lib = Library.new(target_definition)
@lib.user_project_path = sample_project_path
pods_project = Project.new()
@lib.target = pods_project.new_target(:static_library, target_definition.label, :ios)
@lib.user_target_uuids = [@target.uuid]
@lib.support_files_root = config.sandbox.root
@lib.user_project_path = sample_project_path
@target_integrator = TargetIntegrator.new(@lib)
end
it 'returns the targets that need to be integrated' do
@target_integrator.targets.map(&:name).should == %w[ SampleProject ]
end
it 'returns the targets that need to be integrated' do
pods_library = @sample_project.frameworks_group.new_static_library('Pods')
@target.frameworks_build_phase.add_file_reference(pods_library)
Xcodeproj::Project.any_instance.stubs(:targets).returns([@target])
@target_integrator.targets.map(&:name).should.be.empty?
end
it 'does not perform the integration if there are no targets to integrate' do
@target_integrator.stubs(:targets).returns([])
@target_integrator.expects(:add_xcconfig_base_configuration).never
@target_integrator.expects(:add_pods_library).never
@target_integrator.expects(:add_copy_resources_script_phase).never
@target_integrator.expects(:save_user_project).never
@target_integrator.integrate!
end
before do
@target_integrator.integrate!
end
it 'sets the Pods xcconfig as the base config for each build configuration' do
xcconfig_file = @sample_project.files.find { |f| f.path == @lib.xcconfig_relative_path }
@target.build_configurations.each do |config|
config.base_configuration_reference.should == xcconfig_file
end
end
it 'adds references to the Pods static libraries to the Frameworks group' do
@target_integrator.user_project["Frameworks/libPods.a"].should.not == nil
end
it 'adds the libPods static library to the "Link binary with libraries" build phase of each target' do
target = @target_integrator.targets.first
target.frameworks_build_phase.files.find { |f| f.file_ref.path == 'libPods.a'}.should.not == nil
end
it 'adds a Copy Pods Resources build phase to each target' do
target = @target_integrator.targets.first
phase = target.shell_script_build_phases.find { |bp| bp.name == "Copy Pods Resources" }
phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Pods-resources.sh\""
end
end
end
end
...@@ -80,72 +80,4 @@ module Pod ...@@ -80,72 +80,4 @@ module Pod
end end
end end
end end
#-----------------------------------------------------------------------------#
describe TargetIntegrator = Installer::UserProjectIntegrator::TargetIntegrator do
describe "In general" do
before do
sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
@sample_project = Xcodeproj::Project.new sample_project_path
@target = @sample_project.targets.first
target_definition = Podfile::TargetDefinition.new(:default, nil, nil)
@lib = Library.new(target_definition)
@lib.user_project_path = sample_project_path
pods_project = Project.new()
@lib.target = pods_project.new_target(:static_library, target_definition.label, :ios)
@lib.user_target_uuids = [@target.uuid]
@lib.support_files_root = config.sandbox.root
@lib.user_project_path = sample_project_path
@target_integrator = TargetIntegrator.new(@lib)
end
it 'returns the targets that need to be integrated' do
@target_integrator.targets.map(&:name).should == %w[ SampleProject ]
end
it 'returns the targets that need to be integrated' do
pods_library = @sample_project.frameworks_group.new_static_library('Pods')
@target.frameworks_build_phase.add_file_reference(pods_library)
Xcodeproj::Project.any_instance.stubs(:targets).returns([@target])
@target_integrator.targets.map(&:name).should.be.empty?
end
it 'does not perform the integration if there are no targets to integrate' do
@target_integrator.stubs(:targets).returns([])
@target_integrator.expects(:add_xcconfig_base_configuration).never
@target_integrator.expects(:add_pods_library).never
@target_integrator.expects(:add_copy_resources_script_phase).never
@target_integrator.expects(:save_user_project).never
@target_integrator.integrate!
end
before do
@target_integrator.integrate!
end
it 'sets the Pods xcconfig as the base config for each build configuration' do
xcconfig_file = @sample_project.files.find { |f| f.path == @lib.xcconfig_relative_path }
@target.build_configurations.each do |config|
config.base_configuration_reference.should == xcconfig_file
end
end
it 'adds references to the Pods static libraries to the Frameworks group' do
@target_integrator.user_project["Frameworks/libPods.a"].should.not == nil
end
it 'adds the libPods static library to the "Link binary with libraries" build phase of each target' do
target = @target_integrator.targets.first
target.frameworks_build_phase.files.find { |f| f.file_ref.path == 'libPods.a'}.should.not == nil
end
it 'adds a Copy Pods Resources build phase to each target' do
target = @target_integrator.targets.first
phase = target.shell_script_build_phases.find { |bp| bp.name == "Copy Pods Resources" }
phase.shell_script.strip.should == "\"${SRCROOT}/../Pods/Pods-resources.sh\""
end
end
end
end end
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Sandbox::HeadersStore do
before do
@sandbox = Pod::Sandbox.new(temporary_directory + 'Sandbox')
@header_dir = Sandbox::HeadersStore.new(@sandbox, 'Headers')
end
it "returns it's headers root" do
@header_dir.root.should == temporary_directory + 'Sandbox/Headers'
end
it "can add namespaced headers to it's header path using symlinks and return the relative path" do
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/")
namespace_path = Pathname.new("ExampleLib")
relative_header_paths = [
Pathname.new("ExampleLib/MyHeader.h"),
Pathname.new("ExampleLib/MyOtherHeader.h")
]
relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end
symlink_paths = @header_dir.add_files(namespace_path, relative_header_paths)
symlink_paths.each do |path|
path.should.be.symlink
File.read(path).should == "hello"
end
end
it 'keeps a list of unique header search paths when headers are added' do
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/Dir")
namespace_path = Pathname.new("ExampleLib")
relative_header_paths = [
Pathname.new("ExampleLib/Dir/MyHeader.h"),
Pathname.new("ExampleLib/Dir/MyOtherHeader.h")
]
relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end
@header_dir.add_files(namespace_path, relative_header_paths)
@header_dir.search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib")
end
it 'always adds the Headers root to the header search paths' do
@header_dir.search_paths.should.include("${PODS_ROOT}/Headers")
end
end
end
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
module Pod module Pod
describe Sandbox do describe Sandbox do
before do before do
@sandbox = Pod::Sandbox.new(temporary_directory + 'Sandbox') @sandbox = Pod::Sandbox.new(temporary_directory + 'Sandbox')
end end
...@@ -51,12 +49,12 @@ module Pod ...@@ -51,12 +49,12 @@ module Pod
@sandbox.relativize(path).should == expected @sandbox.relativize(path).should == expected
end end
it "converts a list of paths to the relative paths respec to the sandbox" do it "converts a list of paths to the relative paths respect to the sandbox" do
paths = [temporary_directory + 'Sandbox/file_1', temporary_directory + 'Sandbox/file_2' ] paths = [temporary_directory + 'Sandbox/file_1', temporary_directory + 'Sandbox/file_2' ]
@sandbox.relativize_paths(paths).should == [Pathname.new('file_1'), Pathname.new('file_2')] @sandbox.relativize_paths(paths).should == [Pathname.new('file_1'), Pathname.new('file_2')]
end end
#--------------------------------------# #-------------------------------------------------------------------------#
it "returns the path of the manifest" do it "returns the path of the manifest" do
@sandbox.manifest_path.should == temporary_directory + 'Sandbox/Manifest.lock' @sandbox.manifest_path.should == temporary_directory + 'Sandbox/Manifest.lock'
...@@ -84,7 +82,7 @@ module Pod ...@@ -84,7 +82,7 @@ module Pod
@sandbox.specification_path('BananaLib').should == @sandbox.root + 'Local Podspecs/BananaLib.podspec' @sandbox.specification_path('BananaLib').should == @sandbox.root + 'Local Podspecs/BananaLib.podspec'
end end
#--------------------------------------# #-------------------------------------------------------------------------#
it "loads the stored specification with the given name" do it "loads the stored specification with the given name" do
(@sandbox.root + 'Local Podspecs').mkdir (@sandbox.root + 'Local Podspecs').mkdir
...@@ -96,58 +94,8 @@ module Pod ...@@ -96,58 +94,8 @@ module Pod
@sandbox.predownloaded_pods << 'JSONKit' @sandbox.predownloaded_pods << 'JSONKit'
@sandbox.predownloaded_pods.should == ['JSONKit'] @sandbox.predownloaded_pods.should == ['JSONKit']
end end
end
#---------------------------------------------------------------------------#
describe Sandbox::HeadersStore do
#-------------------------------------------------------------------------#
before do
@sandbox = Pod::Sandbox.new(temporary_directory + 'Sandbox')
@header_dir = Sandbox::HeadersStore.new(@sandbox, 'Headers')
end
it "returns it's headers root" do
@header_dir.root.should == temporary_directory + 'Sandbox/Headers'
end
it "can add namespaced headers to it's header path using symlinks and return the relative path" do
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/")
namespace_path = Pathname.new("ExampleLib")
relative_header_paths = [
Pathname.new("ExampleLib/MyHeader.h"),
Pathname.new("ExampleLib/MyOtherHeader.h")
]
relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end
symlink_paths = @header_dir.add_files(namespace_path, relative_header_paths)
symlink_paths.each do |path|
path.should.be.symlink
File.read(path).should == "hello"
end
end
it 'keeps a list of unique header search paths when headers are added' do
FileUtils.mkdir_p(@sandbox.root + "ExampleLib/Dir")
namespace_path = Pathname.new("ExampleLib")
relative_header_paths = [
Pathname.new("ExampleLib/Dir/MyHeader.h"),
Pathname.new("ExampleLib/Dir/MyOtherHeader.h")
]
relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end
@header_dir.add_files(namespace_path, relative_header_paths)
@header_dir.search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib")
end
it 'always adds the Headers root to the header search paths' do
@header_dir.search_paths.should.include("${PODS_ROOT}/Headers")
end
end end
#--------------------------------------#
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