Class: Rsync::Change

Inherits:
Object
  • Object
show all
Defined in:
lib/rsync/change.rb

Overview

Provides details about changes made to a specific file.

Change Flags:

:no_change
:identical
:new
:unknown
:changed

Change Flags collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Change

Returns a new instance of Change.



12
13
14
# File 'lib/rsync/change.rb', line 12

def initialize(data)
  @data = data
end

Instance Method Details

#aclSymbol

The change, if any, to the file ACL.

Returns:

  • (Symbol)


92
93
94
# File 'lib/rsync/change.rb', line 92

def acl
  attribute_prop(9)
end

#changed?Boolean

Whether the file was changed or not.

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
# File 'lib/rsync/change.rb', line 24

def changed?
  if update_type == :message
    return true
  elsif update_type == :recv
    return true
  end
  false
end

#checksumSymbol

The change, if any, to the checksum of the file.

Returns:

  • (Symbol)


56
57
58
# File 'lib/rsync/change.rb', line 56

def checksum
  attribute_prop(2)
end

#ext_attrSymbol

The change, if any, to the file’s extended attributes.

Returns:

  • (Symbol)


98
99
100
# File 'lib/rsync/change.rb', line 98

def ext_attr
  attribute_prop(10)
end

#file_typeSymbol

The type of file.

:file
:directory
:symlink
:device
:special

Returns:

  • (Symbol)


140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/rsync/change.rb', line 140

def file_type
  case raw_file_type
    when 'f'
      :file
    when 'd'
      :directory
    when 'L'
      :symlink
    when 'D'
      :device
    when 'S'
      :special
  end
end

#filenameString

The filename associated with this change.

Returns:

  • (String)


18
19
20
# File 'lib/rsync/change.rb', line 18

def filename
  @data[12..-1]
end

#groupSymbol

The change, if any, to the group of the file.

Returns:

  • (Symbol)


86
87
88
# File 'lib/rsync/change.rb', line 86

def group
  attribute_prop(7)
end

#ownerSymbol

The change, if any, to the owner of the file.

Returns:

  • (Symbol)


80
81
82
# File 'lib/rsync/change.rb', line 80

def owner
  attribute_prop(6)
end

#permissionsSymbol

The change, if any, to the file permissions.

Returns:

  • (Symbol)


74
75
76
# File 'lib/rsync/change.rb', line 74

def permissions
  attribute_prop(5)
end

#sizeSymbol

The change, if any, to the size of the file.

Returns:

  • (Symbol)


62
63
64
# File 'lib/rsync/change.rb', line 62

def size
  attribute_prop(3)
end

#summaryString

Simple description of the change.

Returns:

  • (String)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rsync/change.rb', line 35

def summary
  if update_type == :message
    message
  elsif update_type == :recv and @data[2,9] == "+++++++++"
    "creating"
  elsif update_type == :recv
    "updating"
  else
    changes = []
    #[:checksum, :size, :timestamp, :permissions, :owner, :group, :acl].each do |prop|
    [:checksum, :size, :permissions, :owner, :group, :acl].each do |prop|
      changes << prop if send(prop) == :changed
    end
    changes.join(", ")
  end
end

#timestampSymbol

The change, if any, to the timestamp of the file.

Returns:

  • (Symbol)


68
69
70
# File 'lib/rsync/change.rb', line 68

def timestamp
  attribute_prop(4)
end

#update_typeSymbol

The type of update made to the file.

:sent
:recv
:change
:hard_link
:no_update
:message

Returns:

  • (Symbol)


114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/rsync/change.rb', line 114

def update_type
  case raw_update_type
    when '<'
      :sent
    when '>'
      :recv
    when 'c'
      :change
    when 'h'
      :hard_link
    when '.'
      :no_update
    when '*'
      :message
  end
end