Sha256: 00ee53d1710a73443d442eeaa3d0dc3572e30025b942197a728752d428b7c675

Contents?: true

Size: 995 Bytes

Versions: 4

Compression:

Stored size: 995 Bytes

Contents

require "thor"

module Jalpha
  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/cideploy.sh", 0755
      chmod "./#{snake_name}/bin/setup", 0755
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jalpha-0.3.1 lib/jalpha/install.rb
jalpha-0.3 lib/jalpha/install.rb
jalpha-0.2 lib/jalpha/install.rb
jalpha-0.1 lib/jalpha/install.rb