Module: QAT::CLI::Generator
- Included in:
- Main
- Defined in:
- lib/qat/cli/generator.rb,
lib/qat/cli/generator/project.rb
Overview
Module for the various generators used in the CLI utility
Defined Under Namespace
Classes: Project
Instance Method Summary collapse
-
#add_module(name) ⇒ Object
Adds a QAT module to the current project.
-
#add_modules(modules) ⇒ Object
Adds QAT modules to the current project.
-
#create_project(name) ⇒ Object
Creates a new QAT project with a given name.
Instance Method Details
#add_module(name) ⇒ Object
Adds a QAT module to the current project
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/qat/cli/generator.rb', line 35 def add_module(name) @stdout.puts "Adding module #{name}" if @sub_options[:verbose] begin QAT::CLI.add_module name, @stdout, @sub_options @stdout.puts "Module #{name} added to #{Dir.getwd.split(::File::SEPARATOR).last}" rescue => exception @stderr.puts "Error adding module #{name}: #{exception.}" @exit_code = 1 end end |
#add_modules(modules) ⇒ Object
Adds QAT modules to the current project
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/qat/cli/generator.rb', line 21 def add_modules(modules) missing_modules = modules.reject { |mod| QAT::CLI.has_module? mod } if missing_modules.any? raise ArgumentError.new "Module#{missing_modules.size > 1 ? 's' : ''} #{missing_modules.join ','} missing!" end modules.each do |module_name| add_module(module_name) end end |
#create_project(name) ⇒ Object
Creates a new QAT project with a given name
9 10 11 12 13 14 15 16 17 |
# File 'lib/qat/cli/generator.rb', line 9 def create_project(name) QAT::CLI::Generator::Project.new(@stdin, @stdout, @stderr, @kernel).run! name, @sub_options if @options.has_key? :modules FileUtils.cd name, @sub_options do add_modules(@options[:modules]) end end end |