Sha256: acc7fc600047a02fadae9cd02bc369336ef134832e9cf692c898d532c5bd2fd3

Contents?: true

Size: 889 Bytes

Versions: 4

Compression:

Stored size: 889 Bytes

Contents

module Tonic
  module Template
    class << self

      def create(name = "")
        if name.empty?
          copy_template
        else
          sh "mkdir #{name}"
          copy_template(name)
        end

        log_files
        bundle_install(name)
      end

      protected

      def copy_template(new_path = "")
        path =  File.expand_path('../../../template', __FILE__)
        puts path
        sh "cp #{path}/.* ./#{new_path}"
        sh "cp -r #{path}/* ./#{new_path}"
      end

      private

      def sh(*command)
        Tonic::Shell.run(*command)
      end

      def log_files
        puts 'Created files:'
        Dir[File.expand_path '../../../template/**/*', __FILE__].each {|it| puts it }
      end

      def bundle_install(name = "")
        puts 'Running bundle install'
        sh "cd ./#{name}"
        sh "bundle install"
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tonic-0.0.6 lib/tonic/template.rb
tonic-0.0.4 lib/tonic/template.rb
tonic-0.0.3 lib/tonic/template.rb
tonic-0.0.2 lib/tonic/template.rb