Sha256: f6c65c3dad40010169f0766b08788278b6823455c840eb5b251b2bdc34687f70
Contents?: true
Size: 913 Bytes
Versions: 7
Compression:
Stored size: 913 Bytes
Contents
module WebTranslateIt module Safe class Sink < Stream def process return unless active? save cleanup end protected # 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 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, &) return unless files.size > limit to_remove = files[0..(files.size - limit - 1)] # TODO: validate here to_remove.each(&) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems