Class: Taskr::Actions::Ruby

Inherits:
Base
  • Object
show all
Defined in:
lib/taskr/actions.rb

Instance Attribute Summary

Attributes inherited from Base

#parameters, #task, #task_action

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_s, #trigger

Constructor Details

This class inherits a constructor from Taskr::Actions::Base

Instance Method Details

#executeObject



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/taskr/actions.rb', line 174

def execute
  outio = StringIO.new
  errio = StringIO.new
  old_stdout, $stdout = $stdout, outio
  old_stderr, $stderr = $stderr, errio
  
  code = parameters['code']
  eval(code)
  
  err = errio.string
  out = outio.string
  LogEntry.debug(task_action, out) unless out.blank?
  LogEntry.error(task_action, err) unless err.blank?
  
  $stdout = old_stdout
  $stderr = old_stderr
end