Module: PrlBackup
- Included in:
- Backup, Backup, VirtualMachine, VirtualMachine
- Defined in:
- lib/prlbackup.rb,
lib/prlbackup/cli.rb,
lib/prlbackup/backup.rb,
lib/prlbackup/version.rb,
lib/prlbackup/virtual_machine.rb
Defined Under Namespace
Classes: Backup, CLI, VirtualMachine
Constant Summary collapse
- VERSION =
'1.3.0'
Class Attribute Summary collapse
-
.config ⇒ Object
The global configuration based on command line options.
Instance Method Summary collapse
-
#conditionally_run(*args) ⇒ String
Run the command and log the last line from stdout unless –dry-run.
- #logger ⇒ Object
-
#run(*args) ⇒ String
Run the command until it is finished.
Class Attribute Details
.config ⇒ Object
The global configuration based on command line options.
13 14 15 |
# File 'lib/prlbackup.rb', line 13 def config @config end |
Instance Method Details
#conditionally_run(*args) ⇒ String
Run the command and log the last line from stdout unless –dry-run.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/prlbackup.rb', line 18 def conditionally_run(*args) unless PrlBackup.config[:dry_run] output = run(*args) logger.info(output.split("\n").last) else output = '' logger.info("Dry-running `#{args.shelljoin}`...") end output end |
#logger ⇒ Object
43 44 45 |
# File 'lib/prlbackup.rb', line 43 def logger @logger ||= create_logger end |
#run(*args) ⇒ String
Run the command until it is finished.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/prlbackup.rb', line 32 def run(*args) logger.info("Running `#{args.shelljoin}`...") if PrlBackup.config[:verbose] output = `#{args.shelljoin} 2>&1` status = $? unless status.success? logger.error("Command `#{args.shelljoin}` failed with exit status #{status.exitstatus}:\n#{output}") exit(1) end output end |