Sha256: 040850dbd485972bc2661a234036de92efa0901d95c2b43cb476044e1dd829a8

Contents?: true

Size: 1.73 KB

Versions: 61

Compression:

Stored size: 1.73 KB

Contents

# encoding: utf-8
module Mutx
  module Tasks

    def self.is_there_task_with? name, type=nil
      self.task_id_for name, type
    end

    # Returns a list of tasks id
    # @param [Boolean] type or not
    # @return [Array] a list of task ids
    def self.tasks type=nil
      Mutx::Support::Log.debug "Tasks:Getting all tasks ids" if Mutx::Support::Log
      Mutx::Database::MongoConnector.tasks(type)
    end

    # Returns the id for given task name
    # @param [String] task name
    # @return [Fixnum] task id
    def self.task_id_for(task_name, type=nil)
      Mutx::Support::Log.debug "Tasks:Getting task id for #{task_name}" if Mutx::Support::Log
      Mutx::Database::MongoConnector.task_id_for(task_name, type)
    end

    # Returns the ids for running tasks
    # @return [Array] of task ids
    def self.running_tasks
      Mutx::Database::MongoConnector.running_tasks
    end

    def self.running_tests
      Mutx::Database::MongoConnector.running_tests
    end

    def self.exist_task? task_id
      !Mutx::Database::MongoConnector.task_data_for(task_id).nil?
    end

    def self.exist? task_id
        self.exist_task? task_id
    end

    def self.is_there_running_executions_for? task_name
        self.number_of_running_executions_for_task(task_name)>0
    end

    def self.number_of_running_executions_for_task task_name
      Mutx::Database::MongoConnector.running_for_task(task_name).size
    end

    def self.delete! task_id
      if self.exist_task? task_id
        Mutx::Database::MongoConnector.delete_task task_id
        success = true
        message = "Task deleted!"
      else
        success = false
        message = "Could not find task with id '#{task_id}'"
      end
      {success:success, message:message}
    end

  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
mutx-0.2.9 lib/mutx/tasks/tasks.rb
mutx-0.2.8 lib/mutx/tasks/tasks.rb
mutx-0.2.7 lib/mutx/tasks/tasks.rb
mutx-0.2.6 lib/mutx/tasks/tasks.rb
mutx-0.2.5 lib/mutx/tasks/tasks.rb
mutx-0.2.4 lib/mutx/tasks/tasks.rb
mutx-0.2.3 lib/mutx/tasks/tasks.rb
mutx-0.2.2 lib/mutx/tasks/tasks.rb
mutx-0.2.1 lib/mutx/tasks/tasks.rb
mutx-0.2.0 lib/mutx/tasks/tasks.rb
mutx-0.1.69 lib/mutx/tasks/tasks.rb
mutx-0.1.68 lib/mutx/tasks/tasks.rb
mutx-0.1.67 lib/mutx/tasks/tasks.rb
mutx-0.1.66 lib/mutx/tasks/tasks.rb
mutx-0.1.65 lib/mutx/tasks/tasks.rb
mutx-0.1.64 lib/mutx/tasks/tasks.rb
mutx-0.1.63 lib/mutx/tasks/tasks.rb
mutx-0.1.62 lib/mutx/tasks/tasks.rb
mutx-0.1.61 lib/mutx/tasks/tasks.rb
mutx-0.1.60 lib/mutx/tasks/tasks.rb