Class: Tms::Comparison
- Inherits:
-
Object
- Object
- Tms::Comparison
- Defined in:
- lib/tms/comparison.rb
Instance Attribute Summary collapse
-
#backup_a ⇒ Object
readonly
Returns the value of attribute backup_a.
-
#backup_b ⇒ Object
readonly
Returns the value of attribute backup_b.
Instance Method Summary collapse
-
#initialize(backup_a, backup_b) ⇒ Comparison
constructor
A new instance of Comparison.
- #run ⇒ Object
Constructor Details
#initialize(backup_a, backup_b) ⇒ Comparison
Returns a new instance of Comparison.
8 9 10 |
# File 'lib/tms/comparison.rb', line 8 def initialize(backup_a, backup_b) @backup_a, @backup_b = backup_a, backup_b end |
Instance Attribute Details
#backup_a ⇒ Object (readonly)
Returns the value of attribute backup_a.
7 8 9 |
# File 'lib/tms/comparison.rb', line 7 def backup_a @backup_a end |
#backup_b ⇒ Object (readonly)
Returns the value of attribute backup_b.
7 8 9 |
# File 'lib/tms/comparison.rb', line 7 def backup_b @backup_b end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tms/comparison.rb', line 12 def run @a_total, @b_total = 0, 0 begin root_dirs = (backup_a.path.children(false) | backup_b.path.children(false)).sort root_dirs.reject!{ |root_dir| root_dir.path[0, 1] == '.' } root_dirs.each do |root_dir| dirs = Backup.filter_dirs? ? Backup.filter_dirs.map{ |filter_dir| root_dir / filter_dir } : [root_dir] dirs.each do |dir| compare(backup_a.path / dir, backup_b.path / dir, Path.new('/', dir)) end end rescue Interrupt puts puts 'Interrupted' end if Tms::Backup.show_both_sizes? line [colorize('Total:', :total), space(@a_total), space(@b_total)].join(' ') else line [colorize('Total:', :total), space(@b_total)].join(' ') end end |