Class: DevSuite::Utils::FileWriter::BackupManager
- Inherits:
-
Object
- Object
- DevSuite::Utils::FileWriter::BackupManager
- Defined in:
- lib/dev_suite/utils/file_writer/backup_manager.rb
Instance Method Summary collapse
- #create_backup ⇒ Object
-
#initialize(path) ⇒ BackupManager
constructor
A new instance of BackupManager.
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_backup ⇒ Object
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.}" end |