Sha256: dc43c2234c2ecba9ff56dea79641845249ec9a171e4767b5d888a6fe614100d1

Contents?: true

Size: 732 Bytes

Versions: 2

Compression:

Stored size: 732 Bytes

Contents

module Astrails
  module Safe
    class Sink < Stream

      def process
        return unless active?

        save
        cleanup
      end

      protected

      # path is defined in subclass
      def base
        @base ||= File.join(path, File.basename(@backup.filename).split(".").first)
      end

      def full_path
        @full_path ||= File.join(path, @backup.filename) + @backup.extension
      end

      # call block on files to be removed (all except for the LAST 'limit' files
      def cleanup_with_limit(files, limit, &block)
        return unless files.size > limit

        to_remove = files[0..(files.size - limit - 1)]
        # TODO: validate here
        to_remove.each(&block)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
astrails-safe-0.1.10 lib/astrails/safe/sink.rb
astrails-safe-0.2.0 lib/astrails/safe/sink.rb