Sha256: 1cac75a99ae1fc31564fd829fb04459cc6ea5199365e9149303f5ca41f054bb9

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Backup
  class Package
    ##
    # The time when the backup initiated (in format: 2011.02.20.03.29.59)
    attr_accessor :time

    ##
    # The trigger which initiated the backup process
    attr_reader :trigger

    ##
    # Extension for the final archive file(s)
    attr_accessor :extension

    ##
    # Set by the Splitter if the final archive was "chunked"
    attr_accessor :chunk_suffixes

    ##
    # If true, the Cycler will not attempt to remove the package when Cycling.
    attr_accessor :no_cycle

    ##
    # The version of Backup used to create the package
    attr_reader :version

    def initialize(model)
      @trigger = model.trigger.dup
      @extension = "tar".dup
      @chunk_suffixes = []
      @no_cycle = false
      @version = VERSION
    end

    def filenames
      if chunk_suffixes.empty?
        [basename]
      else
        chunk_suffixes.map { |suffix| "#{basename}-#{suffix}" }
      end
    end

    def basename
      "#{trigger}.#{extension}"
    end

    def time_as_object
      Time.strptime(time, "%Y.%m.%d.%H.%M.%S")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
backupii-0.1.0.pre.alpha.2 lib/backup/package.rb
backupii-0.1.0.pre.alpha.1 lib/backup/package.rb