Module: Task
- Defined in:
- lib/rbbt/workflow/task.rb,
lib/rbbt/workflow/usage.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#input_defaults ⇒ Object
Returns the value of attribute input_defaults.
-
#input_descriptions ⇒ Object
Returns the value of attribute input_descriptions.
-
#input_options ⇒ Object
Returns the value of attribute input_options.
-
#input_types ⇒ Object
Returns the value of attribute input_types.
-
#inputs ⇒ Object
Returns the value of attribute inputs.
-
#name ⇒ Object
Returns the value of attribute name.
-
#result_description ⇒ Object
Returns the value of attribute result_description.
-
#result_type ⇒ Object
Returns the value of attribute result_type.
Class Method Summary collapse
Instance Method Summary collapse
- #doc(deps = nil) ⇒ Object
- #exec(*args) ⇒ Object
- #exec_in(object, *args) ⇒ Object
- #param_options ⇒ Object
- #parse_description ⇒ Object
- #persist_exec(filename, *args) ⇒ Object
- #persist_exec_in(filename, *args) ⇒ Object
- #take_input_values(input_values) ⇒ Object
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/rbbt/workflow/task.rb', line 5 def description @description end |
#input_defaults ⇒ Object
Returns the value of attribute input_defaults.
5 6 7 |
# File 'lib/rbbt/workflow/task.rb', line 5 def input_defaults @input_defaults end |
#input_descriptions ⇒ Object
Returns the value of attribute input_descriptions.
5 6 7 |
# File 'lib/rbbt/workflow/task.rb', line 5 def input_descriptions @input_descriptions end |
#input_options ⇒ Object
Returns the value of attribute input_options.
5 6 7 |
# File 'lib/rbbt/workflow/task.rb', line 5 def @input_options end |
#input_types ⇒ Object
Returns the value of attribute input_types.
5 6 7 |
# File 'lib/rbbt/workflow/task.rb', line 5 def input_types @input_types end |
#inputs ⇒ Object
Returns the value of attribute inputs.
5 6 7 |
# File 'lib/rbbt/workflow/task.rb', line 5 def inputs @inputs end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/rbbt/workflow/task.rb', line 5 def name @name end |
#result_description ⇒ Object
Returns the value of attribute result_description.
5 6 7 |
# File 'lib/rbbt/workflow/task.rb', line 5 def result_description @result_description end |
#result_type ⇒ Object
Returns the value of attribute result_type.
5 6 7 |
# File 'lib/rbbt/workflow/task.rb', line 5 def result_type @result_type end |
Class Method Details
.setup(options = {}, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rbbt/workflow/task.rb', line 7 def self.setup( = {}, &block) block.extend Task = IndiferentHash.setup block.singleton_methods. select{|method| method.to_s[-1] != "="[0]}.each{|method| if block.respond_to?(method.to_s + "=") and .include? method.to_sym block.send(method.to_s + '=', [method.to_sym]) end } block end |
Instance Method Details
#doc(deps = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rbbt/workflow/usage.rb', line 4 def doc(deps = nil) puts "## #{ name }:" puts "\n" << description if description and not description.empty? puts puts SOPT.input_doc(inputs, input_types, input_descriptions, input_defaults) if deps and deps.any? puts puts "From dependencies:" puts deps.each do |dep| puts " #{dep.name}:" puts puts SOPT.input_doc(dep.inputs, dep.input_types, dep.input_descriptions, dep.input_defaults) puts end end end |
#exec(*args) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/rbbt/workflow/task.rb', line 46 def exec(*args) case when (args.length == 1 and not inputs.nil? and inputs.length > 1 and Hash === args.first) self.call *take_input_values(IndiferentHash.setup(args.first)) else self.call *args end end |
#exec_in(object, *args) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/rbbt/workflow/task.rb', line 55 def exec_in(object, *args) case when (args.length == 1 and not inputs.nil? and inputs.length > 1 and Hash === args.first) object.instance_exec *IndiferentHash.setup(args.first).values_at(*inputs), &self else object.instance_exec *args, &self end end |
#param_options ⇒ Object
32 33 |
# File 'lib/rbbt/workflow/task.rb', line 32 def end |
#parse_description ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rbbt/workflow/task.rb', line 19 def parse_description if description =~ /\n\n/ short_description, rest = description.match(/(.*?)\n\n(.*)/).values_at 1, 2 else short_description = description rest = nil end if rest.nil? long_description = "" end end |
#persist_exec(filename, *args) ⇒ Object
64 65 66 67 68 |
# File 'lib/rbbt/workflow/task.rb', line 64 def persist_exec(filename, *args) Persist.persist "Task", @persistence_type, :file => filename do exec *args end end |
#persist_exec_in(filename, *args) ⇒ Object
70 71 72 73 74 |
# File 'lib/rbbt/workflow/task.rb', line 70 def persist_exec_in(filename, *args) Persist.persist "Task", @persistence_type, :file => filename do exec_in *args end end |
#take_input_values(input_values) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rbbt/workflow/task.rb', line 35 def take_input_values(input_values) return [] if @inputs.nil? values = [] @inputs.each do |input| value = input_values[input] value = IndiferentHash.setup(@input_defaults || {})[input] if value.nil? values << value end values end |