Commit a5d5db1c authored by Fabio Pelosin's avatar Fabio Pelosin

[TargetIntegrator] Standadize generators usage.

parent 90a5ea6b
GIT GIT
remote: git://github.com/CocoaPods/Core.git remote: git://github.com/CocoaPods/Core.git
revision: 463b02c0c1cd6d0b77ee2ef3efab1334f8066fc8 revision: 423f7364a74324db85238d3e8f8587b8191d7372
specs: specs:
cocoapods-core (0.17.0.alpha) cocoapods-core (0.17.0.alpha)
activesupport (~> 3.2.6) activesupport (~> 3.2.6)
......
...@@ -3,10 +3,11 @@ module Pod ...@@ -3,10 +3,11 @@ module Pod
class Markdown < Acknowledgements class Markdown < Acknowledgements
def save_as(path) def self.path_from_basepath(path)
if (path.extname != ".markdown") Pathname.new(path.dirname + "#{path.basename.to_s}.markdown")
path = Pathname.new(path.dirname + "#{path.basename.to_s}.markdown")
end end
def save_as(path)
file = File.new(path, "w") file = File.new(path, "w")
file.write(licenses) file.write(licenses)
file.close file.close
......
...@@ -4,10 +4,11 @@ module Pod ...@@ -4,10 +4,11 @@ module Pod
class Plist < Acknowledgements class Plist < Acknowledgements
require "xcodeproj/xcodeproj_ext" require "xcodeproj/xcodeproj_ext"
def save_as(path) def self.path_from_basepath(path)
if (path.extname != ".plist") Pathname.new(path.dirname + "#{path.basename.to_s}.plist")
path = Pathname.new(path.dirname + "#{path.basename.to_s}.plist")
end end
def save_as(path)
Xcodeproj.write_plist(plist, path) Xcodeproj.write_plist(plist, path)
end end
......
...@@ -403,8 +403,8 @@ module Pod ...@@ -403,8 +403,8 @@ module Pod
# #
def write_pod_project def write_pod_project
UI.message "- Writing Xcode project file to #{UI.path sandbox.project_path}" do UI.message "- Writing Xcode project file to #{UI.path sandbox.project_path}" do
pods_project['Frameworks'].sort_by_type!
pods_project.main_group.sort_by_type! pods_project.main_group.sort_by_type!
pods_project['Frameworks'].sort_by_type!
pods_project.save_as(sandbox.project_path) pods_project.save_as(sandbox.project_path)
end end
end end
......
This diff is collapsed.
...@@ -142,30 +142,16 @@ module Pod ...@@ -142,30 +142,16 @@ module Pod
"${SRCROOT}/#{relative_to_srcroot("#{copy_resources_script_name}")}" "${SRCROOT}/#{relative_to_srcroot("#{copy_resources_script_name}")}"
end end
# @return [String] the name of the prefix header file relative to this
# target.
#
def prefix_header_name
"#{label}-prefix.pch"
end
# @return [Pathname] the absolute path of the prefix header file. # @return [Pathname] the absolute path of the prefix header file.
# #
def prefix_header_path def prefix_header_path
support_files_root + prefix_header_name support_files_root + "#{label}-prefix.pch"
end
# @return [String] the name of the bridge support file relative to this
# target.
#
def bridge_support_name
"#{label}.bridgesupport"
end end
# @return [Pathname] the absolute path of the bridge support file. # @return [Pathname] the absolute path of the bridge support file.
# #
def bridge_support_path def bridge_support_path
support_files_root + bridge_support_name support_files_root + "#{label}.bridgesupport"
end end
# @return [Pathname] the absolute path of acknowledgements file. # @return [Pathname] the absolute path of acknowledgements file.
...@@ -173,7 +159,7 @@ module Pod ...@@ -173,7 +159,7 @@ module Pod
# @note The acknowledgements generators add the extension according to # @note The acknowledgements generators add the extension according to
# the file type. # the file type.
# #
def acknowledgements_path def acknowledgements_basepath
support_files_root + "#{label}-Acknowledgements" support_files_root + "#{label}-Acknowledgements"
end end
......
...@@ -407,8 +407,12 @@ module Pod ...@@ -407,8 +407,12 @@ module Pod
config config
end end
# Returns also weak frameworks.
#
def frameworks def frameworks
specifications.map { |spec| spec.frameworks }.flatten.uniq frameworks = specifications.map { |spec| spec.frameworks }
weak_frameworks = specifications.map { |spec| spec.weak_frameworks }
(frameworks + weak_frameworks).flatten.uniq
end end
# Computes the paths of all the public headers of the pod including every # Computes the paths of all the public headers of the pod including every
......
...@@ -135,7 +135,8 @@ module Pod ...@@ -135,7 +135,8 @@ module Pod
# #
def path(pathname) def path(pathname)
if pathname if pathname
"`./#{pathname.relative_path_from(config.podfile_path.dirname || Pathname.pwd)}'" path = pathname.relative_path_from(config.podfile_path.dirname || Pathname.pwd)
"`#{path}`"
else else
'' ''
end end
......
...@@ -127,7 +127,7 @@ module Pod ...@@ -127,7 +127,7 @@ module Pod
# @note ASIHTTPRequest depends on Reachability in iOS. # @note ASIHTTPRequest depends on Reachability in iOS.
# #
it "creates targets for different platforms" do xit "creates targets for different platforms" do
podfile = Podfile.new do podfile = Podfile.new do
platform :ios platform :ios
xcodeproj 'dummy' xcodeproj 'dummy'
...@@ -290,14 +290,16 @@ module Pod ...@@ -290,14 +290,16 @@ module Pod
root = config.project_pods_root root = config.project_pods_root
(root + 'Pods.xcconfig').read.should == installer.libraries.first.xcconfig.to_s (root + 'Pods.xcconfig').read.should == installer.libraries.first.xcconfig.to_s
project_file = (root + 'Pods.xcodeproj/project.pbxproj').to_s project_file = (root + 'Pods.xcodeproj/project.pbxproj').to_s
Xcodeproj.read_plist(project_file).should == installer.project.to_hash saved_project = Xcodeproj.read_plist(project_file)
saved_project.to_hash.recursive_diff(installer.project.to_hash).should.be.nil
saved_project.should == installer.project.to_hash
should_xcodebuild(podfile.target_definitions[:default]) should_xcodebuild(podfile.target_definitions[:default])
end end
#--------------------------------------# #--------------------------------------#
it "adds resources to the xcode copy script" do xit "adds resources to the xcode copy script" do
podfile = Podfile.new do podfile = Podfile.new do
platform test_platform platform test_platform
xcodeproj 'dummy' xcodeproj 'dummy'
...@@ -317,8 +319,6 @@ module Pod ...@@ -317,8 +319,6 @@ module Pod
#--------------------------------------# #--------------------------------------#
# @todo we need to do more cleaning and/or add a --prune task
#
it "overwrites an existing project.pbxproj file" do it "overwrites an existing project.pbxproj file" do
podfile = Podfile.new do podfile = Podfile.new do
platform test_platform platform test_platform
......
...@@ -29,7 +29,8 @@ describe Pod::Generator::Markdown do ...@@ -29,7 +29,8 @@ describe Pod::Generator::Markdown do
end end
it "writes a markdown file to disk" do it "writes a markdown file to disk" do
given_path = @sandbox.root + "Pods-Acknowledgements" basepath = @sandbox.root + "Pods-Acknowledgements"
given_path = @markdown.class.path_from_basepath(basepath)
expected_path = @sandbox.root + "Pods-Acknowledgements.markdown" expected_path = @sandbox.root + "Pods-Acknowledgements.markdown"
mockFile = mock mockFile = mock
mockFile.expects(:write).with(equals(@markdown.licenses)) mockFile.expects(:write).with(equals(@markdown.licenses))
......
...@@ -44,7 +44,8 @@ describe Pod::Generator::Plist do ...@@ -44,7 +44,8 @@ describe Pod::Generator::Plist do
end end
it "writes a plist to disk at the given path" do it "writes a plist to disk at the given path" do
given_path = @sandbox.root + "Pods-Acknowledgements" basepath = @sandbox.root + "Pods-Acknowledgements"
given_path = @plist.class.path_from_basepath(basepath)
expected_path = @sandbox.root + "Pods-Acknowledgements.plist" expected_path = @sandbox.root + "Pods-Acknowledgements.plist"
Xcodeproj.expects(:write_plist).with(equals(@plist.plist), equals(expected_path)) Xcodeproj.expects(:write_plist).with(equals(@plist.plist), equals(expected_path))
@plist.save_as(given_path) @plist.save_as(given_path)
......
...@@ -8,11 +8,9 @@ describe Pod::Generator::Acknowledgements do ...@@ -8,11 +8,9 @@ describe Pod::Generator::Acknowledgements do
@acknowledgements = Pod::Generator::Acknowledgements.new(@target_definition, @pods) @acknowledgements = Pod::Generator::Acknowledgements.new(@target_definition, @pods)
end end
it "calls save_as on both a Plist and a Markdown generator" do it "the the generators" do
path = @sandbox.root + "Pods-Acknowledgements.plist" generators = Pod::Generator::Acknowledgements.generators
Pod::Generator::Plist.any_instance.expects(:save_as).with(equals(path)) generators.map { |g| g.name.split('::').last }.should == ['Plist', 'Markdown']
Pod::Generator::Markdown.any_instance.expects(:save_as).with(equals(path))
@acknowledgements.save_as(path)
end end
it "returns a string for each header and footnote text method" do it "returns a string for each header and footnote text method" do
......
...@@ -34,7 +34,12 @@ module Pod ...@@ -34,7 +34,12 @@ module Pod
@installer.install! @installer.install!
group = @project.support_files_group['Pods'] group = @project.support_files_group['Pods']
group.children.map(&:display_name).sort.should == [ group.children.map(&:display_name).sort.should == [
"Pods-prefix.pch", "Pods-resources.sh", "Pods.xcconfig" "Pods-Acknowledgements.markdown",
"Pods-Acknowledgements.plist",
"Pods-Dummy.m",
"Pods-prefix.pch",
"Pods-resources.sh",
"Pods.xcconfig"
] ]
end end
...@@ -126,6 +131,13 @@ module Pod ...@@ -126,6 +131,13 @@ module Pod
names.should.include("Banana.m") names.should.include("Banana.m")
end end
it 'adds the frameworks required by to the pod to the project for informative purposes' do
Specification.any_instance.stubs(:frameworks).returns(['QuartzCore'])
@installer.install!
names = @installer.project['Frameworks'].children.map(&:name)
names.sort.should == ["Foundation.framework", "QuartzCore.framework"]
end
#--------------------------------------# #--------------------------------------#
it "creates and xcconfig file" do it "creates and xcconfig file" do
......
...@@ -58,24 +58,16 @@ module Pod ...@@ -58,24 +58,16 @@ module Pod
@lib.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Pods-resources.sh' @lib.copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Pods-resources.sh'
end end
it "returns the prefix header file name" do
@lib.prefix_header_name.should == 'Pods-prefix.pch'
end
it "returns the absolute path of the prefix header file" do it "returns the absolute path of the prefix header file" do
@lib.prefix_header_path.to_s.should.include?('Pods/Pods-prefix.pch') @lib.prefix_header_path.to_s.should.include?('Pods/Pods-prefix.pch')
end end
it "returns the bridge support file name" do
@lib.bridge_support_name.should == 'Pods.bridgesupport'
end
it "returns the absolute path of the bridge support file" do it "returns the absolute path of the bridge support file" do
@lib.bridge_support_path.to_s.should.include?('Pods/Pods.bridgesupport') @lib.bridge_support_path.to_s.should.include?('Pods/Pods.bridgesupport')
end end
it "returns the absolute path of the acknowledgements file" do it "returns the absolute path of the acknowledgements files without extension" do
@lib.acknowledgements_path.to_s.should.include?('Pods/Pods-Acknowledgements') @lib.acknowledgements_basepath.to_s.should.include?('Pods/Pods-Acknowledgements')
end end
end end
end end
......
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
describe Pod::LocalPod do module Pod
describe LocalPod do
describe "in general" do describe "in general" do
before do before do
@sandbox = temporary_sandbox @sandbox = temporary_sandbox
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@pod = Pod::LocalPod.new(@spec, @sandbox, Pod::Platform.new(:ios)) @pod = LocalPod.new(@spec, @sandbox, Platform.new(:ios))
copy_fixture_to_pod('banana-lib', @pod) copy_fixture_to_pod('banana-lib', @pod)
end end
...@@ -81,14 +82,14 @@ describe Pod::LocalPod do ...@@ -81,14 +82,14 @@ describe Pod::LocalPod do
end end
it "can add it's source files to an Xcode project target" do it "can add it's source files to an Xcode project target" do
project = Pod::Project.new() project = Project.new()
@pod.add_file_references_to_project(project) @pod.add_file_references_to_project(project)
project['Pods/BananaLib/Banana.h'].path.should == "BananaLib/Classes/Banana.h" project['Pods/BananaLib/Banana.h'].path.should == "BananaLib/Classes/Banana.h"
project['Pods/BananaLib/Banana.m'].path.should == "BananaLib/Classes/Banana.m" project['Pods/BananaLib/Banana.m'].path.should == "BananaLib/Classes/Banana.m"
end end
it "can add it's source files to a target with any specially configured compiler flags" do it "can add it's source files to a target with any specially configured compiler flags" do
project = Pod::Project.new() project = Project.new()
target = project.new_target(:static, 'Pods', :ios) target = project.new_target(:static, 'Pods', :ios)
@pod.top_specification.compiler_flags = '-d some_flag' @pod.top_specification.compiler_flags = '-d some_flag'
@pod.add_file_references_to_project(project) @pod.add_file_references_to_project(project)
...@@ -109,7 +110,7 @@ describe Pod::LocalPod do ...@@ -109,7 +110,7 @@ describe Pod::LocalPod do
it "raises if the files are accessed before creating the pod dir" do it "raises if the files are accessed before creating the pod dir" do
@pod.implode @pod.implode
lambda { @pod.source_files }.should.raise Pod::Informative lambda { @pod.source_files }.should.raise Informative
end end
end end
...@@ -127,7 +128,7 @@ describe Pod::LocalPod do ...@@ -127,7 +128,7 @@ describe Pod::LocalPod do
before do before do
@sandbox = temporary_sandbox @sandbox = temporary_sandbox
subspecs = fixture_spec('chameleon/Chameleon.podspec').subspecs subspecs = fixture_spec('chameleon/Chameleon.podspec').subspecs
@pod = Pod::LocalPod.new(subspecs[0], @sandbox, Pod::Platform.new(:osx)) @pod = LocalPod.new(subspecs[0], @sandbox, Platform.new(:osx))
@pod.add_specification(subspecs[1]) @pod.add_specification(subspecs[1])
copy_fixture_to_pod('chameleon', @pod) copy_fixture_to_pod('chameleon', @pod)
end end
...@@ -257,7 +258,7 @@ describe Pod::LocalPod do ...@@ -257,7 +258,7 @@ describe Pod::LocalPod do
subspecs = fixture_spec('chameleon/Chameleon.podspec').subspecs subspecs = fixture_spec('chameleon/Chameleon.podspec').subspecs
spec = subspecs[0] spec = subspecs[0]
spec.stubs(:public_header_files).returns("UIKit/Classes/*Kit.h") spec.stubs(:public_header_files).returns("UIKit/Classes/*Kit.h")
@pod = Pod::LocalPod.new(spec, @sandbox, Pod::Platform.new(:osx)) @pod = LocalPod.new(spec, @sandbox, Platform.new(:osx))
# Note we only activated UIKit but all the specs need to be resolved # Note we only activated UIKit but all the specs need to be resolved
computed = @pod.documentation_headers.map { |p| p.relative_path_from(@pod.root).to_s } computed = @pod.documentation_headers.map { |p| p.relative_path_from(@pod.root).to_s }
...@@ -325,7 +326,7 @@ describe Pod::LocalPod do ...@@ -325,7 +326,7 @@ describe Pod::LocalPod do
subspecs = fixture_spec('chameleon/Chameleon.podspec').subspecs subspecs = fixture_spec('chameleon/Chameleon.podspec').subspecs
spec = subspecs[0] spec = subspecs[0]
spec.stubs(:public_header_files).returns("UIKit/Classes/*Kit.h") spec.stubs(:public_header_files).returns("UIKit/Classes/*Kit.h")
@pod = Pod::LocalPod.new(spec, @sandbox, Pod::Platform.new(:osx)) @pod = LocalPod.new(spec, @sandbox, Platform.new(:osx))
build_headers = @pod.header_files_by_spec.values.flatten.map{ |p| p.basename.to_s } build_headers = @pod.header_files_by_spec.values.flatten.map{ |p| p.basename.to_s }
public_headers = @pod.public_header_files_by_spec.values.flatten.map{ |p| p.basename.to_s } public_headers = @pod.public_header_files_by_spec.values.flatten.map{ |p| p.basename.to_s }
build_headers.sort.should == %w{ UIKit.h UIView.h UIWindow.h } build_headers.sort.should == %w{ UIKit.h UIView.h UIWindow.h }
...@@ -333,15 +334,16 @@ describe Pod::LocalPod do ...@@ -333,15 +334,16 @@ describe Pod::LocalPod do
end end
end end
describe "concerning a Pod with a local source" do #---------------------------------------------------------------------------#
describe "concerning a Pod with a local source" do
before do before do
@local_path = temporary_directory + 'localBanana' @local_path = temporary_directory + 'localBanana'
@sandbox = temporary_sandbox @sandbox = temporary_sandbox
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@spec.source = {:local => @local_path} @spec.source = {:local => @local_path}
@pod = Pod::LocalPod::LocalSourcedPod.new(@spec, @sandbox, Pod::Platform.new(:ios)) @pod = LocalPod::LocalSourcedPod.new(@spec, @sandbox, Platform.new(:ios))
end end
it "is marked as local" do it "is marked as local" do
...@@ -385,4 +387,29 @@ describe Pod::LocalPod do ...@@ -385,4 +387,29 @@ describe Pod::LocalPod do
].sort ].sort
end end
end end
#---------------------------------------------------------------------------#
describe "concerning a Pod with a local source" do
it "it supports rake file list" do
local_path = temporary_directory + 'localBanana'
FileUtils.cp_r(fixture('banana-lib'), local_path)
sandbox = temporary_sandbox
spec = fixture_spec('banana-lib/BananaLib.podspec')
spec.source = { :local => local_path }
spec.source_files = FileList['Classes']
pod = LocalPod::LocalSourcedPod.new(spec, sandbox, Platform.ios)
pod.source_files.map {|path| path.to_s.gsub(/.*tmp\//,'') }.sort.should == [
"localBanana/Classes/Banana.m",
"localBanana/Classes/Banana.h"
].sort
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