class CubaGenie::Command
Attributes
description[R]
error[R]
project_name[R]
rollback_msg[R]
Public Class Methods
new(**args)
click to toggle source
# File lib/cuba_genie/command.rb, line 16 def initialize(**args) # arrays used to keep track of files created, so that they # can be rolled back, if needed @files_created, @dirs_created = [], [] end
Public Instance Methods
execute() { || ... }
click to toggle source
Yields to a block where the user puts their command code
@param N/A
@return [Boolean] true if methods runs without problems, false if an exception is raised
@note any files or directories created here should have their path pushed to @files_created and @dirs_created arrays.
# File lib/cuba_genie/command.rb, line 33 def execute yield true rescue Exception => e puts e.message and false end
unexecute()
click to toggle source
Deletes all files and directories created with the execute method.
@param N/A
@return [Boolean] true if methods runs without problems, false if an exception is raised
# File lib/cuba_genie/command.rb, line 50 def unexecute puts @rollback_msg unless ENV['RACK_ENV'] == 'test' @files_created.each do |file_path| File.delete file_path if File.exist? file_path end @dirs_created.each do |dir_name| FileUtils.rm_rf(dir_name) if Dir.exist? dir_name end end