Class: DevSuite::Utils::FileWriter::BackupManager

Inherits:
Object
  • Object
show all
Defined in:
lib/dev_suite/utils/file_writer/backup_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ BackupManager

Returns a new instance of BackupManager.



7
8
9
# File 'lib/dev_suite/utils/file_writer/backup_manager.rb', line 7

def initialize(path)
  @path = path
end

Instance Method Details

#create_backupObject



11
12
13
14
15
16
17
# File 'lib/dev_suite/utils/file_writer/backup_manager.rb', line 11

def create_backup
  backup_path = "#{@path}.bak"
  Logger.log("Creating backup of #{@path} at #{backup_path}", level: :info)
  ::FileUtils.cp(@path, backup_path)
rescue IOError => e
  raise "Failed to create backup: #{e.message}"
end