Class: Expire::Playground
- Inherits:
-
Object
- Object
- Expire::Playground
- Defined in:
- lib/expire/playground.rb
Overview
Create playground with example data
Constant Summary collapse
- STEP_WIDTHS =
{ "hourly" => "hour", "daily" => "day", "weekly" => "week", "monthly" => "month", "yearly" => "year" }.freeze
Instance Attribute Summary collapse
-
#backups_dir ⇒ Object
readonly
Returns the value of attribute backups_dir.
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(base) ⇒ Playground
constructor
A new instance of Playground.
Constructor Details
#initialize(base) ⇒ Playground
Returns a new instance of Playground.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/expire/playground.rb', line 18 def initialize(base) @base = base @backups_dir = Pathname.new("#{base}/backups") = { hourly: 42, daily: 15, weekly: 15, monthly: 25, yearly: 5 } end |
Instance Attribute Details
#backups_dir ⇒ Object (readonly)
Returns the value of attribute backups_dir.
31 32 33 |
# File 'lib/expire/playground.rb', line 31 def backups_dir @backups_dir end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
31 32 33 |
# File 'lib/expire/playground.rb', line 31 def base @base end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
31 32 33 |
# File 'lib/expire/playground.rb', line 31 def end |
Class Method Details
.create(base) ⇒ Object
14 15 16 |
# File 'lib/expire/playground.rb', line 14 def self.create(base) new(base).create end |
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/expire/playground.rb', line 33 def create raise_if_backups_dir_exists oldest_backup = Time.now STEP_WIDTHS.each do |adjective, noun| [adjective.to_sym].times do oldest_backup = oldest_backup.ago(1.send(noun)) mkbackup(oldest_backup) end end end |