Module: CSVPlusPlus::Writer::FileBackerUpper

Extended by:
T::Sig
Includes:
Kernel
Included in:
CSV, Excel, OpenDocument
Defined in:
lib/csv_plus_plus/writer/file_backer_upper.rb

Overview

A module that can be mixed into any Writer that needs to back up it’s @output_filename (all of them except Google Sheets)

Instance Method Summary collapse

Instance Method Details

#backup_file(options) ⇒ Object

Assuming the underlying spreadsheet is file-based, create a backup of it



26
27
28
29
30
31
32
33
34
# File 'lib/csv_plus_plus/writer/file_backer_upper.rb', line 26

def backup_file(options)
  return unless ::File.exist?(options.output_filename)

  # TODO: also don't do anything if the current backups contents haven't changed (do a md5sum or something)

  attempt_backups(options).tap do |backed_up_to|
    puts("Backed up #{options.output_filename} to #{backed_up_to}") if options.verbose
  end
end