Commit a9d87406 authored by Fabio Pelosin's avatar Fabio Pelosin

[Installer] Use aggregate target for library reppresentation

Closes #1157
parent 6827f83d
...@@ -59,8 +59,8 @@ module Pod ...@@ -59,8 +59,8 @@ module Pod
# #
def specs_by_lib def specs_by_lib
result = {} result = {}
installer.pod_targets.each do |lib| installer.aggregate_targets.each do |aggregate_target|
result[installer.library_rep(lib)] = lib.specs result[installer.library_rep(aggregate_target)] = aggregate_target.specs
end end
result result
end end
......
...@@ -83,6 +83,7 @@ module Pod ...@@ -83,6 +83,7 @@ module Pod
def initialize(sandbox, library) def initialize(sandbox, library)
@sandbox = sandbox @sandbox = sandbox
@library = library @library = library
raise "[BUG]" unless library.is_a?(AggregateTarget)
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -547,14 +547,14 @@ module Pod ...@@ -547,14 +547,14 @@ module Pod
# @return [LibraryRepresentation] # @return [LibraryRepresentation]
# #
def library_rep(library) def library_rep(aggregate_target)
Hooks::LibraryRepresentation.new(sandbox, library) Hooks::LibraryRepresentation.new(sandbox, aggregate_target)
end end
# @return [Array<LibraryRepresentation>] # @return [Array<LibraryRepresentation>]
# #
def library_reps def library_reps
@library_reps ||= pod_targets.map { |lib| library_rep(lib) } @library_reps ||= aggregate_targets.map { |lib| library_rep(lib) }
end end
# @return [Array<PodRepresentation>] # @return [Array<PodRepresentation>]
...@@ -571,7 +571,9 @@ module Pod ...@@ -571,7 +571,9 @@ module Pod
# @return [Array<Library>] The library. # @return [Array<Library>] The library.
# #
def libraries_using_spec(spec) def libraries_using_spec(spec)
pod_targets.select { |pod_target| pod_target.specs.include?(spec) } aggregate_targets.select do |aggregate_target|
aggregate_target.pod_targets.any? { |pod_target| pod_target.specs.include?(spec) }
end
end end
# @return [Array<Library>] The libraries generated by the installation # @return [Array<Library>] The libraries generated by the installation
......
...@@ -38,7 +38,7 @@ module Pod ...@@ -38,7 +38,7 @@ module Pod
# @return [String] A string suitable for debugging. # @return [String] A string suitable for debugging.
# #
def inspect def inspect
"<#{self.class} name=#{name} platform=#{platform}>" "<#{self.class} name=#{name} >"
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
...@@ -56,9 +56,16 @@ module Pod ...@@ -56,9 +56,16 @@ module Pod
# #
attr_accessor :pod_targets attr_accessor :pod_targets
# @return [Array<SpecConsumer>] # @return [Array<Specification>] The specifications used by this aggregate target.
#
def specs
pod_targets.map(&:specs).flatten
end
# @return [Array<Specification::Consumer>] The consumers of the Pod.
#
def spec_consumers def spec_consumers
pod_targets.map(&:specs).flatten.map { |spec| spec.consumer(platform) } specs.map { |spec| spec.consumer(platform) }
end end
# @return [Pathname] The absolute path of acknowledgements file. # @return [Pathname] The absolute path of acknowledgements file.
......
PODS:Reachability (3.1.0) TARGETS:Pods-Reachability PODS:Reachability (3.1.0) TARGETS:Pods
...@@ -40,13 +40,13 @@ module Pod ...@@ -40,13 +40,13 @@ module Pod
end end
it "the hook representation of the libraries" do it "the hook representation of the libraries" do
@rep.libraries.map(&:name).sort.should == ['Pods-JSONKit'].sort @rep.libraries.map(&:name).sort.should == ['Pods'].sort
end end
it "returns the specs by library representation" do it "returns the specs by library representation" do
specs_by_lib = @rep.specs_by_lib specs_by_lib = @rep.specs_by_lib
lib_rep = specs_by_lib.keys.first lib_rep = specs_by_lib.keys.first
lib_rep.name.should == 'Pods-JSONKit' lib_rep.name.should == 'Pods'
specs_by_lib.should == { lib_rep => @specs } specs_by_lib.should == { lib_rep => @specs }
end end
......
...@@ -7,7 +7,7 @@ module Pod ...@@ -7,7 +7,7 @@ module Pod
@target_definition = Podfile::TargetDefinition.new('MyApp', nil) @target_definition = Podfile::TargetDefinition.new('MyApp', nil)
@spec = Spec.new @spec = Spec.new
@spec.name = 'RestKit' @spec.name = 'RestKit'
@lib = PodTarget.new([@spec], @target_definition, config.sandbox) @lib = AggregateTarget.new(@target_definition, config.sandbox)
@rep = Hooks::LibraryRepresentation.new(config.sandbox, @lib) @rep = Hooks::LibraryRepresentation.new(config.sandbox, @lib)
end end
...@@ -16,7 +16,7 @@ module Pod ...@@ -16,7 +16,7 @@ module Pod
describe "Public Hooks API" do describe "Public Hooks API" do
it "returns the name" do it "returns the name" do
@rep.name.should == 'Pods-MyApp-RestKit' @rep.name.should == 'Pods-MyApp'
end end
it "returns the dependencies" do it "returns the dependencies" do
...@@ -29,7 +29,11 @@ module Pod ...@@ -29,7 +29,11 @@ module Pod
end end
it "returns the path of the prefix header" do it "returns the path of the prefix header" do
@rep.prefix_header_path.should == temporary_directory + 'Pods/Pods-MyApp-RestKit-prefix.pch' @rep.prefix_header_path.should == temporary_directory + 'Pods/Pods-MyApp-prefix.pch'
end
it "returns the path of the copy resources script" do
@rep.copy_resources_script_path.should == temporary_directory + 'Pods/Pods-MyApp-resources.sh'
end end
it "returns the pods project" do it "returns the pods project" do
......
...@@ -383,7 +383,7 @@ module Pod ...@@ -383,7 +383,7 @@ module Pod
@specs = @installer.pod_targets.map(&:specs).flatten @specs = @installer.pod_targets.map(&:specs).flatten
@spec = @specs.find { |spec| spec && spec.name == 'JSONKit' } @spec = @specs.find { |spec| spec && spec.name == 'JSONKit' }
@installer.stubs(:installed_specs).returns(@specs) @installer.stubs(:installed_specs).returns(@specs)
@lib = @installer.aggregate_targets.first.pod_targets.first @aggregate_target = @installer.aggregate_targets.first
end end
it "runs the pre install hooks" do it "runs the pre install hooks" do
...@@ -393,7 +393,7 @@ module Pod ...@@ -393,7 +393,7 @@ module Pod
@installer.expects(:installer_rep).returns(installer_rep) @installer.expects(:installer_rep).returns(installer_rep)
@installer.expects(:pod_rep).with('JSONKit').returns(pod_rep) @installer.expects(:pod_rep).with('JSONKit').returns(pod_rep)
@installer.expects(:library_rep).with(@lib).returns(library_rep) @installer.expects(:library_rep).with(@aggregate_target).returns(library_rep)
@spec.expects(:pre_install!) @spec.expects(:pre_install!)
@installer.podfile.expects(:pre_install!).with(installer_rep) @installer.podfile.expects(:pre_install!).with(installer_rep)
@installer.send(:run_pre_install_hooks) @installer.send(:run_pre_install_hooks)
...@@ -404,7 +404,7 @@ module Pod ...@@ -404,7 +404,7 @@ module Pod
target_installer_data = stub() target_installer_data = stub()
@installer.expects(:installer_rep).returns(installer_rep) @installer.expects(:installer_rep).returns(installer_rep)
@installer.expects(:library_rep).with(@lib).returns(target_installer_data) @installer.expects(:library_rep).with(@aggregate_target).returns(target_installer_data)
@spec.expects(:post_install!) @spec.expects(:post_install!)
@installer.podfile.expects(:post_install!).with(installer_rep) @installer.podfile.expects(:post_install!).with(installer_rep)
@installer.send(:run_post_install_hooks) @installer.send(:run_post_install_hooks)
...@@ -417,15 +417,14 @@ module Pod ...@@ -417,15 +417,14 @@ module Pod
pod_target_osx.stubs(:name).returns('label') pod_target_osx.stubs(:name).returns('label')
library_ios_rep = stub() library_ios_rep = stub()
library_osx_rep = stub() library_osx_rep = stub()
target_installer_data = stub()
@installer.stubs(:pod_targets).returns([pod_target_ios, pod_target_osx]) @installer.stubs(:pod_targets).returns([pod_target_ios, pod_target_osx])
@installer.stubs(:installer_rep).returns(stub()) @installer.stubs(:installer_rep).returns(stub())
@installer.stubs(:library_rep).with(pod_target_ios).returns(library_ios_rep) @installer.stubs(:library_rep).with(@aggregate_target).returns(target_installer_data).twice
@installer.stubs(:library_rep).with(pod_target_osx).returns(library_osx_rep)
@installer.podfile.expects(:pre_install!) @installer.podfile.expects(:pre_install!)
@spec.expects(:post_install!).with(library_ios_rep) @spec.expects(:post_install!).with(target_installer_data).once
@spec.expects(:post_install!).with(library_osx_rep)
@installer.send(:run_pre_install_hooks) @installer.send(:run_pre_install_hooks)
@installer.send(:run_post_install_hooks) @installer.send(:run_post_install_hooks)
...@@ -438,15 +437,15 @@ module Pod ...@@ -438,15 +437,15 @@ module Pod
it "returns the hook representation of a pod" do it "returns the hook representation of a pod" do
file_accessor = stub(:spec => @spec) file_accessor = stub(:spec => @spec)
@lib.stubs(:file_accessors).returns([file_accessor]) @aggregate_target.pod_targets.first.stubs(:file_accessors).returns([file_accessor])
rep = @installer.send(:pod_rep, 'JSONKit') rep = @installer.send(:pod_rep, 'JSONKit')
rep.name.should == 'JSONKit' rep.name.should == 'JSONKit'
rep.root_spec.should == @spec rep.root_spec.should == @spec
end end
it "returns the hook representation of a library" do it "returns the hook representation of an aggregate target" do
rep = @installer.send(:library_rep, @lib) rep = @installer.send(:library_rep, @aggregate_target)
rep.send(:library).name.should == 'Pods-JSONKit' rep.send(:library).name.should == 'Pods'
end end
it "returns the hook representation of all the pods" do it "returns the hook representation of all the pods" do
...@@ -454,14 +453,14 @@ module Pod ...@@ -454,14 +453,14 @@ module Pod
reps.map(&:name).should == ['JSONKit'] reps.map(&:name).should == ['JSONKit']
end end
it "returns the hook representation of all the target installers" do it "returns the hook representation of all the aggregate target" do
reps = @installer.send(:library_reps) reps = @installer.send(:library_reps)
reps.map(&:name).sort.should == ['Pods-JSONKit'].sort reps.map(&:name).sort.should == ['Pods'].sort
end end
it "returns the targets which use a given Pod" do it "returns the aggregate targets which use a given Pod" do
libs = @installer.send(:libraries_using_spec, @spec) libs = @installer.send(:libraries_using_spec, @spec)
libs.map(&:name).should == ['Pods-JSONKit'] libs.map(&:name).should == ['Pods']
end end
end end
......
...@@ -79,8 +79,13 @@ module Pod ...@@ -79,8 +79,13 @@ module Pod
@target.pod_targets = [pod_target] @target.pod_targets = [pod_target]
end end
it "returns the specs of the Pods used by this aggregate target" do
@target.specs.map(&:name).should == ["BananaLib"]
end
it "returns the spec consumers for the pod targets" do it "returns the spec consumers for the pod targets" do
@target.spec_consumers.should.not == nil consumer_reps = @target.spec_consumers.map { |consumer| [consumer.spec.name, consumer.platform_name ] }
consumer_reps.should == [["BananaLib", :ios]]
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