Commit 67d7efcb authored by Luis de la Rosa's avatar Luis de la Rosa

Addressed comments from @irrationalfab:

- simplified collection of unique prefix_header_contents
- reduced sub specs in spec from 4 to 2
Removed inline documentation and added @notes and @todos.
Added entry to Changelog.
parent 0873065d
...@@ -8,6 +8,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -8,6 +8,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
##### Enhancements ##### Enhancements
* Generated prefix header file will now have unique prefix_header_contents for
Pods with subspecs.
[Luis de la Rosa](https://github.com/luisdelarosa)
[#1449](https://github.com/CocoaPods/CocoaPods/issues/1449)
* Add version to output of `pod list` * Add version to output of `pod list`
[Stefan Damm](https://github.com/StefanDamm) [Stefan Damm](https://github.com/StefanDamm)
[Robert Zuber](https://github.com/z00b) [Robert Zuber](https://github.com/z00b)
......
...@@ -40,9 +40,12 @@ module Pod ...@@ -40,9 +40,12 @@ module Pod
# added to the top of the prefix header. For OS X `Cocoa/Cocoa.h` # added to the top of the prefix header. For OS X `Cocoa/Cocoa.h`
# is imported. # is imported.
# #
# @note Only unique prefix_header_contents are added to the prefix header.
#
# @return [String] # @return [String]
# #
# @todo Subspecs can specify prefix header information too. # @todo Subspecs can specify prefix header information too.
# @todo Check to see if we have a similar duplication issue with file_accessor.prefix_header.
# #
def generate def generate
result = "#ifdef __OBJC__\n" result = "#ifdef __OBJC__\n"
...@@ -53,23 +56,17 @@ module Pod ...@@ -53,23 +56,17 @@ module Pod
result << %|\n#import "#{import}"| result << %|\n#import "#{import}"|
end end
# collect all the prefix_header_contents and only get the unique contents so that we don't have duplicates unique_prefix_header_contents = file_accessors.collect do |file_accessor|
all_prefix_header_contents = file_accessors.collect do |file_accessor|
file_accessor.spec_consumer.prefix_header_contents file_accessor.spec_consumer.prefix_header_contents
end end.compact.uniq
unique_and_non_nil_prefix_header_contents = all_prefix_header_contents.compact.uniq
# newline to separate prefix_headers and prefix_header_contents from the imports
result << "\n" result << "\n"
# output those unique prefix_header_contents unique_prefix_header_contents.each do |prefix_header_contents|
unique_and_non_nil_prefix_header_contents.each do |prefix_header_contents|
result << prefix_header_contents result << prefix_header_contents
result << "\n" result << "\n"
end end
# output the prefix_headers
# todo check to see if we have a similar duplicating issue with these
file_accessors.each do |file_accessor| file_accessors.each do |file_accessor|
if prefix_header = file_accessor.prefix_header if prefix_header = file_accessor.prefix_header
result << Pathname(prefix_header).read result << Pathname(prefix_header).read
......
...@@ -21,10 +21,10 @@ module Pod ...@@ -21,10 +21,10 @@ module Pod
EOS EOS
end end
# @note Declaring a subspec was found in issue #1449 to generate duplicates of the prefix_header_contents
it "does not duplicate the contents of the specification's prefix header when a subspec is declared" do it "does not duplicate the contents of the specification's prefix header when a subspec is declared" do
@spec.prefix_header_contents = '#import "BlocksKit.h"' @spec.prefix_header_contents = '#import "BlocksKit.h"'
@spec.prefix_header_file = nil @spec.prefix_header_file = nil
# Declaring a subspec was found in issue #1449 to generate duplicates of the prefix_header_contents
@spec.subspec 'UI' do |subspec| @spec.subspec 'UI' do |subspec|
subspec.source_files = 'Source/UI/*.{h,m}' subspec.source_files = 'Source/UI/*.{h,m}'
end end
...@@ -37,10 +37,10 @@ module Pod ...@@ -37,10 +37,10 @@ module Pod
EOS EOS
end end
# @note Declaring a subspec was found in issue #1449 to generate duplicates of the prefix_header_contents
it "does not duplicate the contents of the specification's prefix header when a subspec is declared multiple times" do it "does not duplicate the contents of the specification's prefix header when a subspec is declared multiple times" do
@spec.prefix_header_contents = '#import "BlocksKit.h"' @spec.prefix_header_contents = '#import "BlocksKit.h"'
@spec.prefix_header_file = nil @spec.prefix_header_file = nil
# Declaring a subspec was found in issue #1449 to generate duplicates of the prefix_header_contents
@spec.subspec 'UI' do |su| @spec.subspec 'UI' do |su|
su.source_files = 'Source/UI/*.{h,m}' su.source_files = 'Source/UI/*.{h,m}'
end end
...@@ -48,15 +48,7 @@ module Pod ...@@ -48,15 +48,7 @@ module Pod
@spec.subspec 'Helpers' do |sh| @spec.subspec 'Helpers' do |sh|
sh.source_files = 'Source/Helpers/*.{h,m}' sh.source_files = 'Source/Helpers/*.{h,m}'
end end
@spec.subspec 'Additions' do |sa|
sa.source_files = 'Source/Additions/*.{h,m}'
end
@spec.subspec 'Dashboard' do |sd|
sd.source_files = 'Source/Dashboard/*.{h,m}'
sd.resources = 'Source/Dashboard/*.{xib}'
end
@gen.generate.should == <<-EOS.strip_heredoc @gen.generate.should == <<-EOS.strip_heredoc
#ifdef __OBJC__ #ifdef __OBJC__
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
......
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