class Astrails::Safe::Sink
Public Instance Methods
process()
click to toggle source
# File lib/astrails/safe/sink.rb, line 5 def process return unless active? save cleanup end
Protected Instance Methods
base()
click to toggle source
path is defined in subclass base is used in ‘cleanup’ to find all files that begin with base. the ‘.’ at the end is essential to distinguish b/w foo.* and foobar.* archives for example
# File lib/astrails/safe/sink.rb, line 17 def base @base ||= File.join(path, File.basename(@backup.filename).split(".").first + '.') end
cleanup_with_limit(files, limit, &block)
click to toggle source
call block on files to be removed (all except for the LAST ‘limit’ files
# File lib/astrails/safe/sink.rb, line 26 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
full_path()
click to toggle source
# File lib/astrails/safe/sink.rb, line 21 def full_path @full_path ||= File.join(path, @backup.filename) + @backup.extension end