lib/rbbt/util/workflow.rb in rbbt-util-3.1.0 vs lib/rbbt/util/workflow.rb in rbbt-util-3.2.0
- old
+ new
@@ -2,10 +2,19 @@
require 'rbbt/util/task'
require 'rbbt/util/persistence'
require 'rbbt/util/misc'
module WorkFlow
+
+ def self.require_workflow(path)
+ if Rbbt.etc.workflow_dir.exists?
+ require Dir.glob(File.join(Rbbt.etc.workflow_dir.read.strip, '*', path + '.rb')).first
+ else
+ require Dir.glob(File.join(Rbbt.share.workflows.find, '*', path + '.rb')).first
+ end
+ end
+
def self.extended(base)
class << base
attr_accessor :tasks, :jobdir, :dangling_options, :dangling_option_descriptions,
:dangling_option_types, :dangling_option_defaults, :dangling_dependencies, :last_task
end
@@ -51,12 +60,12 @@
@dangling_option_descriptions[name] = description if description
@dangling_option_types[name] = type if type
@dangling_option_defaults[name] = default if default
end
- def task_dependencies(dependencies)
- dependencies = [dependencies] unless Array === dependencies
+ def task_dependencies(*dependencies)
+ dependencies = dependencies.flatten
@dangling_dependencies = dependencies.collect{|dep| Symbol === dep ? tasks[dep] : dep }
end
def task_description(description)
@dangling_description = description
@@ -91,10 +100,10 @@
task = Task.new name, persistence, options, option_descriptions, option_types, option_defaults, self, dependencies, self, description, &block
tasks[name] = task
@last_task = task
end
- def job(task, jobname, *args)
+ def job(task, jobname = "Default", *args)
tasks[task].job(jobname, *args)
end
def run(*args)
job(*args).run