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.
Defined Under Namespace
Modules: ClassMethods
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
- #==(obj) ⇒ Object
- #all(arg = self, now = Time.now) ⇒ Object
-
#backup(*args) ⇒ Object
(also: #backups)
placeholders:.
- #from(*args) ⇒ Object
- #initialize ⇒ Object
- #keep(arg, now = Time.now) ⇒ Object
- #last(arg, now = Time.now) ⇒ Object
- #this(arg, now = Time.now) ⇒ Object
- #today(arg = nil, now = Time.now) ⇒ Object (also: #todays)
- #yesterday(arg = nil, now = Time.now) ⇒ Object (also: #yesterdays)
Instance Attribute Details
#kept ⇒ Object (readonly)
Returns the value of attribute kept.
87 88 89 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 87 def kept @kept end |
#last_time ⇒ Object (readonly)
Returns the value of attribute last_time.
86 87 88 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 86 def last_time @last_time end |
#time_range ⇒ Object (readonly)
Returns the value of attribute time_range.
86 87 88 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 86 def time_range @time_range end |
Instance Method Details
#==(obj) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 128 def ==(obj) # return false if obj is not a kind_of this class self.instance_variables.each do |iv| return false if self.instance_variable_get(iv) != obj.instance_variable_get(iv) end true end |
#all(arg = self, now = Time.now) ⇒ Object
123 124 125 126 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 123 def all arg=self, now=Time.now @time_range[:constraint] = Time.epoch...now self end |
#backup(*args) ⇒ Object Also known as: backups
placeholders:
96 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 96 def backup *args; return self; end |
#from(*args) ⇒ Object
97 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 97 def from *args; return self; end |
#initialize ⇒ Object
89 90 91 92 93 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 89 def initialize @kept = [] @time_range = {} @last_time = nil end |
#keep(arg, now = Time.now) ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 115 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
103 104 105 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 103 def last arg, now=Time.now set_time_range :last, now end |
#this(arg, now = Time.now) ⇒ Object
99 100 101 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 99 def this arg, now=Time.now set_time_range :this, now end |
#today(arg = nil, now = Time.now) ⇒ Object Also known as: todays
107 108 109 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 107 def today(arg=nil, now=Time.now) this(day, now) end |
#yesterday(arg = nil, now = Time.now) ⇒ Object Also known as: yesterdays
111 112 113 |
# File 'lib/dated_backup/dsl/time_extensions.rb', line 111 def yesterday(arg=nil, now=Time.now) last(day, now) end |