Class: Wheneverd::DSL::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/wheneverd/dsl/loader.rb

Overview

Loads a schedule file into a Schedule.

This evaluates the file as Ruby in an isolated DSL context, and wraps errors with the schedule path for clearer CLI output.

Note that schedules are arbitrary Ruby code. Do not load untrusted schedule files.

Class Method Summary collapse

Class Method Details

.load_file(path) ⇒ Wheneverd::Schedule

Load and evaluate a schedule file.

Parameters:

  • path (String)

Returns:



16
17
18
19
20
21
22
23
# File 'lib/wheneverd/dsl/loader.rb', line 16

def self.load_file(path)
  absolute_path = File.expand_path(path.to_s)
  evaluate_file(absolute_path)
rescue Wheneverd::DSL::Error => e
  raise_with_path(e, absolute_path)
rescue Wheneverd::Error, StandardError => e
  raise_load_error(e, absolute_path)
end