Commit 04843c3d authored by Eloy Duran's avatar Eloy Duran

Make specs green.

parent fcdd011c
...@@ -21,13 +21,10 @@ module Pod ...@@ -21,13 +21,10 @@ module Pod
def project def project
return @project if @project return @project if @project
@project = Pod::Project.for_platform(@podfile.platform) @project = Pod::Project.for_platform(@podfile.platform)
# First we need to resolve dependencies across *all* targets, so that the activated_pods.each do |pod|
# same correct versions of pods are being used for all targets. This
# happens when we call `activated_specifications'.
activated_specifications.each do |spec|
# Add all source files to the project grouped by pod # Add all source files to the project grouped by pod
group = @project.add_pod_group(spec.name) group = @project.add_pod_group(pod.name)
spec.expanded_source_files.each do |path| pod.source_files.each do |path|
group.files.new('path' => path.to_s) group.files.new('path' => path.to_s)
end end
end end
...@@ -43,31 +40,26 @@ module Pod ...@@ -43,31 +40,26 @@ module Pod
end end
def install_dependencies! def install_dependencies!
activated_specifications.map do |spec| activated_pods.each do |pod|
# TODO @podfile.platform will change to target_definition.platform marker = config.verbose ? "\n-> ".green : ''
LocalPod.new(spec, sandbox, @podfile.platform).tap do |pod|
marker = config.verbose ? "\n-> ".green : ''
should_install = !pod.exists? && !spec.local?
unless should_install unless should_install = !pod.exists? && !pod.specification.local?
puts marker + "Using #{pod}" unless config.silent? puts marker + "Using #{pod}" unless config.silent?
else else
puts marker + "Installing #{spec}".green unless config.silent? puts marker + "Installing #{spec}".green unless config.silent?
downloader = Downloader.for_pod(pod) downloader = Downloader.for_pod(pod)
downloader.download downloader.download
if config.clean if config.clean
downloader.clean downloader.clean
pod.clean pod.clean
end
end end
end
if (should_install && config.doc?) || config.force_doc? if (should_install && config.doc?) || config.force_doc?
puts "Installing Documentation for #{spec}".green if config.verbose? puts "Installing Documentation for #{spec}".green if config.verbose?
Generator::Documentation.new(pod).generate(config.doc_install?) Generator::Documentation.new(pod).generate(config.doc_install?)
end
end end
end end
end end
...@@ -79,8 +71,9 @@ module Pod ...@@ -79,8 +71,9 @@ module Pod
specs_by_target specs_by_target
puts_title "Installing dependencies" puts_title "Installing dependencies"
pods = install_dependencies! install_dependencies!
pods = activated_pods
puts_title("Generating support files\n", false) puts_title("Generating support files\n", false)
target_installers.each do |target_installer| target_installers.each do |target_installer|
target_specs = activated_specifications_for_target(target_installer.target_definition) target_specs = activated_specifications_for_target(target_installer.target_definition)
...@@ -117,7 +110,7 @@ module Pod ...@@ -117,7 +110,7 @@ module Pod
file.puts "PODS:" file.puts "PODS:"
pods.map do |pod| pods.map do |pod|
# TODO this should list _all_ the pods, so merge the platforms # TODO this should list _all_ the pods, so merge the platforms
dependencies = pod.specification.dependencies.values.flatten.uniq dependencies = pod.specification.dependencies[@podfile.platform.to_sym]
[pod.specification.to_s, dependencies.map(&:to_s).sort] [pod.specification.to_s, dependencies.map(&:to_s).sort]
end.sort_by(&:first).each do |name, deps| end.sort_by(&:first).each do |name, deps|
if deps.empty? if deps.empty?
...@@ -152,6 +145,13 @@ module Pod ...@@ -152,6 +145,13 @@ module Pod
specs_by_target.values.flatten specs_by_target.values.flatten
end end
def activated_pods
activated_specifications.map do |spec|
# TODO @podfile.platform will change to target_definition.platform
LocalPod.new(spec, sandbox, @podfile.platform)
end
end
def activated_specifications def activated_specifications
dependency_specifications.reject do |spec| dependency_specifications.reject do |spec|
# Don't activate specs which are only wrappers of subspecs, or share # Don't activate specs which are only wrappers of subspecs, or share
......
...@@ -77,7 +77,7 @@ module Pod ...@@ -77,7 +77,7 @@ module Pod
def add_to_target(target) def add_to_target(target)
implementation_files.each do |file| implementation_files.each do |file|
target.add_source_file(file, nil, specification.compiler_flags[@platform.to_sym]) target.add_source_file(file, nil, specification.compiler_flags[@platform.to_sym].strip)
end end
end end
...@@ -108,7 +108,6 @@ module Pod ...@@ -108,7 +108,6 @@ module Pod
def expanded_paths(platforms_with_patterns, options = {}) def expanded_paths(platforms_with_patterns, options = {})
patterns = platforms_with_patterns.is_a?(Hash) ? (platforms_with_patterns[@platform.to_sym] || []) : platforms_with_patterns patterns = platforms_with_patterns.is_a?(Hash) ? (platforms_with_patterns[@platform.to_sym] || []) : platforms_with_patterns
p platforms_with_patterns if patterns.nil?
patterns.map do |pattern| patterns.map do |pattern|
pattern = root + pattern pattern = root + pattern
......
module Pod module Pod
class Platform class Platform
def self.ios
new :ios
end
def self.osx
new :osx
end
attr_reader :options attr_reader :options
def initialize(symbolic_name, options = {}) def initialize(symbolic_name, options = {})
......
...@@ -235,7 +235,7 @@ module Pod ...@@ -235,7 +235,7 @@ module Pod
end end
def wrapper? def wrapper?
source_files.values.flatten.empty? && !subspecs.empty? source_files.values.all?(&:empty?) && !subspecs.empty?
end end
def subspec_by_name(name) def subspec_by_name(name)
......
...@@ -60,7 +60,7 @@ describe "Pod::Command" do ...@@ -60,7 +60,7 @@ describe "Pod::Command" do
spec.authors.should == { `git config --get user.name`.strip => `git config --get user.email`.strip, "other author" => "and email address" } spec.authors.should == { `git config --get user.name`.strip => `git config --get user.email`.strip, "other author" => "and email address" }
spec.source.should == { :git => 'http://EXAMPLE/Bananas.git', :tag => '1.0.0' } spec.source.should == { :git => 'http://EXAMPLE/Bananas.git', :tag => '1.0.0' }
spec.description.should == 'An optional longer description of Bananas.' spec.description.should == 'An optional longer description of Bananas.'
spec.source_files.should == ['Classes', 'Classes/**/*.{h,m}'] spec.source_files[:ios].should == ['Classes', 'Classes/**/*.{h,m}']
end end
before do before do
......
...@@ -2,7 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,7 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Downloader" do describe "Pod::Downloader" do
before do before do
@pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), temporary_sandbox) @pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), temporary_sandbox, Pod::Platform.ios)
end end
describe "for Git" do describe "for Git" do
......
...@@ -184,7 +184,7 @@ else ...@@ -184,7 +184,7 @@ else
# TODO add a simple source file which uses the compiled lib to check that it really really works # TODO add a simple source file which uses the compiled lib to check that it really really works
it "activates required pods and create a working static library xcode project" do it "activates required pods and create a working static library xcode project" do
spec = Pod::Podfile.new do podfile = Pod::Podfile.new do
# first ensure that the correct info is available to the specs when they load # first ensure that the correct info is available to the specs when they load
config.rootspec = self config.rootspec = self
...@@ -195,7 +195,7 @@ else ...@@ -195,7 +195,7 @@ else
dependency 'SSZipArchive', '< 2' dependency 'SSZipArchive', '< 2'
end end
installer = SpecHelper::Installer.new(spec) installer = SpecHelper::Installer.new(podfile)
installer.install! installer.install!
lock_file_contents = { lock_file_contents = {
......
...@@ -2,7 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,7 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__)
def stub_pod_with_source(source_options) def stub_pod_with_source(source_options)
specification = stub( specification = stub(
:part_of_other_pod? => false, :part_of_other_pod? => false,
:source => source_options :source => source_options
) )
stub('pod') do stub('pod') do
...@@ -13,7 +13,7 @@ end ...@@ -13,7 +13,7 @@ end
describe "Pod::Downloader" do describe "Pod::Downloader" do
it "returns a git downloader with parsed options" do it "returns a git downloader with parsed options" do
pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), temporary_sandbox) pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), temporary_sandbox, Pod::Platform.ios)
downloader = Pod::Downloader.for_pod(pod) downloader = Pod::Downloader.for_pod(pod)
downloader.should.be.instance_of Pod::Downloader::Git downloader.should.be.instance_of Pod::Downloader::Git
downloader.url.should == 'http://banana-corp.local/banana-lib.git' downloader.url.should == 'http://banana-corp.local/banana-lib.git'
...@@ -21,7 +21,7 @@ describe "Pod::Downloader" do ...@@ -21,7 +21,7 @@ describe "Pod::Downloader" do
end end
it 'returns a github downloader when the :git URL is on github' do it 'returns a github downloader when the :git URL is on github' do
pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), temporary_sandbox) pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), temporary_sandbox, Pod::Platform.ios)
pod.specification.stubs(:source).returns(:git => "git://github.com/CocoaPods/CocoaPods") pod.specification.stubs(:source).returns(:git => "git://github.com/CocoaPods/CocoaPods")
downloader = Pod::Downloader.for_pod(pod) downloader = Pod::Downloader.for_pod(pod)
downloader.should.be.instance_of Pod::Downloader::GitHub downloader.should.be.instance_of Pod::Downloader::GitHub
......
...@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Generator::Documentation do describe Pod::Generator::Documentation do
before do before do
@sandbox = temporary_sandbox @sandbox = temporary_sandbox
@pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), @sandbox) @pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), @sandbox, Pod::Platform.ios)
copy_fixture_to_pod('banana-lib', @pod) copy_fixture_to_pod('banana-lib', @pod)
@doc_installer = Pod::Generator::Documentation.new(@pod) @doc_installer = Pod::Generator::Documentation.new(@pod)
end end
......
...@@ -36,14 +36,12 @@ describe "Pod::Installer" do ...@@ -36,14 +36,12 @@ describe "Pod::Installer" do
dependency 'ASIHTTPRequest' dependency 'ASIHTTPRequest'
end end
config.rootspec = podfile config.rootspec = podfile
expected = []
installer = Pod::Installer.new(podfile) installer = Pod::Installer.new(podfile)
pods = installer.activated_specifications.map do |spec| pods = installer.activated_specifications.map do |spec|
spec.header_files[:ios].each do |header|
expected << config.project_pods_root + header
end
Pod::LocalPod.new(spec, installer.sandbox, podfile.platform) Pod::LocalPod.new(spec, installer.sandbox, podfile.platform)
end end
expected = pods.map { |pod| pod.header_files }.flatten.map { |header| config.project_pods_root + header }
expected.size.should > 0
installer.target_installers.first.bridge_support_generator_for(pods, installer.sandbox).headers.should == expected installer.target_installers.first.bridge_support_generator_for(pods, installer.sandbox).headers.should == expected
end end
......
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Platform" do describe Pod::Platform do
it "returns a new Platform instance" do
Pod::Platform.ios.should == Pod::Platform.new(:ios)
Pod::Platform.osx.should == Pod::Platform.new(:osx)
end
before do before do
@platform = Pod::Platform.new(:ios) @platform = Pod::Platform.ios
end end
it "exposes it's symbolic name" do it "exposes it's symbolic name" do
......
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