Sha256: cc66ad6c6043ba82dce9ec059c044ff8f9402d1007744a9c21b99e7099f9cbc6

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'claide/command/plugins_helper'
require 'claide/executable'

module CLAide
  class TemplateRunner
    extend CLAide::Executable
    executable :git

    def initialize(name, template_url)
      @name = name
      @template_url = template_url
    end

    # 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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
claide-plugins-0.9.2 lib/claide/command/template_runner.rb