Class: DiffDirs

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

Class Method Summary collapse

Class Method Details

.diff_dirs(dir1, dir2) ⇒ Object

Raises:

  • (ArgumentError)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/diff_dirs.rb', line 2

def self.diff_dirs(dir1, dir2)
  raise(ArgumentError, "Directories must be strings.") unless dir1.is_a?(String) && dir2.is_a?(String)
  
  dir1 = expand_path(dir1)
  dir2 = expand_path(dir2)
  
  cmd = "diff -qr #{dir1} #{dir2}"
  diff_result = execute(cmd)
  out = []
  diff_result.each_line do |line|
    line.chomp!
    out << diff_result_line_parse(dir1, dir2, line)
  end
  out
end