module Taskmaster
Public Class Methods
aggregate()
click to toggle source
# File lib/taskmaster.rb, line 7 def self.aggregate load_rails_models hash = Henchman.included_in.inject({}) do |hash, klass| hash[klass.name] = klass.cron_output.strip hash end hash end
aggregate_whenever()
click to toggle source
# File lib/taskmaster.rb, line 16 def self.aggregate_whenever load_rails_models array = Henchman.included_in.inject([]) do |arr, klass| arr << klass.scheduled_jobs arr end array.flatten.join("\n") end
application()
click to toggle source
# File lib/taskmaster.rb, line 38 def self.application Rails.root.basename.to_s rescue "application" end
cron_output()
click to toggle source
# File lib/taskmaster.rb, line 33 def self.cron_output raw_output = aggregate raw_output.keys.map { |key| section(key, raw_output[key]) }.join("\n") end
section(key, cron)
click to toggle source
# File lib/taskmaster.rb, line 25 def self.section(key, cron) buffer = [] buffer << "#-- begin Taskmaster cron for #{application} - #{key}" buffer << cron buffer << "#-- end Taskmaster cron for #{application} - #{key}\n" buffer end
Private Class Methods
load_rails_models()
click to toggle source
# File lib/taskmaster.rb, line 45 def self.load_rails_models if defined?(Rails) Dir[Rails.root.join('app', 'models', '**', '*.rb')].each { |file| require file } end end