46dbc43eafb510d98d21fcb303ca2ffd873e3089
Dev Now detecting difference in...

Dev authored 7 years ago

1) require 'fileutils'
2) 
Dev Refactoring. Adding pkg mgmt.

Dev authored 7 years ago

3) module RCM
4)   class File
Dev Working everything.

Dev authored 7 years ago

5)     attr_accessor :path, :owner, :group, :mode, :state, :src_path, :changed
6) 
7)     PRESENT = 'present'.freeze
8)     ABSENT = 'absent'.freeze
Dev Refactoring. Adding pkg mgmt.

Dev authored 7 years ago

9) 
10)     def ==(other)
11)       return false unless other.is_a?(RCM::File)
12) 
Dev Working everything.

Dev authored 7 years ago

13)       # Paths are same and status is absent for both
14)       return true if @state == ABSENT && other.state == ABSENT && @path == other.path
Dev Now detecting difference in...

Dev authored 7 years ago

15) 
Dev Solidifying file comparison.

Dev authored 7 years ago

16)       # Return false if any of the attributes don't match
17)       return false unless @owner == other.owner &&
Dev Refactoring. Adding pkg mgmt.

Dev authored 7 years ago

18)           @group == other.group &&
Dev Working everything.

Dev authored 7 years ago

19)           @mode == other.mode &&
20)           @state == other.state &&
Dev Solidifying file comparison.

Dev authored 7 years ago

21)           @path == other.path
22) 
23)       # Check contents of file. At this point, path will be same for the 2 objects.
24)       unless @src_path.empty?
25)         return ::FileUtils.compare_file(@path, @src_path)
26)       end
27) 
28)       unless other.src_path.empty?
29)         return ::FileUtils.compare_file(@path, other.src_path)
30)       end
31) 
Dev Now detecting difference in...

Dev authored 7 years ago

32) 
Dev Refactoring. Adding pkg mgmt.

Dev authored 7 years ago

33)     end
34) 
Dev Working everything.

Dev authored 7 years ago

35)     def initialize(path, owner, group, mode, src_path, state)
Dev Refactoring. Adding pkg mgmt.

Dev authored 7 years ago

36)       @path = path
37)       @owner = owner
38)       @group = group
39)       @mode = mode
Dev Now detecting difference in...

Dev authored 7 years ago

40)       @src_path = src_path
Dev Working everything.

Dev authored 7 years ago

41)       @state = state
Dev Now detecting difference in...

Dev authored 7 years ago

42)       @changed = false
Dev Refactoring. Adding pkg mgmt.

Dev authored 7 years ago

43)     end
44) 
45)     def to_s
46)       "Path = #{@path}\n" +
47)       "Owner = #{@owner}\n" +
48)       "Group = #{@group}\n" +
49)       "Mode = #{@mode}\n" +
Dev Now detecting difference in...

Dev authored 7 years ago

50)       "Source Path = #{src_path}\n" +
51)       "Changed = #{@changed}"