Commit efb81a02 authored by Fabio Pelosin's avatar Fabio Pelosin

[Sandbox] Clean up implementation

parent d5f4684c
...@@ -60,10 +60,10 @@ module Pod ...@@ -60,10 +60,10 @@ module Pod
#--------------------------------------# #--------------------------------------#
# @!group Specifications
public public
# @!group Specifications
# @return [Specification] returns the specification, either from the # @return [Specification] returns the specification, either from the
# sandbox or by fetching the remote source, associated with the # sandbox or by fetching the remote source, associated with the
# external source. # external source.
...@@ -96,6 +96,8 @@ module Pod ...@@ -96,6 +96,8 @@ module Pod
#--------------------------------------# #--------------------------------------#
public
# @!group Subclasses hooks # @!group Subclasses hooks
# Fetches the external source from the remote according to the params. # Fetches the external source from the remote according to the params.
...@@ -117,39 +119,10 @@ module Pod ...@@ -117,39 +119,10 @@ module Pod
#--------------------------------------# #--------------------------------------#
# @! Subclasses helpers
private private
# Stores a specification in the `Local Podspecs` folder. # @! Subclasses helpers
#
# @param [Sandbox] sandbox
# the sandbox where the podspec should be stored.
#
# @param [String, Pathname] podspec
# The contents of the specification (String) or the path to a
# podspec file (Pathname).
#
# @todo This could be done by the sandbox.
# @todo Store all the specifications (including those not originating
# from external sources) so users can check them.
# @todo The check for the podspec string is a bit primitive.
#
def store_podspec(sandbox, podspec)
output_path = sandbox.root + "Local Podspecs/#{name}.podspec"
output_path.dirname.mkpath
if podspec.is_a?(String)
unless podspec.include?('Spec.new')
raise Informative, "The `#{name}.podspec` from `#{description}` appears to be invalid."
end
output_path.open('w') { |f| f.puts(podspec) }
else
unless podspec.exist?
raise Informative, "No podspec found for `#{name}` in #{description}"
end
FileUtils.copy(podspec, output_path)
end
end
# Pre-downloads a Pod passing the options to the downloader and informing # Pre-downloads a Pod passing the options to the downloader and informing
# the sandbox. # the sandbox.
...@@ -165,8 +138,8 @@ module Pod ...@@ -165,8 +138,8 @@ module Pod
target.rmtree if target.exist? target.rmtree if target.exist?
downloader = Downloader.for_target(target, @params) downloader = Downloader.for_target(target, @params)
downloader.download downloader.download
store_podspec(sandbox, target + "#{name}.podspec") sandbox.store_podspec(name, target + "#{name}.podspec", true)
sandbox.predownloaded_pods << name sandbox.store_pre_downloaded_pod(name)
if downloader.options_specific? if downloader.options_specific?
source = @params source = @params
else else
...@@ -291,7 +264,7 @@ module Pod ...@@ -291,7 +264,7 @@ module Pod
path = @params[:podspec] path = @params[:podspec]
path = Pathname.new(path).expand_path if path.to_s.start_with?("~") path = Pathname.new(path).expand_path if path.to_s.start_with?("~")
require 'open-uri' require 'open-uri'
open(path) { |io| store_podspec(sandbox, io.read) } open(path) { |io| sandbox.store_podspec(name, io.read, true) }
end end
end end
...@@ -314,7 +287,7 @@ module Pod ...@@ -314,7 +287,7 @@ module Pod
# @see AbstractExternalSource#copy_external_source_into_sandbox # @see AbstractExternalSource#copy_external_source_into_sandbox
# #
def copy_external_source_into_sandbox(sandbox) def copy_external_source_into_sandbox(sandbox)
store_podspec(sandbox, pod_spec_path) sandbox.store_podspec(name, pod_spec_path, true)
sandbox.store_local_path(name, @params[:local]) sandbox.store_local_path(name, @params[:local])
end end
...@@ -349,10 +322,10 @@ module Pod ...@@ -349,10 +322,10 @@ module Pod
#--------------------------------------# #--------------------------------------#
# @!group Helpers
private private
# @!group Helpers
# @return [Pathname] the path of the podspec. # @return [Pathname] the path of the podspec.
# #
def pod_spec_path def pod_spec_path
......
...@@ -222,7 +222,7 @@ module Pod ...@@ -222,7 +222,7 @@ module Pod
def create_copy_resources_script def create_copy_resources_script
path = library.copy_resources_script_path path = library.copy_resources_script_path
UI.message "- Generating copy resources script at #{UI.path(path)}" do UI.message "- Generating copy resources script at #{UI.path(path)}" do
resources = library.file_accessors.map { |accessor| accessor.resources.values.flatten.map {|res| sandbox.relativize(res)} }.flatten resources = library.file_accessors.map { |accessor| accessor.resources.values.flatten.map {|res| project.relativize(res)} }.flatten
resources << bridge_support_file if bridge_support_file resources << bridge_support_file if bridge_support_file
generator = Generator::CopyResourcesScript.new(resources) generator = Generator::CopyResourcesScript.new(resources)
generator.save_as(path) generator.save_as(path)
......
...@@ -35,6 +35,35 @@ module Pod ...@@ -35,6 +35,35 @@ module Pod
@root ||= path.dirname @root ||= path.dirname
end end
# @return [Pathname] Returns the relative path from the project root.
#
# @param [Pathname] path
# The path that needs to be converted to the relative format.
#
# @note If the two absolute paths don't share the same root directory an
# extra `../` is added to the result of
# {Pathname#relative_path_from}.
#
# @example
#
# path = Pathname.new('/Users/dir')
# @sandbox.root #=> Pathname('/tmp/CocoaPods/Lint/Pods')
#
# @sandbox.relativize(path) #=> '../../../../Users/dir'
# @sandbox.relativize(path) #=> '../../../../../Users/dir'
#
def relativize(path)
unless path.absolute?
raise Informative, "Attempt to add relative path to the Pods project"
end
result = path.relative_path_from(root)
unless root.to_s.split('/')[1] == path.to_s.split('/')[1]
result = Pathname.new('../') + result
end
result
end
# @return [String] a string representation suited for debugging. # @return [String] a string representation suited for debugging.
# #
def inspect def inspect
...@@ -107,7 +136,7 @@ module Pod ...@@ -107,7 +136,7 @@ module Pod
# Adds a file reference for each one of the given files in the specified # Adds a file reference for each one of the given files in the specified
# group, namespaced by specification unless a file reference for the given # group, namespaced by specification unless a file reference for the given
# path alrady exits. # path already exits.
# #
# @note With this set-up different subspecs might not reference the same # @note With this set-up different subspecs might not reference the same
# file (i.e. the first will win). Not sure thought if this is a # file (i.e. the first will win). Not sure thought if this is a
...@@ -149,35 +178,6 @@ module Pod ...@@ -149,35 +178,6 @@ module Pod
refs_by_absolute_path[absolute_path] refs_by_absolute_path[absolute_path]
end end
# @return [Pathname] Returns the relative path from the project root.
#
# @param [Pathname] path
# The path that needs to be converted to the relative format.
#
# @note If the two absolute paths don't share the same root directory an
# extra `../` is added to the result of
# {Pathname#relative_path_from}.
#
# @example
#
# path = Pathname.new('/Users/dir')
# @sandbox.root #=> Pathname('/tmp/CocoaPods/Lint/Pods')
#
# @sandbox.relativize(path) #=> '../../../../Users/dir'
# @sandbox.relativize(path) #=> '../../../../../Users/dir'
#
def relativize(path)
unless path.absolute?
raise Informative, "Attempt to add relative path to the Pods project"
end
result = path.relative_path_from(root)
unless root.to_s.split('/')[1] == path.to_s.split('/')[1]
result = Pathname.new('../') + result
end
result
end
# Adds a file reference to the podfile. # Adds a file reference to the podfile.
# #
# @param [Pathname,String] podfile_path # @param [Pathname,String] podfile_path
......
...@@ -13,7 +13,7 @@ module Pod ...@@ -13,7 +13,7 @@ module Pod
# Pods # Pods
# | # |
# +-- Headers # +-- Headers
# | +-- Build # | +-- Private
# | | +-- [Pod Name] # | | +-- [Pod Name]
# | +-- Public # | +-- Public
# | +-- [Pod Name] # | +-- [Pod Name]
...@@ -22,6 +22,8 @@ module Pod ...@@ -22,6 +22,8 @@ module Pod
# | +-- [Pod Name] # | +-- [Pod Name]
# | # |
# +-- Specifications # +-- Specifications
# | +-- External Sources
# | +-- Normal Sources
# | # |
# +-- Target Support Files # +-- Target Support Files
# | +-- [Target Name] # | +-- [Target Name]
...@@ -84,36 +86,6 @@ module Pod ...@@ -84,36 +86,6 @@ module Pod
root.rmtree root.rmtree
end end
# @return [Pathname] Returns the relative path from the sandbox.
#
# @note If the two absolute paths don't share the same root directory an
# extra `../` is added to the result of {Pathname#relative_path_from}
#
#
# @example
#
# path = Pathname.new('/Users/dir')
# @sandbox.root #=> Pathname('/tmp/CocoaPods/Lint/Pods')
#
# @sandbox.relativize(path) #=> '../../../../Users/dir'
# @sandbox.relativize(path) #=> '../../../../../Users/dir'
#
def relativize(path)
result = path.relative_path_from(root)
unless root.to_s.split('/')[1] == path.to_s.split('/')[1]
result = Pathname.new('../') + result
end
result
end
# Converts a list of paths to their relative variant.
#
# @return [Array<Pathname>] the relative paths.
#
def relativize_paths(paths)
paths.map { |path| relativize(path) }
end
# @return [String] a string representation suitable for debugging. # @return [String] a string representation suitable for debugging.
# #
def inspect def inspect
...@@ -122,6 +94,8 @@ module Pod ...@@ -122,6 +94,8 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
public
# @!group Paths # @!group Paths
# @return [Pathname] the path of the manifest. # @return [Pathname] the path of the manifest.
...@@ -149,64 +123,115 @@ module Pod ...@@ -149,64 +123,115 @@ module Pod
root root
end end
# Returns the path where the Pod with the given name is stored, taking into
# account whether the Pod is locally sourced.
#
# @param [String] name
# The name of the Pod.
#
# @return [Pathname] the path of the Pod.
#
def pod_dir(name)
root_name = Specification.root_name(name)
if local?(root_name)
Pathname.new(local_pods[root_name])
else
# root + "Sources/#{name}"
root + root_name
end
end
#-------------------------------------------------------------------------#
public
# @!group Specification store
# Returns the specification for the Pod with the given name.
#
# @param [String] name
# the name of the Pod for which the specification is requested.
#
# @return [Specification] the specification if the file is found.
#
def specification(name)
if file = specification_path(name)
Specification.from_file(file)
end
end
# @return [Pathname] the path for the directory where to store the # @return [Pathname] the path for the directory where to store the
# specifications. # specifications.
# #
def specifications_dir # @todo Migrate old installations and store the for all the pods.
# Two folders should be created `External Sources` and `Podspecs`.
#
def specifications_dir(external_source = false)
# root + "Specifications" # root + "Specifications"
root + "Local Podspecs" root + "Local Podspecs"
end end
# Returns the path of the specification for the Pod with the # Returns the path of the specification for the Pod with the
# given name. # given name, if one is stored.
# #
# @param [String] name # @param [String] name
# the name of the Pod for which the podspec file is requested. # the name of the Pod for which the podspec file is requested.
# #
# @return [Pathname] the path or nil. # @return [Pathname] the path or nil.
# @return [Nil] if the podspec is not stored.
# #
def specification_path(name) def specification_path(name)
path = specifications_dir + "#{name}.podspec" path = specifications_dir + "#{name}.podspec"
path.exist? ? path : nil path.exist? ? path : nil
end end
#-------------------------------------------------------------------------# # Stores a specification in the `Local Podspecs` folder.
# @!group Pods storage & source
# Returns the specification for the Pod with the given name.
# #
# @param [String] name # @param [Sandbox] sandbox
# the name of the Pod for which the specification is requested. # the sandbox where the podspec should be stored.
# #
# @return [Specification] the specification if the file is found. # @param [String, Pathname] podspec
# The contents of the specification (String) or the path to a
# podspec file (Pathname).
# #
def specification(name) # @todo Store all the specifications (including those not originating
if file = specification_path(name) # from external sources) so users can check them.
Specification.from_file(file) #
def store_podspec(name, podspec, external_source = false)
output_path = specifications_dir(external_source) + "#{name}.podspec"
output_path.dirname.mkpath
if podspec.is_a?(String)
output_path.open('w') { |f| f.puts(podspec) }
else
unless podspec.exist?
raise Informative, "No podspec found for `#{name}` in #{podspec}"
end
FileUtils.copy(podspec, output_path)
end
spec = Specification.from_file(output_path)
unless spec.name == name
raise Informative, "The name of the given podspec `#{spec.name}` doesn't match the expected one `#{name}`"
end end
end end
# Returns the path where the Pod with the given name is stored, taking into #-------------------------------------------------------------------------#
# account whether the Pod is locally sourced.
public
# @!group Pods information
# Marks a Pod as pre-downloaded
# #
# @param [String] name # @param [String] name
# The name of the Pod. # The name of the Pod.
# #
# @return [Pathname] the path of the Pod. # @return [void]
# #
def pod_dir(name) def store_pre_downloaded_pod(name)
root_name = Specification.root_name(name) root_name = Specification.root_name(name)
if local?(root_name) predownloaded_pods << root_name
Pathname.new(local_pods[root_name])
else
# root + "Sources/#{name}"
root + root_name
end
end end
#--------------------------------------#
# @return [Array<String>] The names of the pods that have been # @return [Array<String>] The names of the pods that have been
# pre-downloaded from an external source. # pre-downloaded from an external source.
# #
......
...@@ -20,57 +20,63 @@ module Pod ...@@ -20,57 +20,63 @@ module Pod
describe ExternalSources::AbstractExternalSource do describe ExternalSources::AbstractExternalSource do
it "compares to another" do
dependency_1 = Dependency.new("Reachability", :git => 'url')
dependency_2 = Dependency.new("Another_name", :git => 'url')
dependency_3 = Dependency.new("Reachability", :git => 'another_url')
dependency_1.should.be == dependency_1
dependency_1.should.not.be == dependency_2
dependency_1.should.not.be == dependency_3
end
before do before do
dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability')) dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability'))
@external_source = ExternalSources.from_dependency(dependency) @external_source = ExternalSources.from_dependency(dependency)
end end
it "returns the specification from the sandbox if available" do #--------------------------------------#
@external_source.specification_from_external(config.sandbox)
@external_source.expects(:specification_from_external).never
@external_source.specification(config.sandbox).name.should == 'Reachability'
end
it "returns the specification from the remote if needed" do describe "In general" do
@external_source.specification(config.sandbox).name.should == 'Reachability'
end
it "returns the specification from the sandbox if available" do it "compares to another" do
@external_source.specification_from_external(config.sandbox) dependency_1 = Dependency.new("Reachability", :git => 'url')
@external_source.specification_from_local(config.sandbox).name.should == 'Reachability' dependency_2 = Dependency.new("Another_name", :git => 'url')
end dependency_3 = Dependency.new("Reachability", :git => 'another_url')
it "returns nil if the specification from the sandbox is not available" do dependency_1.should.be == dependency_1
@external_source.specification_from_local(config.sandbox).should.be.nil dependency_1.should.not.be == dependency_2
end dependency_1.should.not.be == dependency_3
end
it "returns the specification fetching it from the external source in any case" do it "returns the specification from the sandbox if available" do
@external_source.specification_from_external(config.sandbox).name.should == 'Reachability' config.sandbox.store_podspec('Reachability', fixture('integration/Reachability/Reachability.podspec'))
end @external_source.expects(:specification_from_external).never
@external_source.specification(config.sandbox).name.should == 'Reachability'
end
#--------------------------------------# it "fetches the remote if needed to return the specification" do
@external_source.specification(config.sandbox).name.should == 'Reachability'
end
describe "Subclasses helpers" do it "returns the specification as stored in the sandbox if available" do
@external_source.specification_from_external(config.sandbox)
@external_source.specification_from_local(config.sandbox).name.should == 'Reachability'
end
it "stores the podspec in the sandbox" do it "returns nil if the specification requested from local is not available in the sandbox" do
sandbox = config.sandbox @external_source.specification_from_local(config.sandbox).should.be.nil
podspec_path = fixture('integration/Reachability/Reachability.podspec') end
@external_source.send(:store_podspec, sandbox, podspec_path)
it "returns the specification fetching it from the external source in any case" do
@external_source.specification_from_external(config.sandbox).name.should == 'Reachability'
end
it "stores the specification in the sandbox after fetching it from the remote" do
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.not.exist?
@external_source.specification_from_external(config.sandbox).name.should == 'Reachability'
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
it "pre-downloads the Pod and store the relevant information in the sandbox" do end
#--------------------------------------#
describe "Subclasses helpers" do
it "pre-downloads the Pod and stores the relevant information in the sandbox" do
sandbox = config.sandbox sandbox = config.sandbox
@external_source.send(:pre_download, sandbox) @external_source.send(:pre_download, sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
......
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
describe Pod::Project do module Pod
describe "In general" do describe Project do
before do before do
@project = Pod::Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox.project_path)
end end
it "creates the support file group on initialization" do #-------------------------------------------------------------------------#
@project.support_files_group.name.should == 'Targets Support Files'
end
it "returns the `Pods` group" do describe "In general" do
@project.pods.name.should == 'Pods'
end
it "returns the `Local Pods` group" do it "creates the support file group on initialization" do
@project.local_pods.name.should == 'Local Pods' @project.support_files_group.name.should == 'Targets Support Files'
end end
it "returns the `Resources` group" do it "can return the relative path of a given absolute path" do
@project.resources.name.should == 'Resources' path = temporary_directory + 'Pods/BananaLib/file'
end @project.relativize(path).should == Pathname.new('BananaLib/file')
end
it "adds a group for a specification" do it "can return the relative path of a given absolute path outside its root" do
group = @project.add_spec_group('JSONKit', @project.pods) path = temporary_directory + 'file'
@project.pods.children.should.include?(group) @project.relativize(path).should == Pathname.new('../file')
g = @project['Pods/JSONKit'] end
g.name.should == 'JSONKit'
g.children.should.be.empty?
end
it "namespaces subspecs in groups" do it "can return the relative path of a given absolute path with another root directory" do
group = @project.add_spec_group('JSONKit/Subspec', @project.pods) path = Pathname('/tmp/Lint')
@project.pods.groups.find { |g| g.name == 'JSONKit' }.children.should.include?(group) expected = Pathname.new('../../../tmp/Lint')
g = @project['Pods/JSONKit/Subspec'] @project.instance_variable_set(:@root, Pathname.new('/Users/sandbox'))
g.name.should == 'Subspec' @project.relativize(path).should == expected
g.children.should.be.empty? end
end
it "adds the Podfile configured as a Ruby file" do
@project.add_podfile(config.sandbox.root + '../Podfile')
f = @project['Podfile']
f.name.should == 'Podfile'
f.source_tree.should == 'SOURCE_ROOT'
f.xc_language_specification_identifier.should == 'xcode.lang.ruby'
f.path.should == '../Podfile'
end end
#--------------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Groups" do
it "returns the `Pods` group" do
@project.pods.name.should == 'Pods'
end
it "returns the `Local Pods` group" do
@project.local_pods.name.should == 'Local Pods'
end
it "returns the `Resources` group" do
@project.resources.name.should == 'Resources'
end
it "adds a group for a specification" do
group = @project.add_spec_group('JSONKit', @project.pods)
@project.pods.children.should.include?(group)
g = @project['Pods/JSONKit']
g.name.should == 'JSONKit'
g.children.should.be.empty?
end
it "namespaces subspecs in groups" do
group = @project.add_spec_group('JSONKit/Subspec', @project.pods)
@project.pods.groups.find { |g| g.name == 'JSONKit' }.children.should.include?(group)
g = @project['Pods/JSONKit/Subspec']
g.name.should == 'Subspec'
g.children.should.be.empty?
end
it "adds the file references for the given source files" do
source_files = [ config.sandbox.root + "A_POD/some_file.m" ]
@project.add_file_references(source_files, 'BananaLib', @project.pods)
group = @project['Pods/BananaLib']
group.should.not.be.nil
group.children.map(&:path).should == [ "A_POD/some_file.m" ]
end end
it "adds the only one file reference for a given absolute path" do #-------------------------------------------------------------------------#
source_files = [ config.sandbox.root + "A_POD/some_file.m" ]
@project.add_file_references(source_files, 'BananaLib', @project.pods) describe "File references" do
@project.add_file_references(source_files, 'BananaLib', @project.pods)
group = @project['Pods/BananaLib'] it "adds the file references for the given source files" do
group.children.count.should == 1 source_files = [ config.sandbox.root + "A_POD/some_file.m" ]
group.children.first.path.should == "A_POD/some_file.m" @project.add_file_references(source_files, 'BananaLib', @project.pods)
group = @project['Pods/BananaLib']
group.should.not.be.nil
group.children.map(&:path).should == [ "A_POD/some_file.m" ]
end
it "adds the only one file reference for a given absolute path" do
source_files = [ config.sandbox.root + "A_POD/some_file.m" ]
@project.add_file_references(source_files, 'BananaLib', @project.pods)
@project.add_file_references(source_files, 'BananaLib', @project.pods)
group = @project['Pods/BananaLib']
group.children.count.should == 1
group.children.first.path.should == "A_POD/some_file.m"
end
it "returns the file reference for a given source file" do
file = config.sandbox.root + "A_POD/some_file.m"
@project.add_file_references([file], 'BananaLib', @project.pods)
file_reference = @project.file_reference(file)
file_reference.path.should == "A_POD/some_file.m"
end
it "adds the Podfile configured as a Ruby file" do
@project.add_podfile(config.sandbox.root + '../Podfile')
f = @project['Podfile']
f.name.should == 'Podfile'
f.source_tree.should == 'SOURCE_ROOT'
f.xc_language_specification_identifier.should == 'xcode.lang.ruby'
f.path.should == '../Podfile'
end
end end
it "returns the file reference for a given source file" do #-------------------------------------------------------------------------#
file = config.sandbox.root + "A_POD/some_file.m"
@project.add_file_references([file], 'BananaLib', @project.pods) describe "File references" do
file_reference = @project.file_reference(file)
file_reference.path.should == "A_POD/some_file.m" it "stores the references by absolute path" do
file = config.sandbox.root + "A_POD/some_file.m"
@project.add_file_references([file], 'BananaLib', @project.pods)
refs_by_absolute_path = @project.send(:refs_by_absolute_path)
refs_by_absolute_path.should == {
file => @project.file_reference(file)
}
end
end end
#-------------------------------------------------------------------------#
end end
end end
......
...@@ -7,80 +7,62 @@ module Pod ...@@ -7,80 +7,62 @@ module Pod
@sandbox = Pod::Sandbox.new(temporary_directory + 'Sandbox') @sandbox = Pod::Sandbox.new(temporary_directory + 'Sandbox')
end end
it "automatically creates its root if it doesn't exist" do #-------------------------------------------------------------------------#
File.directory?(temporary_directory + 'Sandbox').should.be.true
end
it "returns the manifest" do
@sandbox.manifest.should == nil
end
it "returns the project" do describe "In general" do
@sandbox.project.should == nil
end
it "returns the public headers store" do it "automatically creates its root if it doesn't exist" do
@sandbox.public_headers.root.should == temporary_directory + 'Sandbox/Headers' File.directory?(temporary_directory + 'Sandbox').should.be.true
end end
it "returns the build headers store" do it "returns the manifest" do
@sandbox.build_headers.root.should == temporary_directory + 'Sandbox/BuildHeaders' @sandbox.manifest.should == nil
end end
it "deletes the entire root directory on implode" do it "returns the project" do
@sandbox.implode @sandbox.project.should == nil
File.directory?(temporary_directory + 'Sandbox').should.be.false end
end
it "can return the relative path of a given absolute path" do it "returns the public headers store" do
path = temporary_directory + 'Sandbox/file' @sandbox.public_headers.root.should == temporary_directory + 'Sandbox/Headers'
@sandbox.relativize(path).should == Pathname.new('file') end
end
it "can return the relative path of a given absolute path outside the sandbox root" do it "returns the build headers store" do
path = temporary_directory + 'file' @sandbox.build_headers.root.should == temporary_directory + 'Sandbox/BuildHeaders'
@sandbox.relativize(path).should == Pathname.new('../file') end
end
it "can return the relative path of a given absolute path with another root directory" do it "deletes the entire root directory on implode" do
path = Pathname('/tmp/Lint') @sandbox.implode
expected = Pathname.new('../../../tmp/Lint') File.directory?(temporary_directory + 'Sandbox').should.be.false
@sandbox.instance_variable_set(:@root, Pathname.new('/Users/sandbox')) end
@sandbox.relativize(path).should == expected
end
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' ]
@sandbox.relativize_paths(paths).should == [Pathname.new('file_1'), Pathname.new('file_2')]
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
it "returns the path of the manifest" do describe "Paths" do
@sandbox.manifest_path.should == temporary_directory + 'Sandbox/Manifest.lock'
end
it "returns the path of the Pods project" do it "returns the path of the manifest" do
@sandbox.project_path.should == temporary_directory + 'Sandbox/Pods.xcodeproj' @sandbox.manifest_path.should == temporary_directory + 'Sandbox/Manifest.lock'
end end
it "returns the directory for the support files of a library" do it "returns the path of the Pods project" do
@sandbox.library_support_files_dir('Pods').should == temporary_directory + 'Sandbox' @sandbox.project_path.should == temporary_directory + 'Sandbox/Pods.xcodeproj'
end end
it "returns the directory where to store the specifications" do it "returns the directory for the support files of a library" do
@sandbox.specifications_dir.should == temporary_directory + 'Sandbox/Local Podspecs' @sandbox.library_support_files_dir('Pods').should == temporary_directory + 'Sandbox'
end end
it "returns the directory where a Pod is stored" do
@sandbox.pod_dir('JSONKit').should == temporary_directory + 'Sandbox/JSONKit'
end
it "returns the path to a spec file in the 'Local Podspecs' dir" do
(@sandbox.root + 'Local Podspecs').mkdir
FileUtils.cp(fixture('banana-lib/BananaLib.podspec'), @sandbox.root + 'Local Podspecs')
@sandbox.specification_path('BananaLib').should == @sandbox.root + 'Local Podspecs/BananaLib.podspec'
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Pods storage & source" do describe "Specification store" do
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
...@@ -88,10 +70,37 @@ module Pod ...@@ -88,10 +70,37 @@ module Pod
@sandbox.specification('BananaLib').name.should == 'BananaLib' @sandbox.specification('BananaLib').name.should == 'BananaLib'
end end
it "returns the directory where a Pod is stored" do it "returns the directory where to store the specifications" do
@sandbox.pod_dir('JSONKit').should == temporary_directory + 'Sandbox/JSONKit' @sandbox.specifications_dir.should == temporary_directory + 'Sandbox/Local Podspecs'
end
it "returns the path to a spec file in the 'Local Podspecs' dir" do
(@sandbox.root + 'Local Podspecs').mkdir
FileUtils.cp(fixture('banana-lib/BananaLib.podspec'), @sandbox.root + 'Local Podspecs')
@sandbox.specification_path('BananaLib').should == @sandbox.root + 'Local Podspecs/BananaLib.podspec'
end
it "stores a podspec with a given path into the sandbox" do
@sandbox.store_podspec('BananaLib', fixture('banana-lib/BananaLib.podspec'))
path = @sandbox.root + 'Local Podspecs/BananaLib.podspec'
path.should.exist
@sandbox.specification_path('BananaLib').should == path
end end
it "stores a podspec with the given string into the sandbox" do
podspec_string = fixture('banana-lib/BananaLib.podspec').read
@sandbox.store_podspec('BananaLib', podspec_string)
path = @sandbox.root + 'Local Podspecs/BananaLib.podspec'
path.should.exist
@sandbox.specification_path('BananaLib').should == path
end
end
#-------------------------------------------------------------------------#
describe "Pods information" do
it "returns the directory where a local Pod is stored" do it "returns the directory where a local Pod is stored" do
@sandbox.store_local_path('BananaLib', Pathname.new('Some Path')) @sandbox.store_local_path('BananaLib', Pathname.new('Some Path'))
@sandbox.pod_dir('BananaLib').should.be == Pathname.new('Some Path') @sandbox.pod_dir('BananaLib').should.be == Pathname.new('Some Path')
...@@ -100,7 +109,12 @@ module Pod ...@@ -100,7 +109,12 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "stores the list of the names of the pre-downloaded pods" do it "stores the list of the names of the pre-downloaded pods" do
@sandbox.predownloaded_pods << 'BananaLib' @sandbox.store_pre_downloaded_pod('BananaLib')
@sandbox.predownloaded_pods.should == ['BananaLib']
end
it "returns the checkout sources of the Pods" do
@sandbox.store_pre_downloaded_pod('BananaLib/Subspec')
@sandbox.predownloaded_pods.should == ['BananaLib'] @sandbox.predownloaded_pods.should == ['BananaLib']
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