Sha256: bb704665c5e2af0e1e79f65d95894b1c1ee13e501e2c125c6b5a82eef2a9b1fe

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'fileutils'

module Squib
  # Squib's command-line options
  module Commands

    # Generate a new Squib project into a fresh directory.
    #
    # Provides conventions for using Git (you are using version control, right??). 
    # Also provides some basic layout and config files to start from, along with templates for instructions and other notes you don't want to forget.
    # 
    #
    # @example
    #   squib new foo-blasters
    #   cd foo-blasters
    #   ruby deck.rb
    #   git init
    #   git add .
    #   git commit -m "Starting my cool new game using Squib!"
    #
    # @api public
    class New

      # :nodoc:
      # @api private 
      def process(args)
        raise ArgumentError.new('Please specify a path.') if args.empty?

        new_project_path = File.expand_path(args.join(" "), Dir.pwd)
        template_path = File.expand_path('../project_template', File.dirname(__FILE__))

        FileUtils.mkdir_p new_project_path
        if !Dir["#{new_project_path}/**/*"].empty?
          $stderr.puts "#{new_project_path} exists and is not empty. Doing nothing and quitting."
        else
          Dir.chdir(new_project_path) do
            FileUtils.cp_r template_path + '/.', new_project_path
          end
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
squib-0.0.4 lib/squib/commands/new.rb