Class: DailyWeeklyMonthly::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/daily_weekly_monthly/runner.rb

Constant Summary collapse

DEFAULTS =
{
  backups_dir: File.expand_path("~/backups"),
  output_extension: "pgdump.gz",
  day_of_week: 1,
  day_of_month: 1,
  days_to_keep: 7,
  weeks_to_keep: 5,
  months_to_keep: 12,
  smtp_server: false,
  smtp_port: false,
  notify: false,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(backup_command, options = {}) ⇒ Runner

Returns a new instance of Runner.



20
21
22
23
# File 'lib/daily_weekly_monthly/runner.rb', line 20

def initialize backup_command, options = {}
  @backup_command = backup_command
  @options = DEFAULTS.merge(options)
end

Instance Method Details

#callObject



25
26
27
28
29
30
# File 'lib/daily_weekly_monthly/runner.rb', line 25

def call
  processor = Processor.new(backup, @options[:backups_dir], @options[:output_extension])
  processor.call("daily", keep: @options[:days_to_keep])
  processor.call("weekly", keep: @options[:weeks_to_keep]) if weekly_backup?
  processor.call("monthly", keep: @options[:months_to_keep]) if monthly_backup?
end