Sha256: d108eb4c43fbe5f6f07853010b677751a3a220c6446ea7bddc83a7662fae2ff5
Contents?: true
Size: 845 Bytes
Versions: 4
Compression:
Stored size: 845 Bytes
Contents
module BackupRepos class Shell def initialize(opts = {}) @debug = opts[:debug] || false end def run(command) log_command(command) execute_command(command) end private def debug? @debug || BackupRepos.config.debug end def execute_command(command) output = IO.popen(command, 'r', err: [:child, :out]) do |io| output = io.read log_output(output) output end [success?(output), output] end def success?(output) return false if output =~ /remote error\:/ return false if output =~ /fatal\:/ true end def log_command(command) return unless debug? puts "EXECUTING: #{command}" end def log_output(output) return unless debug? puts 'OUTPUT:' puts output end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
backup_repos-0.3.0 | lib/backup_repos/shell.rb |
backup_repos-0.2.1 | lib/backup_repos/shell.rb |
backup_repos-0.2.0 | lib/backup_repos/shell.rb |
backup_repos-0.1.0 | lib/backup_repos/shell.rb |