Skip to content

Commit

Permalink
Make UserProjectIntegrator work again.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Apr 13, 2012
1 parent 3a9bf89 commit d51f5a0
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 32 deletions.
12 changes: 6 additions & 6 deletions .kick
Expand Up @@ -4,12 +4,12 @@ Kicker::Recipes::Ruby.runner_bin = 'bacon'


process do |files| process do |files|
specs = files.take_and_map do |file| specs = files.take_and_map do |file|
case file if file =~ %r{lib/cocoapods/(.+?)\.rb$}
when %r{lib/cocoapods/installer.+\.rb$} s = Dir.glob("spec/**/#{File.basename(file, '.rb')}_spec.rb")
['spec/unit/installer_spec.rb', 'spec/unit/installer/target_installer_spec.rb'] if file =~ %r{lib/cocoapods/installer.+\.rb$}
when %r{lib/cocoapods/(.+?)\.rb$} s.concat(['spec/unit/installer_spec.rb', 'spec/unit/installer/target_installer_spec.rb'])
s = Dir.glob("spec/**/#{$1}_spec.rb") end
s unless s.empty? s.uniq unless s.empty?
end end
end end
Kicker::Recipes::Ruby.run_tests(specs) Kicker::Recipes::Ruby.run_tests(specs)
Expand Down
4 changes: 2 additions & 2 deletions lib/cocoapods/command/install.rb
Expand Up @@ -11,7 +11,7 @@ def self.banner
The Xcode project file should be specified in your `Podfile` like this: The Xcode project file should be specified in your `Podfile` like this:
xcodeproj "path/to/project.xcodeproj" xcodeproj 'path/to/project.xcodeproj'
If no xcodeproj is specified, then a search for an Xcode project will If no xcodeproj is specified, then a search for an Xcode project will
be made. If more than one Xcode project is found, the command will be made. If more than one Xcode project is found, the command will
Expand Down Expand Up @@ -59,7 +59,7 @@ def run
Repo.new(ARGV.new(["update"])).run Repo.new(ARGV.new(["update"])).run
end end


Installer.new(podfile, @projpath).install! Installer.new(podfile).install!
end end
end end
end end
Expand Down
6 changes: 3 additions & 3 deletions lib/cocoapods/installer.rb
Expand Up @@ -9,8 +9,8 @@ class Installer


attr_reader :sandbox attr_reader :sandbox


def initialize(podfile, user_project_path = nil) def initialize(podfile)
@podfile, @user_project_path = podfile, user_project_path @podfile = podfile
# FIXME: pass this into the installer as a parameter # FIXME: pass this into the installer as a parameter
@sandbox = Sandbox.new(config.project_pods_root) @sandbox = Sandbox.new(config.project_pods_root)
@resolver = Resolver.new(@podfile, @sandbox) @resolver = Resolver.new(@podfile, @sandbox)
Expand Down Expand Up @@ -91,7 +91,7 @@ def install!
puts "* Writing Xcode project file to `#{@sandbox.project_path}'\n\n" if config.verbose? puts "* Writing Xcode project file to `#{@sandbox.project_path}'\n\n" if config.verbose?
project.save_as(@sandbox.project_path) project.save_as(@sandbox.project_path)


UserProjectIntegrator.new(@podfile.xcodeproj, @podfile).integrate! UserProjectIntegrator.new(@podfile).integrate! if @podfile.xcodeproj
end end


def run_post_install_hooks def run_post_install_hooks
Expand Down
16 changes: 10 additions & 6 deletions lib/cocoapods/installer/user_project_integrator.rb
Expand Up @@ -7,12 +7,8 @@ class Installer
class UserProjectIntegrator class UserProjectIntegrator
include Pod::Config::Mixin include Pod::Config::Mixin


attr_reader :user_project_path, :user_project def initialize(podfile)

def initialize(user_project_path, podfile)
@user_project_path = config.project_root + user_project_path
@podfile = podfile @podfile = podfile
@user_project = Xcodeproj::Project.new(user_project_path)
end end


def integrate! def integrate!
Expand All @@ -21,7 +17,7 @@ def integrate!
# Only need to write out the user's project if any of the target # Only need to write out the user's project if any of the target
# integrators actually did some work. # integrators actually did some work.
if targets.map(&:integrate!).any? if targets.map(&:integrate!).any?
@user_project.save_as(user_project_path) user_project.save_as(user_project_path)
end end


unless config.silent? unless config.silent?
Expand All @@ -30,6 +26,14 @@ def integrate!
end end
end end


def user_project_path
@podfile.xcodeproj
end

def user_project
@user_project ||= Xcodeproj::Project.new(user_project_path)
end

def workspace_path def workspace_path
config.project_root + "#{user_project_path.basename('.xcodeproj')}.xcworkspace" config.project_root + "#{user_project_path.basename('.xcodeproj')}.xcworkspace"
end end
Expand Down
12 changes: 8 additions & 4 deletions spec/functional/user_project_integrator_spec.rb
Expand Up @@ -4,10 +4,16 @@
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory


before do before do
@sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
config.project_root = @sample_project_path.dirname

sample_project_path = @sample_project_path
@podfile = Pod::Podfile.new do @podfile = Pod::Podfile.new do
platform :ios platform :ios


xcodeproj sample_project_path
link_with 'SampleProject' # this is an app target! link_with 'SampleProject' # this is an app target!

dependency 'JSONKit' dependency 'JSONKit'


target :test_runner, :exclusive => true do target :test_runner, :exclusive => true do
Expand All @@ -16,11 +22,9 @@
end end
end end


@sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') @integrator = Pod::Installer::UserProjectIntegrator.new(@podfile)
config.project_root = @sample_project_path.dirname

@integrator = Pod::Installer::UserProjectIntegrator.new(@sample_project_path, @podfile)
@integrator.integrate! @integrator.integrate!

@sample_project = Xcodeproj::Project.new(@sample_project_path) @sample_project = Xcodeproj::Project.new(@sample_project_path)
end end


Expand Down
7 changes: 5 additions & 2 deletions spec/integration_spec.rb
Expand Up @@ -367,11 +367,14 @@ def should_xcodebuild(target_definition)
basename = platform == :ios ? 'iPhone' : 'Mac' basename = platform == :ios ? 'iPhone' : 'Mac'
projpath = temporary_directory + 'ASIHTTPRequest.xcodeproj' projpath = temporary_directory + 'ASIHTTPRequest.xcodeproj'
FileUtils.cp_r(fixture("integration/ASIHTTPRequest/#{basename}.xcodeproj"), projpath) FileUtils.cp_r(fixture("integration/ASIHTTPRequest/#{basename}.xcodeproj"), projpath)
spec = Pod::Podfile.new do
podfile = Pod::Podfile.new do
self.platform platform self.platform platform
xcodeproj projpath
dependency 'SSZipArchive' dependency 'SSZipArchive'
end end
installer = SpecHelper::Installer.new(spec, projpath)
installer = SpecHelper::Installer.new(podfile)
installer.install! installer.install!


workspace = Xcodeproj::Workspace.new_from_xcworkspace(temporary_directory + 'ASIHTTPRequest.xcworkspace') workspace = Xcodeproj::Workspace.new_from_xcworkspace(temporary_directory + 'ASIHTTPRequest.xcworkspace')
Expand Down
@@ -1,8 +1,8 @@
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)


describe "Pod::Command::Install" do describe "Pod::Command::Install" do
it "should include instructions on how to reference the xcode project" do it "should include instructions on how to reference the xcode project" do
Pod::Command::Install.banner.should.match /xcodeproj path\/to\/project.xcodeproj/ Pod::Command::Install.banner.should.match %r{xcodeproj 'path/to/project\.xcodeproj'}
end end


before do before do
Expand All @@ -17,9 +17,10 @@


describe "When the Podfile does not specify the xcodeproject" do describe "When the Podfile does not specify the xcodeproject" do
before do before do
config.stubs(:rootspec).returns(Pod::Podfile.new { platform :ios; dependency 'AFNetworking'}) config.stubs(:podfile).returns(Pod::Podfile.new { platform :ios; dependency 'AFNetworking'})
@installer = Pod::Command::Install.new(Pod::Command::ARGV.new) @installer = Pod::Command::Install.new(Pod::Command::ARGV.new)
end end

it "raises an informative error" do it "raises an informative error" do
should.raise(Pod::Informative) { @installer.run } should.raise(Pod::Informative) { @installer.run }
end end
Expand All @@ -28,14 +29,14 @@
begin begin
@installer.run @installer.run
rescue Pod::Informative => err rescue Pod::Informative => err
err.message.should.match /xcodeproj 'path\/to\/project\.xcodeproj/ err.message.should.match %r{xcodeproj 'path/to/project\.xcodeproj'}
end end
end end
end end


describe "When the Podfile specifies xcodeproj to an invalid path" do describe "When the Podfile specifies xcodeproj to an invalid path" do
before do before do
config.stubs(:rootspec).returns(Pod::Podfile.new { platform :ios; xcodeproj 'nonexistent/project.xcodeproj'; dependency 'AFNetworking'}) config.stubs(:podfile).returns(Pod::Podfile.new { platform :ios; xcodeproj 'nonexistent/project.xcodeproj'; dependency 'AFNetworking'})
@installer = Pod::Command::Install.new(Pod::Command::ARGV.new) @installer = Pod::Command::Install.new(Pod::Command::ARGV.new)
end end


Expand Down
10 changes: 6 additions & 4 deletions spec/unit/installer/user_project_integrator_spec.rb
Expand Up @@ -4,19 +4,21 @@
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory


before do before do
@sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
config.project_root = @sample_project_path.dirname

sample_project_path = @sample_project_path
@podfile = Pod::Podfile.new do @podfile = Pod::Podfile.new do
platform :ios platform :ios
xcodeproj sample_project_path
dependency 'JSONKit' dependency 'JSONKit'
target :test_runner, :exclusive => true do target :test_runner, :exclusive => true do
link_with 'TestRunner' link_with 'TestRunner'
dependency 'Kiwi' dependency 'Kiwi'
end end
end end


@sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') @integrator = Pod::Installer::UserProjectIntegrator.new(@podfile)
config.project_root = @sample_project_path.dirname

@integrator = Pod::Installer::UserProjectIntegrator.new(@sample_project_path, @podfile)
end end


after do after do
Expand Down

0 comments on commit d51f5a0

Please sign in to comment.