Commit 7f1ae489 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'master' of github.com:CocoaPods/CocoaPods

* 'master' of github.com:CocoaPods/CocoaPods:
  Make sure pod removes the .git directory when cleaning (using github downloader)
  remove unused lines
  Add dummy source related spec to integration spec Fix a bug that pod name with '-' will make dummy source generate inproperly
  implement unit test for dummy source
  Move the generated dummy file under "Target Support Files/Pods"
  add a dummy source file to Pod, so that in case no source files presented, the pod lib would still compile
parents 8a0e6906 38d85b09
...@@ -30,6 +30,7 @@ module Pod ...@@ -30,6 +30,7 @@ module Pod
autoload :BridgeSupport, 'cocoapods/generator/bridge_support' autoload :BridgeSupport, 'cocoapods/generator/bridge_support'
autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script' autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script'
autoload :Documentation, 'cocoapods/generator/documentation' autoload :Documentation, 'cocoapods/generator/documentation'
autoload :DummySource, 'cocoapods/generator/dummy_source'
end end
end end
......
...@@ -60,13 +60,21 @@ module Pod ...@@ -60,13 +60,21 @@ module Pod
end end
def clean def clean
# no-op if download_only?
FileUtils.rm_f(tmp_path)
else
super
end
end end
def tarball_url_for(id) def tarball_url_for(id)
original_url, username, reponame = *(url.match(/[:\/]([\w\-]+)\/([\w\-]+)\.git/).to_a) original_url, username, reponame = *(url.match(/[:\/]([\w\-]+)\/([\w\-]+)\.git/).to_a)
"https://github.com/#{username}/#{reponame}/tarball/#{id}" "https://github.com/#{username}/#{reponame}/tarball/#{id}"
end end
def tmp_path
target_path + "tarball.tar.gz"
end
private private
...@@ -75,8 +83,6 @@ module Pod ...@@ -75,8 +83,6 @@ module Pod
end end
def download_and_extract_tarball(id) def download_and_extract_tarball(id)
tmp_path = target_path + "tarball.tar.gz"
File.open(tmp_path, "w+") do |tmpfile| File.open(tmp_path, "w+") do |tmpfile|
open tarball_url_for(id) do |archive| open tarball_url_for(id) do |archive|
tmpfile.write Zlib::GzipReader.new(archive).read tmpfile.write Zlib::GzipReader.new(archive).read
...@@ -84,8 +90,6 @@ module Pod ...@@ -84,8 +90,6 @@ module Pod
system "tar xf #{tmpfile.path} -C #{target_path} --strip-components 1" system "tar xf #{tmpfile.path} -C #{target_path} --strip-components 1"
end end
FileUtils.rm_f(tmp_path)
end end
end end
end end
......
module Pod
module Generator
class DummySource
def initialize(label="Pods")
@label = label.gsub(/[^a-zA-Z]/, '')
end
def save_as(pathname)
pathname.open('w') do |source|
source.puts "@interface #{@label}Dummy : NSObject"
source.puts "@end"
source.puts "@implementation #{@label}Dummy"
source.puts "@end"
end
end
end
end
end
...@@ -53,7 +53,7 @@ module Pod ...@@ -53,7 +53,7 @@ module Pod
end end
def target_support_files def target_support_files
[:copy_resources_script_name, :prefix_header_name, :xcconfig_name].map { |file| @target_definition.send(file) } [:copy_resources_script_name, :prefix_header_name, :xcconfig_name, :dummy_source_name].map { |file| @target_definition.send(file) }
end end
# TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support. # TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
...@@ -75,11 +75,11 @@ module Pod ...@@ -75,11 +75,11 @@ module Pod
support_files_group = @project.group("Targets Support Files").create_group(@target_definition.label) support_files_group = @project.group("Targets Support Files").create_group(@target_definition.label)
support_files_group.create_files(target_support_files) support_files_group.create_files(target_support_files)
xcconfig_file = support_files_group.files.where(:path => @target_definition.xcconfig_name) xcconfig_file = support_files_group.files.where(:path => @target_definition.xcconfig_name)
configure_build_configurations(xcconfig_file) configure_build_configurations(xcconfig_file)
create_files(pods, sandbox) create_files(pods, sandbox)
add_dummy_file(support_files_group)
end end
def configure_build_configurations(xcconfig_file) def configure_build_configurations(xcconfig_file)
...@@ -91,6 +91,11 @@ module Pod ...@@ -91,6 +91,11 @@ module Pod
end end
end end
def add_dummy_file(support_files_group)
dummy = Pathname.new(@target_definition.dummy_source_name)
@target.add_source_file(dummy)
end
def create_files(pods, sandbox) def create_files(pods, sandbox)
if @podfile.generate_bridge_support? if @podfile.generate_bridge_support?
bridge_support_metadata_path = sandbox.root + @target_definition.bridge_support_name bridge_support_metadata_path = sandbox.root + @target_definition.bridge_support_name
...@@ -104,6 +109,8 @@ module Pod ...@@ -104,6 +109,8 @@ module Pod
save_prefix_header_as(sandbox.root + @target_definition.prefix_header_name, pods) save_prefix_header_as(sandbox.root + @target_definition.prefix_header_name, pods)
puts "* Generating copy resources script at `#{sandbox.root + @target_definition.copy_resources_script_name}'" if config.verbose? puts "* Generating copy resources script at `#{sandbox.root + @target_definition.copy_resources_script_name}'" if config.verbose?
copy_resources_script_for(pods).save_as(sandbox.root + @target_definition.copy_resources_script_name) copy_resources_script_for(pods).save_as(sandbox.root + @target_definition.copy_resources_script_name)
puts "* Generating dummy source at `#{sandbox.root + @target_definition.dummy_source_name}'" if config.verbose?
Generator::DummySource.new(@target_definition.label).save_as(sandbox.root + @target_definition.dummy_source_name)
end end
private private
......
...@@ -95,6 +95,10 @@ module Pod ...@@ -95,6 +95,10 @@ module Pod
def prefix_header_name def prefix_header_name
"#{label}-prefix.pch" "#{label}-prefix.pch"
end end
def dummy_source_name
"#{label}Dummy.m"
end
def bridge_support_name def bridge_support_name
"#{label}.bridgesupport" "#{label}.bridgesupport"
......
...@@ -84,9 +84,21 @@ describe "Pod::Downloader" do ...@@ -84,9 +84,21 @@ describe "Pod::Downloader" do
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
VCR.use_cassette('tarballs', :record => :new_episodes) { downloader.download } VCR.use_cassette('tarballs', :record => :new_episodes) { downloader.download }
downloader.clean
(@pod.root + 'tarball.tar.gz').should.not.exist (@pod.root + 'tarball.tar.gz').should.not.exist
end end
it "removes the .git directory when cleaning" do
@pod.specification.stubs(:source).returns(
:git => "git://github.com/lukeredpath/libPusher.git", :download_only => false
)
downloader = Pod::Downloader.for_pod(@pod)
downloader.download
downloader.clean
(@pod.root + '.git').should.not.exist
end
end end
describe "for Mercurial" do describe "for Mercurial" do
......
...@@ -118,6 +118,26 @@ else ...@@ -118,6 +118,26 @@ else
'DEPENDENCIES' => ["Reachability (from `#{url}')"] 'DEPENDENCIES' => ["Reachability (from `#{url}')"]
} }
end end
it "install a dummy source file" do
create_config!
podfile = Pod::Podfile.new do
self.platform :ios
xcodeproj 'dummy'
dependency 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
end
installer = SpecHelper::Installer.new(podfile)
installer.install!
dummy = (config.project_pods_root + 'PodsDummy.m').read
dummy.should.include?('@implementation PodsDummy')
end
it "installs a library with a podspec defined inline" do it "installs a library with a podspec defined inline" do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
......
require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Generator::DummySource do
extend SpecHelper::TemporaryDirectory
before do
setup_temporary_directory
end
after do
teardown_temporary_directory
end
it "generates a dummy sourcefile with the appropriate class" do
generator = Pod::Generator::DummySource.new("Pods")
file = temporary_directory + 'PodsDummy.m'
generator.save_as(file)
file.read.should == <<-EOS
@interface PodsDummy : NSObject
@end
@implementation PodsDummy
@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