Class: Rustic::Evaluator
- Inherits:
-
Object
- Object
- Rustic::Evaluator
- Includes:
- Console
- Defined in:
- lib/rustic/evaluator.rb
Instance Method Summary collapse
- #backup! ⇒ Object
- #evaluate ⇒ Object
-
#initialize(config) ⇒ Evaluator
constructor
A new instance of Evaluator.
- #on_error(error) ⇒ Object
- #with_hooks(config, args = nil, &block) ⇒ Object
Constructor Details
#initialize(config) ⇒ Evaluator
6 |
# File 'lib/rustic/evaluator.rb', line 6 def initialize(config) = @config = config |
Instance Method Details
#backup! ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rustic/evaluator.rb', line 19 def backup! with_hooks(@config.backup_config) do command, env = Rustic::CommandBuilder.new("backup", @config).build Rustic::Wrapper.new(command, env).run end end |
#evaluate ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/rustic/evaluator.rb', line 8 def evaluate with_hooks(@config) do backup! unless @config.backup_config.nil? end rescue StandardError => e on_error(e) raise end |
#on_error(error) ⇒ Object
17 |
# File 'lib/rustic/evaluator.rb', line 17 def on_error(error) = @config.on_error&.call(error) |
#with_hooks(config, args = nil, &block) ⇒ Object
26 |
# File 'lib/rustic/evaluator.rb', line 26 def with_hooks(config, args = nil, &block) = Rustic::Hooks.new(config).with_hooks(args, &block) |