Class: RailsInteractive::CLI::CommandHandler
- Inherits:
-
Object
- Object
- RailsInteractive::CLI::CommandHandler
- Defined in:
- lib/cli/command_handler.rb
Overview
Commands class for the interactive CLI module
Instance Method Summary collapse
- #handle_dependencies(dependencies) ⇒ Object
- #handle_multi_options(options, dependencies = nil) ⇒ Object
- #handle_option(option, dependencies = nil) ⇒ Object
-
#initialize ⇒ CommandHandler
constructor
A new instance of CommandHandler.
Constructor Details
#initialize ⇒ CommandHandler
Returns a new instance of CommandHandler.
10 11 12 13 14 |
# File 'lib/cli/command_handler.rb', line 10 def initialize @commands = Command.new.all @installed_commands = [] @installed_dependencies = [] end |
Instance Method Details
#handle_dependencies(dependencies) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cli/command_handler.rb', line 32 def handle_dependencies(dependencies) dependencies&.each do |dependency| next if duplicated_gem?(dependency) puts ">> Dependency Detected: #{dependency} " @installed_dependencies << dependency system("bin/rails app:template LOCATION=templates/setup_#{dependency}.rb") end end |
#handle_multi_options(options, dependencies = nil) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/cli/command_handler.rb', line 16 def (, dependencies = nil) handle_dependencies(dependencies) .each do |option| @installed_commands << option system("bin/rails app:template LOCATION=templates/setup_#{option}.rb") end end |
#handle_option(option, dependencies = nil) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/cli/command_handler.rb', line 25 def handle_option(option, dependencies = nil) @installed_commands << option handle_dependencies(dependencies) system("bin/rails app:template LOCATION=templates/setup_#{option}.rb") end |