Commit 9fa878c9 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge pull request #1909 from pietbrauer/add_dynamic_url_to_pod_template

Add possibility to specify a template URL
parents b0c71244 35c03c7d
......@@ -19,6 +19,9 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
* Improves `pod init` to save Xcode project file in Podfile when one was supplied.
[Kyle Fuller](https://github.com/kylef)
* Adds functionality to specify a template URL for the `pod lib create` command.
[Piet Brauer](https://github.com/pietbrauer)
###### Bug Fixes
* Fixes a bug with `pod repo remove` silently handling permission errors.
......
......@@ -10,13 +10,15 @@ module Pod
self.summary = 'Creates a new Pod'
self.description = <<-DESC
Creates a new Pod with the given name from the template in the working directory.
Creates a scaffold for the development of a new Pod according to the CocoaPods best practices.
If a `TEMPLATE_URL`, pointing to a git repo containing a compatible template, is specified, it will be used in place of the default one.
DESC
self.arguments = '[NAME]'
self.arguments = 'NAME [TEMPLATE_URL]'
def initialize(argv)
@name = argv.shift_argument
@template_url = argv.shift_argument
super
end
......@@ -53,7 +55,7 @@ module Pod
#
def clone_template
UI.section("Creating `#{@name}` Pod") do
git!"clone '#{TEMPLATE_REPO}' #{@name}"
git!"clone '#{template_repo_url}' #{@name}"
end
end
......@@ -74,10 +76,17 @@ module Pod
# @return [void]
#
def print_info
UI.puts "\nTo learn more about the template see `#{TEMPLATE_INFO_URL}`."
UI.puts "\nTo learn more about the template see `#{template_repo_url}`."
UI.puts "To learn more about creating a new pod, see `#{CREATE_NEW_POD_INFO_URL}`."
end
# Checks if a template URL is given else returns the TEMPLATE_REPO URL
#
# @return String
#
def template_repo_url
@template_url || TEMPLATE_REPO
end
end
#-----------------------------------------------------------------------#
......
......@@ -77,5 +77,22 @@ module Pod
output = run_command('lib', 'create', 'TestPod')
output.should.include? 'http://guides.cocoapods.org/making/making-a-cocoapod'
end
before do
Command::Lib::Create.any_instance.stubs(:configure_template)
Command::Lib::Create.any_instance.stubs(:git!)
end
it "should use the given template URL" do
template_url = 'https://github.com/custom/template.git'
Command::Lib::Create.any_instance.expects(:git!).with("clone '#{template_url}' TestPod").once
sut = run_command('lib', 'create', 'TestPod', template_url)
end
it "should use the default URL if no template URL is given" do
template_url = 'https://github.com/CocoaPods/pod-template.git'
Command::Lib::Create.any_instance.expects(:git!).with("clone '#{template_url}' TestPod").once
run_command('lib', 'create', 'TestPod')
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