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 Generator
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)
pathname.open('w') do |source|
source.puts "@interface PodsDummy : NSObject"
source.puts "@interface #{class_name} : NSObject"
source.puts "@end"
source.puts "@implementation PodsDummy"
source.puts "@implementation #{class_name}"
source.puts "@end"
end
end
......
......@@ -107,10 +107,10 @@ module Pod
acknowledgements_path = target_installer.target_definition.acknowledgements_path
Generator::Acknowledgements.new(target_installer.target_definition,
pods_for_target).save_as(acknowledgements_path)
generate_dummy_source(target_installer)
end
generate_lock_file!(specifications)
generate_dummy_source
puts "- Running post install hooks" if config.verbose?
# Post install hooks run _before_ saving of project, so that they can alter it before saving.
......@@ -172,17 +172,17 @@ module Pod
end
end
def generate_dummy_source
filename = "PodsDummy.m"
def generate_dummy_source(target_installer)
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)
Generator::DummySource.new.save_as(pathname)
dummy_source.save_as(pathname)
project_file = project.files.new('path' => filename)
project.group("Targets Support Files") << project_file
target_installers.each do |target_installer|
target_installer.target.source_build_phases.first << project_file
end
target_installer.target.source_build_phases.first << project_file
end
def specs_by_target
......
......@@ -114,8 +114,31 @@ else
installer = SpecHelper::Installer.new(podfile)
installer.install!
dummy = (config.project_pods_root + 'PodsDummy.m').read
dummy.should.include?('@implementation PodsDummy')
dummy = (config.project_pods_root + 'PodsDummy_Pods.m').read
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
it "installs a library with a podspec defined inline" do
......
......@@ -11,15 +11,28 @@ describe Pod::Generator::DummySource do
teardown_temporary_directory
end
it "generates a dummy sourcefile with the appropriate class" do
generator = Pod::Generator::DummySource.new
it "generates a dummy sourcefile with the appropriate class for the class name identifier" do
generator = Pod::Generator::DummySource.new('SomeIdentification')
file = temporary_directory + 'PodsDummy.m'
generator.save_as(file)
file.read.should == <<-EOS
@interface PodsDummy : NSObject
@interface PodsDummy_SomeIdentification : NSObject
@end
@implementation PodsDummy
@implementation PodsDummy_SomeIdentification
@end
EOS
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
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