class FlowTask
Public Instance Methods
run_command(cmd)
click to toggle source
Runs a system command with logging, captures STDIN, STDOUT, and STDERR and returns them
# File lib/app/models/flow_task.rb, line 34 def run_command(cmd) require 'open3' Rails.logger.info "[INFO #{Time.now}] #{self} running #{cmd}" update_attribute(:command, cmd) stdin, stdout, stderr = Open3.popen3(cmd) [stdin, stdout, stderr].map do |io| s = io.read.strip rescue nil io.close s end end
status()
click to toggle source
# File lib/app/models/flow_task.rb, line 21 def status if error_msg.present? "error" elsif finished_at.present? "done" elsif started_at.present? "working" else "start" end end
to_param()
click to toggle source
to be used as the friendly URL
# File lib/app/models/flow_task.rb, line 17 def to_param "#{id}-#{self.class.to_s.underscore}" end