Module: DatedBackup::DSL::TimeExtensions
- Defined in:
- lib/dated_backup/dsl/time_extensions.rb
Overview
After a run through the DSL, the TimeExtensions#kept method should contain an array of all of the items to keep. Each item will be a hash with two keys: a :constraint key, which contains a range of Times (from oldest to newest), and a :scope key, which will indicate whether the backup to look at is a weekly, monthly, etc. If no :scope key is given, then all of the backups in the time range given by the :constraint key will be assumed to be kept.
Instance Attribute Summary collapse
-
#kept ⇒ Object
readonly
Returns the value of attribute kept.
-
#last_time ⇒ Object
readonly
Returns the value of attribute last_time.
-
#time_range ⇒ Object
readonly
Returns the value of attribute time_range.
Instance Method Summary collapse
- #all(arg = self, now = Time.now) ⇒ Object
- #backup(*args) ⇒ Object (also: #backups)
- #from(*args) ⇒ Object
- #initialize ⇒ Object
- #keep(arg, now = Time.now) ⇒ Object
- #last(arg, now = Time.now) ⇒ Object
- #this(arg, now = Time.now) ⇒ Object
Instance Attribute Details
#kept ⇒ Object (readonly)
Returns the value of attribute kept.
17 18 19 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 17 def kept @kept end |
#last_time ⇒ Object (readonly)
Returns the value of attribute last_time.
16 17 18 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 16 def last_time @last_time end |
#time_range ⇒ Object (readonly)
Returns the value of attribute time_range.
16 17 18 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 16 def time_range @time_range end |
Instance Method Details
#all(arg = self, now = Time.now) ⇒ Object
61 62 63 64 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 61 def all arg=self, now=Time.now @time_range[:constraint] = Time.epoch...now self end |
#backup(*args) ⇒ Object Also known as: backups
25 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 25 def backup *args; return self; end |
#from(*args) ⇒ Object
26 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 26 def from *args; return self; end |
#initialize ⇒ Object
19 20 21 22 23 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 19 def initialize @kept = [] @time_range = {} @last_time = nil end |
#keep(arg, now = Time.now) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 53 def keep arg, now=Time.now all(self, now) unless time_range[:constraint] @kept << time_range reset_times self end |
#last(arg, now = Time.now) ⇒ Object
49 50 51 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 49 def last arg, now=Time.now set_time_range :last, now end |
#this(arg, now = Time.now) ⇒ Object
45 46 47 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 45 def this arg, now=Time.now set_time_range :this, now end |