Class: QAT::CLI::Generator::Project

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/qat/cli/generator/project.rb

Overview

New project generator

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Project

Returns a new instance of Project.

Since:

  • 0.1.0



11
12
13
# File 'lib/qat/cli/generator/project.rb', line 11

def initialize stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel
  @fileutils_output = stdout
end

Instance Method Details

#run!(name, opts = {}) ⇒ Object

Create a new project. Will create a new folder with the project’s name.

Parameters:

  • name (String)

    The new project’s name

Since:

  • 0.1.0



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/qat/cli/generator/project.rb', line 17

def run! name, opts={}

  raise ArgumentError.new 'No project name given' unless name
  raise ArgumentError.new "The project '#{name}' already exists" if ::File.directory? name

  mkdir name, opts
  cp_r ::File.join(::File.dirname(__FILE__), '..', '..', 'project', '.'), name, opts
  cd name, opts do
    mkdir_p ::File.join('config', 'common'), opts
    mkdir_p 'lib', opts
    mkdir_p 'public', opts
  end

end