Class: Lobster::JobList

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ JobList

Returns a new instance of JobList.



5
6
7
8
9
# File 'lib/lobster/job_list.rb', line 5

def initialize(config)
  @config = config
  @current_options = nil
  @jobs = {}
end

Instance Attribute Details

#jobsObject

Returns the value of attribute jobs.



3
4
5
# File 'lib/lobster/job_list.rb', line 3

def jobs
  @jobs
end

Instance Method Details

#cmd(command) ⇒ Object

backward compatibility



40
41
42
# File 'lib/lobster/job_list.rb', line 40

def cmd(command)
  @current_options[:command] = command
end

#environmentObject

config data



45
46
47
# File 'lib/lobster/job_list.rb', line 45

def environment
  @config[:environment]
end

#job(name) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/lobster/job_list.rb', line 25

def job(name)
  @current_options = {}
  yield
  @new_jobs[name] ||= @jobs[name] || Job.new(name)
  @new_jobs[name].reload(@current_options, @config[:lobster_dir])
  @current_options = nil
end

#reloadObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/lobster/job_list.rb', line 11

def reload
  @new_jobs = {}

  file = @config[:schedule_file]
  instance_eval(File.read(file),file)

  # purely for logging
  @jobs.each do |name, job|
    job.destroy unless @new_jobs[name]
  end

  @jobs = @new_jobs
end