Commit d746ab3b authored by Piet Brauer's avatar Piet Brauer

Add possibility to specify a template URL

parent a88e48f7
......@@ -13,10 +13,11 @@ module Pod
Creates a new Pod with the given name from the template in the working directory.
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 +54,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 +75,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