lib/claide/command/plugins/create.rb in claide-plugins-0.9.1 vs lib/claide/command/plugins/create.rb in claide-plugins-0.9.2
- old
+ new
@@ -1,7 +1,8 @@
require 'claide/command/plugins_helper'
-require 'claide/executable'
+require 'claide/command/gem_helper'
+require 'claide/command/template_runner'
module CLAide
class Command
class Plugins
# The create subcommand. Used to create a new plugin using either the
@@ -44,59 +45,18 @@
help! 'The plugin name cannot contain spaces.' if @name.match(/\s/)
end
def run
- clone_template
- configure_template
+ runner = TemplateRunner.new @name, @template_url
+ runner.clone_template
+ runner.configure_template
show_reminder
end
#----------------------------------------#
private
-
- # !@group Private helpers
-
- extend CLAide::Executable
- executable :git
-
- # 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]
- git! command
- end
- end
-
- # Runs the template configuration utilities.
- #
- # @return [void]
- #
- def configure_template
- UI.section('-> Configuring template') do
- Dir.chdir(@name) do
- if File.file? 'configure'
- system "./configure #{@name}"
- else
- UI.warn 'Template does not have a configure file.'
- end
- end
- end
- end
-
- # Checks if a template URL is given else returns the Plugins.config URL
- #
- # @return String
- #
- def template_repo_url
- @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
#
def show_reminder