Permalink
Browse files

Encapsulate adding a pod's source files to an Xcode target within Loc…

…alPod.
  • Loading branch information...
1 parent ef25e3f commit 8390e00b8a729f239a134ccc3a9166a3f96c91c7 @lukeredpath lukeredpath committed Feb 25, 2012
View
@@ -7,5 +7,5 @@ group :development do
gem "guard-bacon"
gem "rb-fsevent"
gem "growl"
- gem "mocha"
+ gem "mocha-on-bacon"
end
View
@@ -11,6 +11,8 @@ GEM
metaclass (0.0.1)
mocha (0.10.4)
metaclass (~> 0.0.1)
+ mocha-on-bacon (0.2.0)
+ mocha (>= 0.9.8)
rake (0.9.2.2)
rb-fsevent (0.9.0)
schmurfy-bacon (1.2.1)
@@ -26,6 +28,6 @@ DEPENDENCIES
growl
guard
guard-bacon
- mocha
+ mocha-on-bacon
rake
rb-fsevent
@@ -66,11 +66,7 @@ def install!(pods, sandbox)
pods.each do |pod|
xcconfig.merge!(pod.specification.xcconfig)
-
- pod.implementation_files.each do |file|
- @target.add_source_file(file, nil, pod.specification.compiler_flags)
- end
-
+ pod.add_to_target(@target)
pod.link_headers
end
View
@@ -50,10 +50,6 @@ def clean_paths
def resources
expanded_paths(specification.resources, :relative_to_sandbox => true)
end
-
- def implementation_files
- source_files.select { |f| f.extname != '.h' }
- end
def header_files
source_files.select { |f| f.extname == '.h' }
@@ -65,8 +61,18 @@ def link_headers
end
end
+ def add_to_target(target)
+ implementation_files.each do |file|
+ target.add_source_file(file, nil, specification.compiler_flags)
+ end
+ end
+
private
+ def implementation_files
+ source_files.select { |f| f.extname != '.h' }
+ end
+
def relative_root
root.relative_path_from(@sandbox.root)
end
@@ -121,8 +121,8 @@ def header_dir
attr_writer :compiler_flags
def compiler_flags
- flags = "#{@compiler_flags} "
- flags << '-fobjc-arc' if requires_arc
+ flags = "#{@compiler_flags}"
+ flags << ' -fobjc-arc' if requires_arc
flags
end
@@ -265,10 +265,6 @@ def expanded_source_files
files
end
- def implementation_files
- expanded_source_files.select { |f| f.extname != '.h' }
- end
-
# Returns only the header files of this pod.
def header_files
expanded_source_files.select { |f| f.extname == '.h' }
View
@@ -1,6 +1,6 @@
require 'rubygems'
require 'bacon'
-require 'mocha'
+require 'mocha-on-bacon'
require 'pathname'
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
@@ -45,10 +45,6 @@
@pod.resources.should == [Pathname.new("BananaLib/Resources/logo-sidebar.png")]
end
- it 'returns a list of implementation files' do
- @pod.implementation_files.should == [Pathname.new("BananaLib/Classes/Banana.m")]
- end
-
it 'returns a list of header files' do
@pod.header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")]
end
@@ -70,4 +66,17 @@
File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read
end
+ it "can add it's source files to an Xcode project target" do
+ target = mock('target')
+ target.expects(:add_source_file).with(Pathname.new("BananaLib/Classes/Banana.m"), anything, anything)
+ @pod.add_to_target(target)
+ end
+
+ it "can add it's source files to a target with any specially configured compiler flags" do
+ @pod.specification.compiler_flags = '-d some_flag'
+ target = mock('target')
+ target.expects(:add_source_file).with(anything, anything, "-d some_flag")
+ @pod.add_to_target(target)
+ end
+
end
@@ -160,12 +160,6 @@
@spec.header_files.sort.should == files.sort
end
- it "returns the list of implementation files" do
- files = @destroot.glob('**/*.{c,m}')
- files = files.map { |file| file.relative_path_from(config.project_pods_root) }
- @spec.implementation_files.sort.should == files.sort
- end
-
it "returns a hash of mappings from the pod's destroot to its header dirs, which by default is just the pod's header dir" do
@spec.copy_header_mappings.size.should == 1
@spec.copy_header_mappings[Pathname.new('SSZipArchive')].sort.should == %w{

0 comments on commit 8390e00

Please sign in to comment.