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
31
32
33
34
35
36
37
38
39
40
41
# 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

  if opts.any?
    mkdir name, verbose: true
    cp_r ::File.join(::File.dirname(__FILE__), '..', '..', 'project', '.'), name
    cd name do
      mkdir_p ::File.join('config', 'common'), verbose: true
      mkdir_p 'lib', verbose: true
      mkdir_p 'public', verbose: true
    end
  else
    mkdir name
    cp_r ::File.join(::File.dirname(__FILE__), '..', '..', 'project', '.'), name
    cd name do
      mkdir_p ::File.join('config', 'common')
      mkdir_p 'lib'
      mkdir_p 'public'
    end
  end


end