lib/claide/command/plugins/create.rb in claide-plugins-0.9.0 vs lib/claide/command/plugins/create.rb in claide-plugins-0.9.1

- old
+ new

@@ -7,31 +7,32 @@ # The create subcommand. Used to create a new plugin using either the # default template (CocoaPods/cocoapods-plugin-template) or a custom # template # class Create < Plugins - NAME_PREFIX = 'claide-' - self.summary = 'Creates a new plugin' - self.description = <<-DESC + def self.description + <<-DESC Creates a scaffold for the development of a new plugin - named `NAME` according to the CocoaPods best practices. + named `NAME` according to the 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 + DESC + end self.arguments = [ CLAide::Argument.new('NAME', true), CLAide::Argument.new('TEMPLATE_URL', false), ] def initialize(argv) @name = argv.shift_argument - unless @name.nil? || @name.empty? || @name.start_with?(NAME_PREFIX) - @name = NAME_PREFIX + @name.dup + prefix = CLAide::Plugins.config.plugin_prefix + '-' + unless @name.nil? || @name.empty? || @name.start_with?(prefix) + @name = prefix + @name.dup end @template_url = argv.shift_argument super end @@ -57,31 +58,20 @@ # !@group Private helpers extend CLAide::Executable executable :git - TEMPLATE_BASE_URL = 'https://github.com/CocoaPods/' - TEMPLATE_REPO = TEMPLATE_BASE_URL + 'cocoapods-plugin-template.git' - TEMPLATE_INFO_URL = TEMPLATE_BASE_URL + 'cocoapods-plugin-template' - # Clones the template from the remote in the working directory using # the name of the plugin. # # @return [void] # def clone_template UI.section("-> Creating `#{@name}` plugin") do UI.notice "using template '#{template_repo_url}'" command = ['clone', template_repo_url, @name] - if method(:git!).arity == -1 - git! command - else - # TODO: delete this conditional and use the other branch when - # 0.5.0 is released - require 'shellwords' - git! command.map(&:to_s).map(&:shellescape).join(' ') - end + git! command end end # Runs the template configuration utilities. # @@ -97,15 +87,15 @@ end end end end - # Checks if a template URL is given else returns the TEMPLATE_REPO URL + # Checks if a template URL is given else returns the Plugins.config URL # # @return String # def template_repo_url - @template_url || TEMPLATE_REPO + @template_url || CLAide::Plugins.config.plugin_template_url end # Shows a reminder to the plugin author to make a Pull Request # in order to update plugins.json once the plugin is released #