Class: Tumugi::Workflow

Inherits:
Object
  • Object
show all
Defined in:
lib/tumugi/workflow.rb

Constant Summary collapse

DEFAULT_CONFIG_FILE =
"tumugi_config.rb"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWorkflow

Returns a new instance of Workflow.



18
19
20
21
22
# File 'lib/tumugi/workflow.rb', line 18

def initialize
  @id = SecureRandom.uuid
  @tasks = {}
  @params = {}
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



13
14
15
# File 'lib/tumugi/workflow.rb', line 13

def id
  @id
end

#paramsObject

Returns the value of attribute params.



14
15
16
# File 'lib/tumugi/workflow.rb', line 14

def params
  @params
end

Instance Method Details

#add_task(id, task) ⇒ Object



33
34
35
# File 'lib/tumugi/workflow.rb', line 33

def add_task(id, task)
  @tasks[id.to_s] = task
end

#execute(command, root_task_id, options) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/tumugi/workflow.rb', line 24

def execute(command, root_task_id, options)
  process_common_options(command, options)
  load_workflow_file(options[:file])
  dag = create_dag(root_task_id)
  command_module = Kernel.const_get("Tumugi").const_get("Command")
  cmd = command_module.const_get("#{command.to_s.capitalize}").new
  cmd.execute(dag, options)
end

#find_task(id) ⇒ Object



37
38
39
40
41
# File 'lib/tumugi/workflow.rb', line 37

def find_task(id)
  task = @tasks[id.to_s]
  raise Tumugi::TumugiError, "Task not found: #{id}" if task.nil?
  task
end