Sha256: bf63799cee73de602ca1c1042b2fe8fbf8c1f32d85003f4c2a5fd7e33822b13f

Contents?: true

Size: 978 Bytes

Versions: 1

Compression:

Stored size: 978 Bytes

Contents

require 'singleton'
require 'forwardable'
require 'erb'
require 'fileutils'
require 'git'

module SinatraScaffolder
  class Create
    include Singleton
    extend SingleForwardable

    def_delegators :instance, :create
    
    def create(project_name)
      copy_template(project_name)
      init_git_repo(project_name)  
    end
    
    def delete(project_name)
      delete_template(project_name)  
    end

    def copy_template(project_name)
      appRoot = File.join(File.expand_path(File.dirname(__FILE__)),'..')
      FileUtils.cp_r("#{appRoot}/template", project_name)
      puts "Creating the #{project_name} directory"
    end  
    
    def delete_template(project_name)
      FileUtils.remove_dir(project_name)
      puts "Deleting the #{project_name} directory"
    end 
    
    def init_git_repo(project_name)
      g = Git.init(project_name)
      g.add
      g.commit("Initial Commit")
      puts "Initializing the #{project_name} repo"
    end  
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinatra-scaffolder-0.0.3 lib/sinatra-scaffolder/create.rb