Sha256: 800a8a96aadc160661f721a78206b2ef06bbb074074e0bd6b02204706d8a50f3

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

# frozen_string_literal: true

class Rustic::CommandBuilders::Backup
  attr_reader :config

  def initialize(config)
    @config = config.backup_config
  end

  def build
    raise Rustic::CommandBuilder::MissingConfigError, "Command `backup` misses it's configuration" if @config.nil?
    raise Rustic::CommandBuilder::MalformedConfigError, "Backup paths cannot be empty" if @config.paths.empty?

    [
      "backup",
      @config.one_fs ? "-x" : nil,
      *@config.paths,
      *excludes
    ].compact
  end

  private

  def excludes = ["--exclude"].product(@config.excluded_paths).flatten
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rustic-0.3.2 lib/rustic/command_builders/backup.rb
rustic-0.3.1 lib/rustic/command_builders/backup.rb