Commit c3d1e836 authored by David Venable's avatar David Venable

When generating the PodsDummy class, make that class unique to each target by…

When generating the PodsDummy class, make that class unique to each target by using the Target Definition's label.
parent ea64987a
module Pod module Pod
module Generator module Generator
class DummySource class DummySource
attr_reader :class_name
def initialize(class_name_identifier)
validated_class_name_identifier = class_name_identifier.gsub(/[^0-9a-z_]/i, '_')
@class_name = "PodsDummy_#{validated_class_name_identifier}"
end
def save_as(pathname) def save_as(pathname)
pathname.open('w') do |source| pathname.open('w') do |source|
source.puts "@interface PodsDummy : NSObject" source.puts "@interface #{class_name} : NSObject"
source.puts "@end" source.puts "@end"
source.puts "@implementation PodsDummy" source.puts "@implementation #{class_name}"
source.puts "@end" source.puts "@end"
end end
end end
......
...@@ -107,10 +107,10 @@ module Pod ...@@ -107,10 +107,10 @@ module Pod
acknowledgements_path = target_installer.target_definition.acknowledgements_path acknowledgements_path = target_installer.target_definition.acknowledgements_path
Generator::Acknowledgements.new(target_installer.target_definition, Generator::Acknowledgements.new(target_installer.target_definition,
pods_for_target).save_as(acknowledgements_path) pods_for_target).save_as(acknowledgements_path)
generate_dummy_source(target_installer)
end end
generate_lock_file!(specifications) generate_lock_file!(specifications)
generate_dummy_source
puts "- Running post install hooks" if config.verbose? puts "- Running post install hooks" if config.verbose?
# Post install hooks run _before_ saving of project, so that they can alter it before saving. # Post install hooks run _before_ saving of project, so that they can alter it before saving.
...@@ -172,17 +172,17 @@ module Pod ...@@ -172,17 +172,17 @@ module Pod
end end
end end
def generate_dummy_source def generate_dummy_source(target_installer)
filename = "PodsDummy.m" class_name_identifier = target_installer.target_definition.label
dummy_source = Generator::DummySource.new(class_name_identifier)
filename = "#{dummy_source.class_name}.m"
pathname = Pathname.new(sandbox.root + filename) pathname = Pathname.new(sandbox.root + filename)
Generator::DummySource.new.save_as(pathname) dummy_source.save_as(pathname)
project_file = project.files.new('path' => filename) project_file = project.files.new('path' => filename)
project.group("Targets Support Files") << project_file project.group("Targets Support Files") << project_file
target_installers.each do |target_installer| target_installer.target.source_build_phases.first << project_file
target_installer.target.source_build_phases.first << project_file
end
end end
def specs_by_target def specs_by_target
......
...@@ -114,8 +114,31 @@ else ...@@ -114,8 +114,31 @@ else
installer = SpecHelper::Installer.new(podfile) installer = SpecHelper::Installer.new(podfile)
installer.install! installer.install!
dummy = (config.project_pods_root + 'PodsDummy.m').read dummy = (config.project_pods_root + 'PodsDummy_Pods.m').read
dummy.should.include?('@implementation PodsDummy') dummy.should.include?('@implementation PodsDummy_Pods')
end
it "installs a dummy source file unique to the target" do
create_config!
podfile = Pod::Podfile.new do
self.platform :ios
xcodeproj 'dummy'
pod do |s|
s.name = 'JSONKit'
s.version = '1.2'
s.source = { :git => SpecHelper.fixture('integration/JSONKit').to_s, :tag => 'v1.2' }
s.source_files = 'JSONKit.*'
end
target :AnotherTarget do
pod 'ASIHTTPRequest'
end
end
installer = SpecHelper::Installer.new(podfile)
installer.install!
dummy = (config.project_pods_root + 'PodsDummy_Pods_AnotherTarget.m').read
dummy.should.include?('@implementation PodsDummy_Pods_AnotherTarget')
end end
it "installs a library with a podspec defined inline" do it "installs a library with a podspec defined inline" do
......
...@@ -11,15 +11,28 @@ describe Pod::Generator::DummySource do ...@@ -11,15 +11,28 @@ describe Pod::Generator::DummySource do
teardown_temporary_directory teardown_temporary_directory
end end
it "generates a dummy sourcefile with the appropriate class" do it "generates a dummy sourcefile with the appropriate class for the class name identifier" do
generator = Pod::Generator::DummySource.new generator = Pod::Generator::DummySource.new('SomeIdentification')
file = temporary_directory + 'PodsDummy.m' file = temporary_directory + 'PodsDummy.m'
generator.save_as(file) generator.save_as(file)
file.read.should == <<-EOS file.read.should == <<-EOS
@interface PodsDummy : NSObject @interface PodsDummy_SomeIdentification : NSObject
@end @end
@implementation PodsDummy @implementation PodsDummy_SomeIdentification
@end @end
EOS EOS
end end
it "generates a dummy sourcefile with the appropriate class, replacing non-alphanumeric characters with underscores" do
generator = Pod::Generator::DummySource.new('This!has_non-alphanumeric+characters in it.0123456789')
file = temporary_directory + 'PodsDummy.m'
generator.save_as(file)
file.read.should == <<-EOS
@interface PodsDummy_This_has_non_alphanumeric_characters_in_it_0123456789 : NSObject
@end
@implementation PodsDummy_This_has_non_alphanumeric_characters_in_it_0123456789
@end
EOS
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