Module: Ptf::Commands::Task

Defined in:
lib/ptf/commands/task.rb,
lib/ptf/commands/task/edit.rb,
lib/ptf/commands/task/create.rb

Defined Under Namespace

Modules: Create, Edit

Class Method Summary collapse

Class Method Details

.close(id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ptf/commands/task.rb', line 26

def close(id)
  if !Ptf::FileSystem.id_exist?(id.to_i)
    return "Task #{id} does not exist."
  end

   = Ptf::FileSystem.find_file id.to_i

  if .nil?
    return "Task #{id} has been closed. Reopen it with ptf task reopen ###."
  end

  info = Ptf::MetadataFile.create_from_file()

  info.complete_now
  return "Task #{info.id} is closed."
end

.reopen(id) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ptf/commands/task.rb', line 43

def reopen(id)
  if !Ptf::FileSystem.id_exist?(id.to_i)
    return "Task #{id} does not exist."
  end

   = Ptf::FileSystem.find_file id.to_i, false

  if .nil?
    return "Task #{id} is already open. Close it with ptf task close ###."
  end

  info = Ptf::MetadataFile.create_from_file()

  info.reopen
  return "Task #{info.id} is reopened."
end

.show(id) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ptf/commands/task.rb', line 9

def show(id)
  if !Ptf::FileSystem.id_exist?(id.to_i)
    return "Task #{id} does not exist."
  end

   = Ptf::FileSystem.find_file id.to_i

  if .nil?
    return "Task #{id} has been closed. Reopen it with ptf task reopen ###."
  end

  info = Ptf::MetadataFile.create_from_file()

  data_file = File.join(Ptf::FileSystem.data_dir, info.hash)
  return File.read data_file
end