Class: Whenever::JobList
- Inherits:
-
Object
- Object
- Whenever::JobList
- Defined in:
- lib/whenever/job_list.rb
Instance Method Summary collapse
- #cap(task, options = {}) ⇒ Object
- #command(task, options = {}) ⇒ Object
- #env(variable, value) ⇒ Object
- #every(frequency, options = {}) ⇒ Object
- #generate_cron_output ⇒ Object
- #in_sequence(options = {}) ⇒ 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 22 |
# File 'lib/whenever/job_list.rb', line 4 def initialize() @jobs = Hash.new @env = Hash.new @sequences = Hash.new case when String config = when Hash config = if [:string] [:string] elsif [:file] File.read([:file]) end pre_set([:set]) end eval(config) end |
Instance Method Details
#cap(task, options = {}) ⇒ Object
76 77 78 79 80 |
# File 'lib/whenever/job_list.rb', line 76 def cap(task, = {}) .reverse_merge!(:environment => @environment, :path => @path) [:class] = Whenever::Job::CapTask command(task, ) end |
#command(task, options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/whenever/job_list.rb', line 48 def command(task, = {}) # :cron_log was an old option for output redirection, it remains for backwards compatibility [:output] = ([:cron_log] || @cron_log) if defined?(@cron_log) || .has_key?(:cron_log) # :output is the newer, more flexible option. [:output] = @output if defined?(@output) && !.has_key?(:output) [:class] ||= Whenever::Job::Default @jobs[@current_time_scope] ||= [] if @current_sequence @current_sequence << [:class].new(@options.merge(:task => task).merge()) else @jobs[@current_time_scope] << [:class].new(@options.merge(:task => task).merge()) end end |
#env(variable, value) ⇒ Object
31 32 33 |
# File 'lib/whenever/job_list.rb', line 31 def env(variable, value) @env[variable.to_s] = value end |
#every(frequency, options = {}) ⇒ Object
35 36 37 38 39 |
# File 'lib/whenever/job_list.rb', line 35 def every(frequency, = {}) @current_time_scope = frequency @options = yield end |
#generate_cron_output ⇒ Object
82 83 84 85 86 |
# File 'lib/whenever/job_list.rb', line 82 def generate_cron_output set_path_environment_variable [environment_variables, cron_jobs].compact.join end |
#in_sequence(options = {}) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/whenever/job_list.rb', line 41 def in_sequence(={}) @current_sequence = JobSequence.new(@options.merge()) yield @jobs[@current_time_scope] << @current_sequence @current_sequence = nil end |
#rake(task, options = {}) ⇒ Object
70 71 72 73 74 |
# File 'lib/whenever/job_list.rb', line 70 def rake(task, = {}) .reverse_merge!(:environment => @environment, :path => @path) [:class] = Whenever::Job::RakeTask command(task, ) end |
#runner(task, options = {}) ⇒ Object
64 65 66 67 68 |
# File 'lib/whenever/job_list.rb', line 64 def runner(task, = {}) .reverse_merge!(:environment => @environment, :path => @path) [:class] = Whenever::Job::Runner command(task, ) end |
#set(variable, value) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/whenever/job_list.rb', line 24 def set(variable, value) return if instance_variable_defined?("@#{variable}".to_sym) instance_variable_set("@#{variable}".to_sym, value) self.class.send(:attr_reader, variable.to_sym) end |