Module: Taskmaster

Defined in:
lib/taskmaster.rb,
lib/taskmaster/railtie.rb,
lib/taskmaster/henchman.rb

Defined Under Namespace

Modules: Henchman Classes: Railtie

Class Method Summary collapse

Class Method Details

.aggregateObject



7
8
9
10
11
12
13
14
# 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_wheneverObject



16
17
18
19
20
21
22
23
# 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

.applicationObject



38
39
40
41
42
# File 'lib/taskmaster.rb', line 38

def self.application
  Rails.root.basename.to_s
rescue
  "application"
end

.cron_outputObject



33
34
35
36
# 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) ⇒ Object



25
26
27
28
29
30
31
# 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