Class: TaskLoop::Undeploy

Inherits:
Command
  • Object
show all
Defined in:
lib/taskloop/command/undeploy.rb

Constant Summary

Constants inherited from Command

Command::DOLPHIN, Command::LOGO

Instance Method Summary collapse

Methods inherited from Command

#create_dir_if_needed, #create_file_if_needed, #create_taskloop_file_structure_if_needed, #initialize, #taskloop_cron_log_path, #taskloop_cron_tab_path, #taskloop_data_dir, #taskloop_data_proj_dirs, #taskloop_dir, #taskloop_environments_path, #taskloop_proj_list_dirs, #taskloop_proj_list_path, #taskloop_taskfile_paths, #tasklooprc_path

Constructor Details

This class inherits a constructor from TaskLoop::Command

Instance Method Details

#remove_proj_path_from_projlistObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/taskloop/command/undeploy.rb', line 24

def remove_proj_path_from_projlist
  current_dir = Dir.pwd
  proj_list_dirs = taskloop_proj_list_dirs
  unless proj_list_dirs.include?(current_dir)
    puts "Warning: current Taskfile is not deployed before. Do not need to undeploy it again.".ansi.yellow
    return
  end
  proj_list_dirs.delete(current_dir)
  File.open(taskloop_proj_list_path, "w") do |file|
    file.write(JSON.pretty_generate(proj_list_dirs))
  end

  data_proj_dir = File.join(taskloop_data_dir, current_dir.sha1_8bit)
  unless File.directory?(data_proj_dir)
    puts "Warning: #{data_proj_dir} not exist. ".ansi.yellow
    return
  end

  FileUtils.rm_rf(data_proj_dir)
  puts "Taskfile in <#{current_dir}> has been undeployed successfully.".ansi.blue
end

#runObject



14
15
16
17
18
19
20
21
22
# File 'lib/taskloop/command/undeploy.rb', line 14

def run
  super
  unless File.exists?(:Taskfile.to_s)
    puts "Error: 'taskloop undeploy' command should be executed in the directory where Taskfile exists.".ansi.red
    return
  end

  remove_proj_path_from_projlist
end