class Jujube::JobLoader

Loads job definitions from a set of files and/or directories.

Public Instance Methods

load_jobs(*pathnames) click to toggle source

Load job definitions from one or more files and/or directories.

The job definition files are loaded as Ruby files; it is expected that will make use of the {DSL#job} DSL function, but they can contain other Ruby code as well.

@param pathnames [Pathname…] The file or directory names containing the job definitions.

# File lib/jujube/job_loader.rb, line 14
def load_jobs(*pathnames)
  Job.all_defined_during do
    pathnames.each do |path|
      load_one(path)
    end
  end
end

Private Instance Methods

load_directory(path) click to toggle source

Load jobs from all (recursive) files in a directory.

@param path [Pathname] The directory to search.

# File lib/jujube/job_loader.rb, line 38
def load_directory(path)
  path.each_child do |child|
    load_one(child)
  end
end
load_file(path) click to toggle source

Load jobs from a single file.

@param path [Pathname] The file to load.

# File lib/jujube/job_loader.rb, line 47
def load_file(path)
  load(path)
end
load_one(path) click to toggle source

Load jobs from a single file or directory

@param path [Pathname] The file or directory to load from.

# File lib/jujube/job_loader.rb, line 27
def load_one(path)
  if path.directory?
    load_directory(path)
  else
    load_file(path)
  end
end