Class: RubyTeamSite::WFtask
- Inherits:
-
Object
- Object
- RubyTeamSite::WFtask
- Defined in:
- lib/ruby_teamsite/wftask.rb
Instance Method Summary collapse
-
#add_file(f, comment) ⇒ Object
Add a file to the task.
-
#areavpath ⇒ Object
Return the areavpath of the task.
-
#callback(trans_num, comment = nil) ⇒ Object
Callback to the workflow system to transition an external or cgi task.
-
#failure(msg = nil) ⇒ Object
Callback with failure to the workflow system to transition an external or cgi task to it’s failure successor.
-
#files ⇒ Object
Return an array of files attached to this task.
-
#id ⇒ Object
Return the id of the task.
-
#initialize(task_id) ⇒ WFtask
constructor
Initialize the WFtask class by getting the task from the workflow system by ID.
-
#name ⇒ Object
Return the name of the task.
-
#remove_file(f) ⇒ Object
Remove a file to the task.
-
#success(msg = nil) ⇒ Object
Callback with success to the workflow system to transition an external or cgi task to it’s success successor.
-
#type ⇒ Object
Return the type of the task.
-
#xml ⇒ Object
Return the XML output of the task.
Constructor Details
#initialize(task_id) ⇒ WFtask
Initialize the WFtask class by getting the task from the workflow system by ID.
12 13 14 15 16 17 |
# File 'lib/ruby_teamsite/wftask.rb', line 12 def initialize(task_id) @task_id = task_id.strip @ts_bin = ts_bin @task = `#{@ts_bin}/iwgetwfobj #{task_id.strip}` set_task_info(@task) end |
Instance Method Details
#add_file(f, comment) ⇒ Object
Add a file to the task. Comment is required but sending a blank is acceptable.
65 66 67 68 69 70 |
# File 'lib/ruby_teamsite/wftask.rb', line 65 def add_file(f,comment) file_path = "/#{f}" addfile = `#{@ts_bin}/iwaddtaskfile #{@task_id} #{file_path} "#{comment}" 2>&1` refresh return addfile end |
#areavpath ⇒ Object
Return the areavpath of the task.
40 41 42 |
# File 'lib/ruby_teamsite/wftask.rb', line 40 def areavpath return @areavpath end |
#callback(trans_num, comment = nil) ⇒ Object
Callback to the workflow system to transition an external or cgi task.
45 46 47 48 49 50 51 52 |
# File 'lib/ruby_teamsite/wftask.rb', line 45 def callback(trans_num, comment=nil) # Only do a callback if the task is a cgitask or an externaltask. cb = "" if @task_type == 'cgitask' || @task_type == 'externaltask' cb = `#{@ts_bin}/iwcallback #{@task_id} #{trans_num} "#{comment}" 2>&1` end return cb end |
#failure(msg = nil) ⇒ Object
Callback with failure to the workflow system to transition an external or cgi task to it’s failure successor.
60 61 62 |
# File 'lib/ruby_teamsite/wftask.rb', line 60 def failure(msg=nil) callback(1,msg) end |
#files ⇒ Object
Return an array of files attached to this task.
81 82 83 84 85 86 87 88 89 |
# File 'lib/ruby_teamsite/wftask.rb', line 81 def files tsk = Nokogiri::XML(@task, nil, 'UTF-8') elmnt_files = tsk.css('files file') files = [] if elmnt_files.empty? == false elmnt_files.each {|f| files << f.attribute('path').to_s} end return files end |
#id ⇒ Object
Return the id of the task.
30 31 32 |
# File 'lib/ruby_teamsite/wftask.rb', line 30 def id return @task_id end |
#name ⇒ Object
Return the name of the task.
20 21 22 |
# File 'lib/ruby_teamsite/wftask.rb', line 20 def name return @task_name end |
#remove_file(f) ⇒ Object
Remove a file to the task.
73 74 75 76 77 78 |
# File 'lib/ruby_teamsite/wftask.rb', line 73 def remove_file(f) file_path = "/#{f}" rmfile = `#{@ts_bin}/iwrmtaskfile #{@task_id} #{file_path} 2>&1` refresh return rmfile end |
#success(msg = nil) ⇒ Object
Callback with success to the workflow system to transition an external or cgi task to it’s success successor.
55 56 57 |
# File 'lib/ruby_teamsite/wftask.rb', line 55 def success(msg=nil) callback(0,msg) end |
#type ⇒ Object
Return the type of the task.
25 26 27 |
# File 'lib/ruby_teamsite/wftask.rb', line 25 def type return @task_type end |
#xml ⇒ Object
Return the XML output of the task.
35 36 37 |
# File 'lib/ruby_teamsite/wftask.rb', line 35 def xml return @task end |