class Pod::Command::Lib::Create

Constants

CREATE_NEW_POD_INFO_URL
TEMPLATE_INFO_URL
TEMPLATE_REPO

Public Class Methods

new(argv) click to toggle source
Calls superclass method Pod::Command::new
# File lib/cocoapods/command/lib/create.rb, line 24
def initialize(argv)
  @name = argv.shift_argument
  @template_url = argv.option('template-url', TEMPLATE_REPO)
  super
  @additional_args = argv.remainder!
end
options() click to toggle source
Calls superclass method Pod::Command::options
# File lib/cocoapods/command/lib/create.rb, line 18
def self.options
  [
    ['--template-url=URL', 'The URL of the git repo containing a compatible template'],
  ].concat(super)
end

Public Instance Methods

run() click to toggle source
# File lib/cocoapods/command/lib/create.rb, line 39
def run
  clone_template
  configure_template
  print_info
end
validate!() click to toggle source
Calls superclass method
# File lib/cocoapods/command/lib/create.rb, line 31
def validate!
  super
  help! 'A name for the Pod is required.' unless @name
  help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
  help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
  help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
end

Private Instance Methods

clone_template() click to toggle source

Clones the template from the remote in the working directory using the name of the Pod.

@return [void]

# File lib/cocoapods/command/lib/create.rb, line 63
def clone_template
  UI.section("Cloning `#{template_repo_url}` into `#{@name}`.") do
    git! ['clone', template_repo_url, @name]
  end
end
configure_template() click to toggle source

Runs the template configuration utilities.

@return [void]

# File lib/cocoapods/command/lib/create.rb, line 73
def configure_template
  UI.section("Configuring #{@name} template.") do
    Dir.chdir(@name) do
      if File.exist?('configure')
        system({ 'COCOAPODS_VERSION' => Pod::VERSION }, './configure', @name, *@additional_args)
      else
        UI.warn 'Template does not have a configure file.'
      end
    end
  end
end
print_info() click to toggle source

Runs the template configuration utilities.

@return [void]

template_repo_url() click to toggle source

Checks if a template URL is given else returns the TEMPLATE_REPO URL

@return String

# File lib/cocoapods/command/lib/create.rb, line 98
def template_repo_url
  @template_url || TEMPLATE_REPO
end