class Marz::Rsync::Result
The result of an rsync job
Constants
- ERROR_CODES
Rsync
exit values/error codes
Attributes
exitcode[RW]
Exit code of an rsync job
output[RW]
Output of an rsync job
Public Class Methods
new(output, exitcode)
click to toggle source
# File lib/marz/rsync/result.rb, line 36 def initialize(output, exitcode) @output = output @exitcode = exitcode end
Public Instance Methods
error()
click to toggle source
Error message corresponding to the exit code/error code @return {String}
# File lib/marz/rsync/result.rb, line 49 def error return nil if @exitcode == 0 error_key = @exitcode.to_s if ERROR_CODES.has_key? error_key ERROR_CODES[error_key].to_s elsif @raw_output =~ /Permission denied \(publickey\)/ "Permission denied (publickey)" else "Unknown Error" end end
success?()
click to toggle source
Whether rsync job run without errors @return {Boolean}
# File lib/marz/rsync/result.rb, line 43 def success? @exitcode == 0 end
total_bytes_received()
click to toggle source
Total bytes received @return {String}
# File lib/marz/rsync/result.rb, line 78 def total_bytes_received return nil if @exitcode != 0 || @output.nil? @output.match(/^*(?:Total bytes received: )(\d\S*|\d+\.\d+\S*)/)[1] end
total_bytes_sent()
click to toggle source
Total bytes sent @return {String}
# File lib/marz/rsync/result.rb, line 71 def total_bytes_sent return nil if @exitcode != 0 || @output.nil? @output.match(/^*(?:Total bytes sent: )(\d\S*|\d+\.\d+\S*)/)[1] end
total_size()
click to toggle source
Total size of the rsync job @return {String}
# File lib/marz/rsync/result.rb, line 63 def total_size return nil if @exitcode != 0 || @output.nil? #@output.match(/^*(?:total size is )(\d+\.\d+\S)/)[1] @output.match(/^*(?:total size is )(\d\S*|\d+\.\d+\S*)/)[1] end