Class: Whenever::JobList
- Inherits:
-
Object
- Object
- Whenever::JobList
- Defined in:
- lib/job_list.rb
Instance Method Summary collapse
- #command(task, options = {}) ⇒ Object
- #env(variable, value) ⇒ Object
- #every(frequency, options = {}) ⇒ Object
- #generate_cron_output ⇒ Object
-
#initialize(options) ⇒ JobList
constructor
A new instance of JobList.
- #rake(task, options = {}) ⇒ Object
- #runner(task, options = {}) ⇒ Object
- #set(variable, value) ⇒ Object
Constructor Details
#initialize(options) ⇒ JobList
Returns a new instance of JobList.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/job_list.rb', line 4 def initialize() @jobs = Hash.new @env = Hash.new config = case when String then when Hash @cron_log = [:cron_log] if .has_key? :cron_log @no_stderr_redirect = [:no_stderr_redirect] if .has_key? :no_stderr_redirect if [:string] [:string] elsif [:file] File.read([:file]) end end eval(config) end |
Instance Method Details
#command(task, options = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/job_list.rb', line 38 def command(task, = {}) [:cron_log] ||= @cron_log unless [:cron_log] === false [:no_stderr_redirect] ||= @no_stderr_redirect unless [:no_stderr_redirect] === false [:class] ||= Whenever::Job::Default @jobs[@current_time_scope] ||= [] @jobs[@current_time_scope] << [:class].new(@options.merge(:task => task).merge()) end |
#env(variable, value) ⇒ Object
28 29 30 |
# File 'lib/job_list.rb', line 28 def env(variable, value) @env[variable.to_s] = value end |
#every(frequency, options = {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/job_list.rb', line 32 def every(frequency, = {}) @current_time_scope = frequency @options = yield end |
#generate_cron_output ⇒ Object
58 59 60 |
# File 'lib/job_list.rb', line 58 def generate_cron_output [environment_variables, cron_jobs].compact.join end |
#rake(task, options = {}) ⇒ Object
52 53 54 55 56 |
# File 'lib/job_list.rb', line 52 def rake(task, = {}) .reverse_merge!(:environment => @environment, :path => @path) [:class] = Whenever::Job::RakeTask command(task, ) end |
#runner(task, options = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/job_list.rb', line 46 def runner(task, = {}) .reverse_merge!(:environment => @environment, :path => @path) [:class] = Whenever::Job::Runner command(task, ) end |
#set(variable, value) ⇒ Object
23 24 25 26 |
# File 'lib/job_list.rb', line 23 def set(variable, value) instance_variable_set("@#{variable}".to_sym, value) self.class.send(:attr_reader, variable.to_sym) end |