Sha256: 3bffa5dbb3e2ae7aa460923ace6fa0b2b9a725f059e9d7370f9bbe41d185f59d

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8
module Mutx
  module API

    class Task

      def self.info(task_id)
        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

      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


      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mutx-0.1.18 lib/mutx/API/task.rb
mutx-0.1.17 lib/mutx/API/task.rb
mutx-0.1.16 lib/mutx/API/task.rb