module Mobilize::RunnerHelper
Public Instance Methods
dataset()
click to toggle source
# File lib/mobilize-base/helpers/runner_helper.rb, line 18 def dataset r = self Dataset.find_or_create_by_handler_and_path("gsheet",r.path) end
gbook(gdrive_slot)
click to toggle source
# File lib/mobilize-base/helpers/runner_helper.rb, line 23 def gbook(gdrive_slot) r = self title = r.path.split("/").first Gbook.find_by_path(title,gdrive_slot) end
gsheet(gdrive_slot)
click to toggle source
# File lib/mobilize-base/helpers/runner_helper.rb, line 29 def gsheet(gdrive_slot) r = self u = r.user jobs_sheet = Gsheet.find_by_path(r.path,gdrive_slot) #make sure the user has a runner with a jobs sheet and has write privileges on the spreadsheet unless (jobs_sheet and jobs_sheet.spreadsheet.acl_entry(u.email).ie{|e| e and e.role=="writer"}) #only give the user edit permissions if they're the ones #creating it jobs_sheet = Gsheet.find_or_create_by_path(r.path,gdrive_slot) unless jobs_sheet.spreadsheet.acl_entry(u.email).ie{|e| e and e.role=="owner"} jobs_sheet.spreadsheet.update_acl(u.email) end jobs_sheet.add_headers(r.headers) begin;jobs_sheet.delete_sheet1;rescue;end #don't care if sheet1 deletion fails end return jobs_sheet end
headers()
click to toggle source
# File lib/mobilize-base/helpers/runner_helper.rb, line 4 def headers %w{name active trigger status stage1 stage2 stage3 stage4 stage5} end
is_working?()
click to toggle source
# File lib/mobilize-base/helpers/runner_helper.rb, line 70 def is_working? r = self Mobilize::Resque.active_paths.include?(r.path) end
jobs(jname=nil)
click to toggle source
# File lib/mobilize-base/helpers/runner_helper.rb, line 47 def jobs(jname=nil) r = self js = Job.where(:path=>/^#{r.path.escape_regex}/).to_a if jname return js.sel{|j| j.name == jname}.first else return js end end
title()
click to toggle source
# File lib/mobilize-base/helpers/runner_helper.rb, line 8 def title r = self r.path.split("/").first end
update_status(msg)
click to toggle source
# File lib/mobilize-base/helpers/runner_helper.rb, line 63 def update_status(msg) r = self r.update_attributes(:status=>msg, :status_at=>Time.now.utc) Mobilize::Resque.set_worker_args_by_path(r.path,{'status'=>msg}) return true end
user()
click to toggle source
# File lib/mobilize-base/helpers/runner_helper.rb, line 57 def user r = self user_name = r.path.split("_")[1..-1].join("_").split("(").first.split("/").first User.where(:name=>user_name).first end
worker()
click to toggle source
# File lib/mobilize-base/helpers/runner_helper.rb, line 13 def worker r = self Mobilize::Resque.find_worker_by_path(r.path) end