Class: Rustic::Evaluator

Inherits:
Object
  • Object
show all
Includes:
Console
Defined in:
lib/rustic/evaluator.rb

Instance Method Summary collapse

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

#evaluateObject



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)