Class: Mutx::API::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/mutx/API/task.rb

Class Method Summary collapse

Class Method Details

.info(task_id) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mutx/API/task.rb', line 7

def self.info(task_id)
  #task_id = task_id.to_i if task_id.respond_to? :to_i "NO PASAR EL ID A TO_I"
  response = {
    "project_name" => Dir.pwd.split("/").last,
    "task" => nil,
    "message" => nil
  }
  task = Mutx::Tasks::Task.get(task_id)
  Mutx::Support::Log.debug "Task info for '#{task_id}'"
  if task.nil?
    response["message"] = "Task not found"
  else
    response["task"] = task.api_response
  end
  response
end

.info_for_name(task_name) ⇒ Object



24
25
26
27
28
# File 'lib/mutx/API/task.rb', line 24

def self.info_for_name task_name
  Mutx::Support::Log.debug "Asked info for '#{task_name}'"
  task_id = Mutx::Tasks.task_id_for(task_name)
  self.info(task_id)
end

.status(task_id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mutx/API/task.rb', line 31

def self.status task_id
  Mutx::Support::Log.debug "Task status for '#{task_i}'"
  response = info(task_id)

  output = if response["message"]
    {
      "task_id" => nil,
      "message" => response["message"]
    }
  else
    {
      "task_id" => response["task"]["_id"],
      "status" => response["task"]["status"]
    }
  end
  output
end