Method: TaskLoop::Log#check_log_of_task

Defined in:
lib/taskloop/command/log.rb

#check_log_of_task(name) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/taskloop/command/log.rb', line 50

def check_log_of_task(name)
  found = false
  data_proj_dirs = Dir.entries(taskloop_data_dir)
  data_proj_dirs.each do |dir|
    if dir == "." or dir == ".."
      next
    end
    data_proj_dir = File.join(taskloop_data_dir, dir)

    print_proj = false
    log_files = Dir.entries(data_proj_dir)
    log_files.each do |file|
      if "#{name.sha1}_log" == file
        found = true

        if !print_proj
          print_proj = true
          desc_file_path = File.join(data_proj_dir, ".description")
          puts "=============================".ansi.blue
          File.open(desc_file_path).each_line do |line|
            puts "Project of <#{line.strip}>".ansi.blue
          end
        end
        # print
        task_log_path = File.join(data_proj_dir, "#{name.sha1}_log")
        puts "Log of <Task.name: #{name}> above: ".ansi.blue
        File.open(task_log_path).each_line do |line|
          puts line
        end

        puts "=============================".ansi.blue
        puts ""
      end
    end
  end

  unless found
    puts "Warning: log of <Task.name: #{name}> not exist. Please check if the name of task is correct.".ansi.yellow
    puts ""
  end
end