class Rsync::Result

The result of a sync.

Constants

ERROR_CODES

Error messages by exit code

Attributes

exitcode[RW]

Exit code returned by rsync

Public Class Methods

new(raw, exitcode) click to toggle source

@!visibility private

# File lib/rsync/result.rb, line 34
def initialize(raw, exitcode)
  @raw = raw
  @exitcode = exitcode
end

Public Instance Methods

changes() click to toggle source

List of changes made during this run.

@return {Array<Change>}

# File lib/rsync/result.rb, line 59
def changes
  change_list
end
error() click to toggle source

The error message based on exit code. @return {String}

# File lib/rsync/result.rb, line 47
def error
  error_key = @exitcode.to_s
  if ERROR_CODES.has_key? error_key
    ERROR_CODES[error_key]
  else
    "Unknown Error"
  end
end
success?() click to toggle source

Whether the rsync job was run without errors. @return {Boolean}

# File lib/rsync/result.rb, line 41
def success?
  @exitcode == 0
end

Private Instance Methods

change_list() click to toggle source
# File lib/rsync/result.rb, line 65
def change_list
  list = []
  @raw.split("\n").each do |line|
    #if line =~ /^([<>ch.*][fdLDS][ .+\?cstTpoguax]{9}) (.*)$/
    if line =~ /^([<>ch+\.\*].{10}) (.*)$/
      detail = Change.new(line)
      list << detail if detail.changed?
    end
  end
  list
end