Class: QAT::CLI::Generator::Project
- Inherits:
-
Object
- Object
- QAT::CLI::Generator::Project
- Includes:
- FileUtils
- Defined in:
- lib/qat/cli/generator/project.rb
Overview
New project generator
Instance Method Summary collapse
-
#initialize(stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Project
constructor
A new instance of Project.
-
#run!(name, opts = {}) ⇒ Object
Create a new project.
Constructor Details
#initialize(stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Project
Returns a new instance of Project.
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.
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 |