module Mobilize::JobHelper

Public Instance Methods

active_stage() click to toggle source
# File lib/mobilize-base/helpers/job_helper.rb, line 21
def active_stage
  j = self
  #latest started at or first
  j.stages.select{|s| s.started_at}.sort_by{|s| s.started_at}.last || j.stages.first
end
completed_at() click to toggle source
# File lib/mobilize-base/helpers/job_helper.rb, line 27
def completed_at
  j = self
  j.stages.last.completed_at if j.stages.last
end
failed_at() click to toggle source
# File lib/mobilize-base/helpers/job_helper.rb, line 32
def failed_at
  j = self
  j.active_stage.failed_at if j.active_stage
end
is_working?() click to toggle source
# File lib/mobilize-base/helpers/job_helper.rb, line 49
def is_working?
  j = self
  j.stages.select{|s| s.is_working?}.compact.length>0
end
name() click to toggle source
# File lib/mobilize-base/helpers/job_helper.rb, line 4
def name
  j = self
  j.path.split("/").last
end
runner() click to toggle source

convenience methods

# File lib/mobilize-base/helpers/job_helper.rb, line 43
def runner
  j = self
  runner_path = j.path.split("/")[0..1].join("/")
  return Runner.where(:path=>runner_path).first
end
stages() click to toggle source
# File lib/mobilize-base/helpers/job_helper.rb, line 9
def stages
  j = self
  #starts with the job path, followed by a slash
  Stage.where(:path=>/^#{j.path.escape_regex}\//).to_a.sort_by{|s| s.path}
end
status() click to toggle source
# File lib/mobilize-base/helpers/job_helper.rb, line 15
def status
  #last stage status
  j = self
  j.active_stage.status if j.active_stage
end
status_at() click to toggle source
# File lib/mobilize-base/helpers/job_helper.rb, line 37
def status_at
  j = self
  j.active_stage.status_at if j.active_stage
end