Sha256: 2d17ece68ebdef7216bc0f2a0e0f362f94ff5094c569007aaa24a07f893b37b4

Contents?: true

Size: 616 Bytes

Versions: 3

Compression:

Stored size: 616 Bytes

Contents

module Astrails
  module Safe
    class Sink < Stream

      def process
        return unless active?

        save
        cleanup
      end

      protected

      # prefix is defined in subclass
      def path
        @path ||= File.join(prefix, @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

3 entries across 3 versions & 1 rubygems

Version Path
astrails-safe-0.1.7 lib/astrails/safe/sink.rb
astrails-safe-0.1.8 lib/astrails/safe/sink.rb
astrails-safe-0.1.9 lib/astrails/safe/sink.rb