Class: VRCron

Inherits:
Object
  • Object
show all
Defined in:
lib/VRCron.rb

Overview

VRCron is the parent class for all cronjobs tied into the Vulnreport system. By extending the VRCron class, cronjob classes will automatically be registered into the Vulnreport scheduler instance and run as part of the Vulnreport system (with access to the database and all other parts of Vulnreport).

VRCron subclasses must define vrcron_name (a user-friendly and unique name for the cronjob), vrcron_type of either :cron or :every, and vrcron_schedule with information when they should run. For instance, vrcron_type of :every and vrcron_schedule of 10m runs every 10 minutes. On the other hand, vrcron_type of :cron and vr_schedule of a crontab string '0 7 * * 1,3,5' runs MWF at 0700.

VRCron subclasses must finally define a cron() method which is what will be invoked by the scheduler.

Direct Known Subclasses

AllocationNotification, AllocationPreset

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) cronjobs



27
28
29
# File 'lib/VRCron.rb', line 27

def cronjobs
	@cronjobs ||= []
end

+ (Object) each(&block)



46
47
48
49
50
# File 'lib/VRCron.rb', line 46

def each(&block)
	cronjobs.each do |member|
		block.call(member)
	end
end

+ (Object) vrcron_name(name = nil)



31
32
33
34
# File 'lib/VRCron.rb', line 31

def vrcron_name(name=nil)
	@vrcron_name = name.to_s if !name.nil?
	@vrcron_name ||= self.name
end

+ (Object) vrcron_schedule(sched = nil)



41
42
43
44
# File 'lib/VRCron.rb', line 41

def vrcron_schedule(sched=nil)
	@vrcron_schedule = sched.to_s if !sched.nil?
	@vrcron_schedule ||= nil
end

+ (Object) vrcron_type(type = nil)



36
37
38
39
# File 'lib/VRCron.rb', line 36

def vrcron_type(type=nil)
	@vrcron_type = type if !type.nil?
	@vrcron_type ||= nil
end

Instance Method Details

- (Object) cron



54
55
56
# File 'lib/VRCron.rb', line 54

def cron
	raise "NotImplemented"
end