Sha256: 96be526a1eea19bac9d339aaf5227baa9dcce955fbc60d08977ec95e10a8411c
Contents?: true
Size: 675 Bytes
Versions: 3
Compression:
Stored size: 675 Bytes
Contents
# frozen_string_literal: true module Expire # Keep the most recent Backups class KeepMostRecentRule < RuleBase using RefineAllAndNone RULE_RANK = 10 def self.from_value(value) return new(amount: 0) if value.none? new(amount: Integer(value)) end def self.rank RULE_RANK end def rank self.class.rank end def apply(backups, _) backups.most_recent(amount).each do |backup| backup.add_reason_to_keep(reason_to_keep) end end private def reason_to_keep return 'keep the most recent backup' if amount == 1 "keep the #{amount} most recent backups" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
expire-0.2.2 | lib/expire/keep_most_recent_rule.rb |
expire-0.2.1 | lib/expire/keep_most_recent_rule.rb |
expire-0.2.0 | lib/expire/keep_most_recent_rule.rb |