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)


94
95
96
# File 'lib/rsync/change.rb', line 94

def acl
  attribute_prop(9)
end

#changed?Boolean

Whether the file was changed or not.

Returns:

  • (Boolean)


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

def changed?
  if update_type == :no_change
    false
  else
    true
  end
end

#checksumSymbol

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

Returns:

  • (Symbol)


58
59
60
# File 'lib/rsync/change.rb', line 58

def checksum
  attribute_prop(2)
end

#ext_attrSymbol

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

Returns:

  • (Symbol)


100
101
102
# File 'lib/rsync/change.rb', line 100

def ext_attr
  attribute_prop(10)
end

#file_typeSymbol

The type of file.

:file
:directory
:symlink
:device
:special

Returns:

  • (Symbol)


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

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)


88
89
90
# File 'lib/rsync/change.rb', line 88

def group
  attribute_prop(7)
end

#ownerSymbol

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

Returns:

  • (Symbol)


82
83
84
# File 'lib/rsync/change.rb', line 82

def owner
  attribute_prop(6)
end

#permissionsSymbol

The change, if any, to the file permissions.

Returns:

  • (Symbol)


76
77
78
# File 'lib/rsync/change.rb', line 76

def permissions
  attribute_prop(5)
end

#sizeSymbol

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

Returns:

  • (Symbol)


64
65
66
# File 'lib/rsync/change.rb', line 64

def size
  attribute_prop(3)
end

#summaryString

Simple description of the change.

Returns:

  • (String)


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

def summary
  if update_type == :message
    message
  elsif update_type == :recv and @data[2,9] == "+++++++++"
    "creating local"
  elsif update_type == :recv
    "updating local"
  elsif update_type == :sent and @data[2,9] == "+++++++++"
    "creating remote"
  elsif update_type == :sent
    "updating remote"
  else
    changes = []
    [:checksum, :size, :timestamp, :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)


70
71
72
# File 'lib/rsync/change.rb', line 70

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)


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

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