Sha256: 61639af3525d3a945d7a87cb9f09d5a2cd49a4e1e49fa2f3f59e868194ad249f

Contents?: true

Size: 1.3 KB

Versions: 20

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

20 entries across 20 versions & 1 rubygems

Version Path
squib-0.13.4 lib/squib/commands/new.rb
squib-0.13.3 lib/squib/commands/new.rb
squib-0.13.2 lib/squib/commands/new.rb
squib-0.13.1 lib/squib/commands/new.rb
squib-0.13.0 lib/squib/commands/new.rb
squib-0.12.0 lib/squib/commands/new.rb
squib-0.11.0 lib/squib/commands/new.rb
squib-0.10.0 lib/squib/commands/new.rb
squib-0.9.0 lib/squib/commands/new.rb
squib-0.8.0 lib/squib/commands/new.rb
squib-0.7.0 lib/squib/commands/new.rb
squib-0.6.0 lib/squib/commands/new.rb
squib-0.5.1 lib/squib/commands/new.rb
squib-0.5.0 lib/squib/commands/new.rb
squib-0.4.0 lib/squib/commands/new.rb
squib-0.3.0 lib/squib/commands/new.rb
squib-0.2.0 lib/squib/commands/new.rb
squib-0.1.0 lib/squib/commands/new.rb
squib-0.0.6 lib/squib/commands/new.rb
squib-0.0.5 lib/squib/commands/new.rb