Sha256: 8eae264491a64fd3f735501d43d91149a89c01df1dd79931960a1a05d7caa210

Contents?: true

Size: 866 Bytes

Versions: 4

Compression:

Stored size: 866 Bytes

Contents

require "thor"

module Kickster
  class Install < Thor::Group
    include Thor::Actions

    argument :name
    class_options force: :boolean

    def self.source_root
      File.expand_path("../../../template", __FILE__)
    end

    def name_components
      @_name_components ||= name.scan(/[[:alnum:]]+/)
    end

    def snake_name
      @_snake_name = name_components.map(&:downcase).join("_")
    end

    def camel_name
      @_camel_name = name_components.map(&:capitalize).join("")
    end

    def check_if_exists?
      if File.directory?(snake_name) && !options[:force]
        say "Folder already exist, use --force to overwrite.", :red
        exit 1
      end
    end

    def copy_templates
      directory("./", "./#{snake_name}")
    end

    def report_success
      say "Kickster template folder successfully created!", :green
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kickster-1.0.4 lib/kickster/install.rb
kickster-1.0.3 lib/kickster/install.rb
kickster-1.0.2 lib/kickster/install.rb
kickster-0.2.0 lib/kickster/install.rb