Sha256: 7e6ca7dd23a5972158c253b5a99a30e31410e066a0beae56a92b65ea052ebdaa
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require "daily_weekly_monthly/processor" require "daily_weekly_monthly/downloader" module DailyWeeklyMonthly class Runner 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, }.freeze def initialize backup_command, options = {} @backup_command = backup_command @options = DEFAULTS.merge(options) end 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 private def weekly_backup? Date.today.wday == @options[:day_of_week] end def monthly_backup? Date.today.day == @options[:day_of_month] end def backup Downloader.new(@backup_command).call end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
daily_weekly_monthly-0.0.2 | lib/daily_weekly_monthly/runner.rb |