Sha256: 9f45ef385ab31ad11d578dd1ff365ca77665694094ded08895f3a106fbc84c12

Contents?: true

Size: 994 Bytes

Versions: 12

Compression:

Stored size: 994 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 grant_permissions
      chmod "./#{snake_name}/bin/deploy", 0755
      chmod "./#{snake_name}/bin/setup", 0755
    end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
kickster-2.2.0 lib/kickster/install.rb
kickster-2.1.0 lib/kickster/install.rb
kickster-2.0.0 lib/kickster/install.rb
kickster-1.5.0 lib/kickster/install.rb
kickster-1.4.0 lib/kickster/install.rb
kickster-1.3.0 lib/kickster/install.rb
kickster-1.2.0 lib/kickster/install.rb
kickster-1.1.4 lib/kickster/install.rb
kickster-1.1.3 lib/kickster/install.rb
kickster-1.1.2 lib/kickster/install.rb
kickster-1.1.1 lib/kickster/install.rb
kickster-1.1.0 lib/kickster/install.rb