Commit 60caa667 authored by Eloy Duran's avatar Eloy Duran

Fix bug that would copy Pods.xcodeproj dir into existing one.

parent 78f52d3c
...@@ -10,3 +10,11 @@ task :clean do ...@@ -10,3 +10,11 @@ task :clean do
sh "rm -f lib/**/*.rbo" sh "rm -f lib/**/*.rbo"
sh "rm -f *.gem" sh "rm -f *.gem"
end end
desc "Install a gem version of the current code"
task :install do
require 'lib/cocoapods'
sh "gem build cocoapods.gemspec"
sh "sudo macgem install cocoapods-#{Pod::VERSION}.gem"
sh "sudo macgem compile cocoapods"
end
module Pod module Pod
VERSION = '0.0.2' VERSION = '0.0.3'
class Informative < StandardError class Informative < StandardError
end end
......
...@@ -32,13 +32,13 @@ module Pod ...@@ -32,13 +32,13 @@ module Pod
if @podspec.exist? if @podspec.exist?
spec = Specification.from_podspec(@podspec) spec = Specification.from_podspec(@podspec)
else else
raise Help, "The specified podspec `#{@podspec}' doesn't exist." raise Informative, "The specified podspec `#{@podspec}' doesn't exist."
end end
else else
if config.project_podfile.exist? if config.project_podfile
spec = Specification.from_podfile(config.project_podfile) spec = Specification.from_podfile(config.project_podfile)
else else
raise Help, "No Podfile found in current working directory." raise Informative, "No `Podfile' or `.podspec' file found in the current working directory."
end end
end end
Installer.new(spec).install! Installer.new(spec).install!
......
...@@ -3,6 +3,8 @@ framework 'Foundation' ...@@ -3,6 +3,8 @@ framework 'Foundation'
module Pod module Pod
module Xcode module Xcode
class Project class Project
include Pod::Config::Mixin
# TODO this is a workaround for an issue with MacRuby with compiled files # TODO this is a workaround for an issue with MacRuby with compiled files
# that makes the use of __FILE__ impossible. # that makes the use of __FILE__ impossible.
# #
...@@ -62,10 +64,10 @@ module Pod ...@@ -62,10 +64,10 @@ module Pod
end end
def create_in(pods_root) def create_in(pods_root)
@template_dir.children.each do |child| puts " * Copying contents of template directory `#{@template_dir}' to `#{pods_root}'" if config.verbose?
FileUtils.cp_r(child, pods_root + child.relative_path_from(@template_dir)) FileUtils.cp_r("#{@template_dir}/.", pods_root)
end
pbxproj = pods_root + template_file pbxproj = pods_root + template_file
puts " * Writing Xcode project file to `#{pbxproj}'" if config.verbose?
@template.writeToFile(pbxproj.to_s, atomically:true) @template.writeToFile(pbxproj.to_s, atomically:true)
end end
......
...@@ -31,8 +31,14 @@ else ...@@ -31,8 +31,14 @@ else
Pod::Source.reset! Pod::Source.reset!
Pod::Spec::Set.reset! Pod::Spec::Set.reset!
fixture('spec-repos/master') # ensure the archive is unpacked fixture('spec-repos/master') # ensure the archive is unpacked
config.project_pods_root = temporary_directory + 'Pods'
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
config.project_pods_root = temporary_directory + 'Pods'
FileUtils.cp_r(fixture('integration/.'), config.project_pods_root)
Dir.chdir(config.project_pods_root.to_s) do
FileUtils.mv('ASIHTTPRequest', 'ASIHTTPRequest-1.8.1')
FileUtils.mv('JSONKit', 'JSONKit-1.4')
FileUtils.mv('SSZipArchive', 'SSZipArchive-1.0')
end
end end
after do after do
...@@ -40,9 +46,10 @@ else ...@@ -40,9 +46,10 @@ else
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
end end
# TODO add a simple source file which uses the compiled lib to check that it really really works
it "should activate required pods and create a working static library xcode project" do it "should activate required pods and create a working static library xcode project" do
spec = Pod::Spec.new do spec = Pod::Spec.new do
dependency 'ASIWebPageRequest', '< 1.8.1' dependency 'ASIWebPageRequest', '>= 1.8.1'
dependency 'JSONKit', '>= 1.0' dependency 'JSONKit', '>= 1.0'
dependency 'SSZipArchive', '< 2' dependency 'SSZipArchive', '< 2'
end end
...@@ -79,5 +86,25 @@ else ...@@ -79,5 +86,25 @@ else
(config.project_pods_root + 'Reachability.podspec').should.exist (config.project_pods_root + 'Reachability.podspec').should.exist
(config.project_pods_root + 'ASIHTTPRequest.podspec').should.not.exist (config.project_pods_root + 'ASIHTTPRequest.podspec').should.not.exist
end end
# TODO we need to do more cleaning and/or add a --prune task
it "overwrites an existing project.pbxproj file" do
spec = Pod::Spec.new do
dependency 'JSONKit'
end
installer = SpecHelper::Installer.new(spec)
installer.install!
Pod::Source.reset!
Pod::Spec::Set.reset!
spec = Pod::Spec.new do
dependency 'SSZipArchive'
end
installer = SpecHelper::Installer.new(spec)
installer.install!
project = Pod::Xcode::Project.new(config.project_pods_root)
project.source_files.sort.should == Pod::Installer.new(spec).source_files.sort
end
end end
end end
...@@ -24,3 +24,21 @@ describe "Pod::Command::Repo" do ...@@ -24,3 +24,21 @@ describe "Pod::Command::Repo" do
lambda { Pod::Command::Repo.new(argv('something')) }.should.raise Pod::Command::Help lambda { Pod::Command::Repo.new(argv('something')) }.should.raise Pod::Command::Help
end end
end end
describe "Pod::Command::Install" do
it "tells the user that the specified podspec file doesn't exist" do
command = Pod::Command::Install.new(argv('/does/not/exist/Some.podspec'))
exception = lambda {
command.run
}.should.raise Pod::Informative
exception.message.should.include "The specified podspec `/does/not/exist/Some.podspec' doesn't exist."
end
it "tells the user that no Podfile or podspec was found in the current working dir" do
command = Pod::Command::Install.new(argv)
exception = lambda {
command.run
}.should.raise Pod::Informative
exception.message.should.include "No `Podfile' or `.podspec' file found in the current working directory."
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