Class: Ductr::CLI::NewProjectGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/ductr/cli/new_project_generator.rb

Overview

Thor generator to create a new project

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootString

The templates source used to create a new project

Returns:

  • (String)

    the templates source absolute path



21
22
23
# File 'lib/ductr/cli/new_project_generator.rb', line 21

def self.source_root
  "#{__dir__}/templates/project"
end

Instance Method Details

#gen_binvoid

This method returns an undefined value.

Creates the bin file for the project



57
58
59
# File 'lib/ductr/cli/new_project_generator.rb', line 57

def gen_bin
  copy_file "bin_ductr.rb", "bin/ductr"
end

#gen_configvoid

This method returns an undefined value.

Creates files in the ‘config` folder



66
67
68
69
70
# File 'lib/ductr/cli/new_project_generator.rb', line 66

def gen_config
  copy_file "config_app.rb", "config/app.rb"
  copy_file "config_development.yml", "config/development.yml"
  copy_file "config_environment_development.rb", "config/environment/development.rb"
end

#gen_rootvoid

This method returns an undefined value.

Creates files in the project’s root



41
42
43
44
45
46
47
48
49
50
# File 'lib/ductr/cli/new_project_generator.rb', line 41

def gen_root
  copy_file "gemfile.rb", "Gemfile"
  copy_file "rubocop.yml", ".rubocop.yml"

  create_file "config/initializers/.gitkeep"
  create_file "lib/.gitkeep"
  create_file "app/jobs/.gitkeep"
  create_file "app/pipelines/.gitkeep"
  create_file "app/schedulers/.gitkeep"
end

#initvoid

This method returns an undefined value.

Doing some setup before generating file, creates the project directory and sets it as destination for the generator



31
32
33
34
# File 'lib/ductr/cli/new_project_generator.rb', line 31

def init
  empty_directory name
  self.destination_root = "#{destination_root}/#{name}"
end