Module: Factorix::CLI::Commands::BackupSupport
- Defined in:
- lib/factorix/cli/commands/backup_support.rb
Overview
Mixin for commands that backup files before writing
This module provides:
-
–backup-extension option to specify backup file extension
-
backup_if_exists method to backup a file before overwriting
Prepend this module to commands that modify mod-list.json or mod-settings.dat
Class Method Summary collapse
-
.prepended(base) ⇒ Object
Hook called when this module is prepended to a class.
Instance Method Summary collapse
-
#call(**options) ⇒ Object
Store the –backup-extension option for use in backup_if_exists.
Class Method Details
.prepended(base) ⇒ Object
Hook called when this module is prepended to a class
16 17 18 19 20 |
# File 'lib/factorix/cli/commands/backup_support.rb', line 16 def self.prepended(base) base.class_eval do option :backup_extension, default: ".bak", desc: "Backup file extension" end end |
Instance Method Details
#call(**options) ⇒ Object
Store the –backup-extension option for use in backup_if_exists
28 29 30 31 |
# File 'lib/factorix/cli/commands/backup_support.rb', line 28 def call(**) @backup_extension = [:backup_extension] || DEFAULT_BACKUP_EXTENSION super end |