Sha256: 3adcfac69c29e83bfaa2475b8cd67a84464fb7c7935db3ebbf4fd0586f5172e5

Contents?: true

Size: 1.63 KB

Versions: 4

Compression:

Stored size: 1.63 KB

Contents

require "thor"
require "thor/actions"
require "fileutils"

class Gator
  module Scaffolding
    class ScaffoldCommand < Command
      include Thor::Actions

      define :command => "scaffold", :short => "s",
             :usage => "scaffold TASK", :description => "Set of tasks to manage scaffold templates."

      def self.source_root
        Gator::Scaffolding::ScaffoldingFileUtils.new.scaffolds_home
      end

      desc "scaffold install NAME TEMPLATE_NAME", "Install a scaffold template."
      def install(dir, name=nil)
        file_util.install_scaffold dir, name
      end

      desc "scaffold uninstall TEMPLATE_NAME", "Uninstall a scaffold template."
      def uninstall( scaffold )
        file_util.delete_scaffold scaffold
      end

      desc "scaffold new NAME TEMPLATE_NAME", "Create a new scaffold by template."
      def new(name, template)
        @scaffold_name = name
        directory file_util.scaffold_directory(template), File.expand_path(name)
      end

      desc "scaffold wipe", "Delete all scaffold templates."
      def wipe
        file_util.delete_all_scaffolds
      end

      desc "scaffold list [SEARCH]", "Lists scaffold templates."
      def list(search=nil)
        entries = file_util.scaffold_entries
        entries = entries.select { |e| e.include?(search) } unless search.nil?
        entries.each { |e| say "  #{e}" }
        say "No templates found.", :blue if entries.empty?
      end

      no_tasks {

        def scaffold_name
          @scaffold_name
        end

      }

      private

      def file_util
        @_file_util ||= Gator::Scaffolding::ScaffoldingFileUtils.new
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gator-0.0.25.pre lib/gator/plugins/scaffolding/scaffold_command.rb
gator-0.0.24.pre lib/gator/plugins/scaffolding/scaffold_command.rb
gator-0.0.23.pre lib/gator/plugins/scaffolding/scaffold_command.rb
gator-0.0.22.pre lib/gator/plugins/scaffolding/scaffold_command.rb