Sha256: cf615f80140da663c1b97a00fb63d46f4ec8459d95fd9deb1d3c6242fb130a6c

Contents?: true

Size: 738 Bytes

Versions: 8

Compression:

Stored size: 738 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

8 entries across 8 versions & 2 rubygems

Version Path
astrails-safe-0.2.1 lib/astrails/safe/sink.rb
astrails-safe-0.2.2 lib/astrails/safe/sink.rb
astrails-safe-0.2.3 lib/astrails/safe/sink.rb
bostonlogic-safe-0.3.0 lib/astrails/safe/sink.rb
astrails-safe-0.2.7 lib/astrails/safe/sink.rb
astrails-safe-0.2.6 lib/astrails/safe/sink.rb
astrails-safe-0.2.5 lib/astrails/safe/sink.rb
astrails-safe-0.2.4 lib/astrails/safe/sink.rb